Skip to content
This repository has been archived by the owner on Jan 5, 2019. It is now read-only.
/ qq-bot-rebown Public archive

[DEPRECATED!] SmartQQ robot written in JavaScript, using ES7 async/await features

License

Notifications You must be signed in to change notification settings

Rocket1184/qq-bot-rebown

Repository files navigation

DEPRECATED

  • Sat 05 Jan 2019 02:02:40 PM CST

腾讯已将部分 Smart QQ 的域名指向了不可用的 IP 地址。 Smart QQ 彻底凉了。本项目即日起不再维护。

$ drill s.web2.qq.com
;; ->>HEADER<<- opcode: QUERY, rcode: NOERROR, id: 27920
;; flags: qr rd ra ; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;; s.web2.qq.com.       IN      A

;; ANSWER SECTION:
s.web2.qq.com.  579     IN      A       0.0.0.1

;; AUTHORITY SECTION:

;; ADDITIONAL SECTION:

;; Query time: 13 msec
;; EDNS: version 0; flags: ; udp: 4096
;; SERVER: 127.0.0.1
;; WHEN: Sat Jan  5 14:15:32 2019
;; MSG SIZE  rcvd: 71

qq-bot-rebown

npm version dependencies status

使用 ES7 async/await 语法编写的 Web QQ 机器人。

Features

  • 扫码登录
  • 密码登录 (powered by puppeteer
  • 使用最近一次登录过的 Cookie 自动登录
  • 记录每条收到的消息以及发送者
  • 使用 EventEmitter 管理事件(登录、消息、断线等)
  • 缩短 URL (使用 t.cn 短链接服务)
  • 对所有数据提供 .d.ts 类型定义

RouteMap

  • 发送图片或文件 (WIP)
  • 在群中 @ 群成员 (WIP)

Usage

Example

const { QQ } = require('qq-bot-rebown');

// 构造函数可以添加参数
// 详情参阅 [tsd 类型定义文件](./index.d.ts) 中 QQOptions 部分
const qq = new QQ();

// 设置 “收到消息” 事件监听
qq.on('msg', (msg) => {
    console.log(JSON.stringify(msg));
});

// 设置 “收到好友消息” 事件监听
qq.on('buddy', (msg) => {
    qq.sendBuddyMsg(msg.id, `Hello, ${msg.name}`);
});

// 不要忘记启动 :)
qq.run();

若系统支持,程序将自动打开二维码,请扫码并允许登录。

Output

v2.0.0+,密码登录
[Sat Jan 20 2018 16:17:38 GMT+0800 (CST)] INFO (-/5) 帐号密码登录
[Sat Jan 20 2018 16:17:50 GMT+0800 (CST)] INFO (-/5) 帐号密码验证成功
[Sat Jan 20 2018 16:17:50 GMT+0800 (CST)] INFO (4/5) 获取 vfwebqq 成功
[Sat Jan 20 2018 16:17:50 GMT+0800 (CST)] INFO (5/5) 获取 psessionid 和 uin 成功
[Sat Jan 20 2018 16:17:50 GMT+0800 (CST)] INFO 开始获取帐号信息及联系人列表
[Sat Jan 20 2018 16:17:50 GMT+0800 (CST)] INFO 保存 Cookie 到 /tmp/no.cookie
[Sat Jan 20 2018 16:17:54 GMT+0800 (CST)] INFO 开始接收消息...
[Sat Jan 20 2018 16:24:38 GMT+0800 (CST)] INFO [Bot601测试群.BetaChat] hello, world
{"content":"hello, world","type":"group","id":3751278540,"name":"BetaChat","groupId":2657590898,"groupName":"Bot601测试群"}
[Sat Jan 20 2018 16:24:49 GMT+0800 (CST)] INFO [BetaChat] 测试一下
{"content":"测试一下","type":"buddy","id":3751278540,"name":"BetaChat"}
[Sat Jan 20 2018 16:24:49 GMT+0800 (CST)] INFO => [BetaChat] Hello, BetaChat
v1.0.0+,二维码登录
[Tue Sep 26 2017 19:55:17 GMT+0800 (CST)] INFO (0/5) 开始登录,准备下载二维码
[Tue Sep 26 2017 19:55:18 GMT+0800 (CST)] INFO (1/5) 二维码下载到 /tmp/qq-bot-code.png ,等待扫描
[Tue Sep 26 2017 19:55:37 GMT+0800 (CST)] INFO (2/5) 二维码扫描完成
[Tue Sep 26 2017 19:55:37 GMT+0800 (CST)] INFO (3/5) 获取 ptwebqq 成功
[Tue Sep 26 2017 19:55:37 GMT+0800 (CST)] INFO (4/5) 获取 vfwebqq 成功
[Tue Sep 26 2017 19:55:37 GMT+0800 (CST)] INFO (5/5) 获取 psessionid 和 uin 成功
[Tue Sep 26 2017 19:55:37 GMT+0800 (CST)] INFO 开始获取用户信息
[Tue Sep 26 2017 19:55:37 GMT+0800 (CST)] INFO 保存 Cookie 到 /tmp/my-qq-bot.cookie
[Tue Sep 26 2017 19:55:38 GMT+0800 (CST)] INFO 开始获取好友列表
[Tue Sep 26 2017 19:55:38 GMT+0800 (CST)] INFO 开始获取好友在线状态
[Tue Sep 26 2017 19:55:38 GMT+0800 (CST)] INFO 开始获取讨论组列表
[Tue Sep 26 2017 19:55:38 GMT+0800 (CST)] INFO 开始获取群列表
[Tue Sep 26 2017 19:55:47 GMT+0800 (CST)] INFO 信息初始化完成
[Tue Sep 26 2017 19:55:47 GMT+0800 (CST)] INFO 开始接收消息...
[Tue Sep 26 2017 19:55:56 GMT+0800 (CST)] INFO [群消息] Bot测试群 : Rocka | 测试
{"content":"测试","type":"group","id":4044871627,"name":"Rocka","groupId":2164848864,"groupName":"Bot测试群"}
[Tue Sep 26 2017 19:58:47 GMT+0800 (CST)] INFO [新消息] Pugna | Hello
{"content":"Hello","type":"buddy","id":3249866953,"name":"Pugna"}
[Tue Sep 26 2017 19:58:47 GMT+0800 (CST)] INFO 发消息给好友 Pugna : Hello, Pugna

Docs

事件(Events)列表

Under construction

可先参考 tsd 类型定义文件

短链接 API

const { shortenUrl } = require('qq-bot-rebown');

shortenUrl('https://github.com').then(console.log);
// http://t.cn/RxnlTYR

shortenUrl(['https://gitlab.com', 'https://gist.github.com']).then(console.log);
// [ 'http://t.cn/RhJnX41', 'http://t.cn/amvA44' ]