-
Notifications
You must be signed in to change notification settings - Fork 382
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
32 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,33 @@ | ||
#!/usr/bin/env coffee | ||
|
||
# qqbot相关的测试代码 | ||
int = (v) -> parseInt v | ||
log = console.log | ||
|
||
log = new (require 'log')('debug') | ||
jsons = JSON.stringify | ||
|
||
auth = require "../src/qqauth" | ||
|
||
api = require "../src/qqapi" | ||
QQBot = require "../src/qqbot" | ||
defaults = require '../src/defaults' | ||
|
||
config = require '../config' | ||
qq = config.account | ||
pass = config.password | ||
|
||
|
||
# 设置登录信息 | ||
api.cookies defaults.data 'cookie' | ||
auth_opts = defaults.data 'auth' | ||
### | ||
auth_opts ={ | ||
psessionid | ||
clientid | ||
ptwebqq | ||
uin | ||
vfwebqq | ||
} | ||
### | ||
|
||
|
||
bot = new QQBot( api.cookies(), auth_opts ,config ) | ||
|
||
|
||
api.get_buddy_list auth_opts, (ret,e)-> | ||
log e if e | ||
log 'friend',jsons ret | ||
log '' | ||
bot.save_buddy_info ret.result if ret.retcode == 0 | ||
|
||
|
||
api.get_group_list auth_opts, (ret , e)-> | ||
log e if e | ||
log 'group',jsons ret | ||
log '' | ||
if ret.retcode == 0 | ||
bot.save_group_info ret.result | ||
bot.update_group_member({name:"qqbot群"}) | ||
|
||
|
||
api.long_poll auth_opts, (ret,e)-> | ||
log e if e | ||
log jsons ret | ||
bot.handle_poll_responce(ret) | ||
cookies = defaults.data 'cookie' | ||
auth_info = defaults.data 'auth' | ||
|
||
|
||
bot = new QQBot(cookies,auth_info,config) | ||
group = null | ||
|
||
|
||
bot.listen_group "qqbot群" , (_group,error)-> | ||
|
||
log.info "enter long poll mode, have fun" | ||
bot.runloop() | ||
|
||
group = _group | ||
group.on_message (content ,send, robot, message)-> | ||
log.info 'received',content | ||
if content.match /^wow/ | ||
send 'mom' |