@vikiboss/oicq
v1.21.6
Published
QQ protocol
Downloads
15
Readme
oicq
QQ 协议基于 node
的实现,确保 node
版本 ≥ 12.16
协议支持:iPad
、AWatch
、APad
、APhone
、MacOS
安装
npm
npm i oicq
yarn
yarn add oicq
使用
扫码登录
使用手机 QQ 扫描二维码登录,不需要通过滑块和设备锁验证,但 token
失效时需要重新扫码。
const oicq = require('oicq');
// 配置账号并创建实例
const qq = 123456789;
const client = oicq.createClient(account);
// 监听上线事件
client.on('system.online', () => console.log('账号登录成功,已正常上线。'));
// 监听消息并回复
client.on('message', (event) => event.reply('Hello'));
// 扫码后按回车登录
const qr_login = (event) => process.stdin.once('data', this.login);
// 这里不填写密码
client.on('system.login.qrcode', qr_login);
// 完成验证后登录
client.login();
密码登录
使用明文或者 md5
加密过的密码登录,一劳永逸,但是可能首次登录需要通过滑块验证,有几率会环境异常。
const oicq = require('oicq');
// 配置账号并创建实例
const qq = 123456789;
const client = oicq.createClient(account);
// 监听上线事件
client.on('system.online', () => console.log('账号登录成功,已正常上线。'));
// 监听消息并回复
client.on('message', (event) => event.reply('Hello'));
// 滑块事件监听函数,用于输入 ticket 来通过滑块验证
const pwd_login = (event) => process.stdin.once('data', this.sliderLogin);
// 设备锁监听函数,当验证完成后,按回车确认
const dev_login = (event) => process.stdin.once('data', this.login);
// 监听登录保护对应的验证事件
client.on('system.login.slider', pwd_login);
client.on('system.login.device', dev_login);
// 完成验证后,需要填写明文密码或 md5 加密后的密码进行登录
client.login('password');
常用功能
client.sendGroupMsg(group_id, 'hello'); // 向指定群发送群聊消息
client.sendPrivateMsg(user_id, 'hello'); // 向指定好友发送私聊消息
client.deleteMsg(message_id); // 撤回指定消息 id 的消息
client.setGroupKick(group_id, uid); // 将指定群成员移出指定群
client.setGroupBan(group_id, user_id, 3600); // 禁言指定群指定人指定时间,单位是秒
感谢
此为修改版本,原项目地址:takayama-lily/oicq - master