简介
CQNode是一个基于酷Q与CoolQ HTTP API 插件的Node.js的QQ机器人开发框架
复读
只需要几行代码即可实现一个简单的复读功能
class Repeat extends CQNode.Module {
onMessage(data, resp) {
return resp.reply(`收到消息: ${data.msg}`);
}
}
CQNode.createRobot({
modules: [new Repeat()],
});
定时器
简单的主动发送消息示例
class Timer extends CQNode.Module {
constructor(group) {
this.group = group;
}
onRun() {
this.minute = 0;
this.timer = setInterval(() => {
this.cqnode.api.sendGroupMsg(this.group, `模块已启动${++this.minute}分钟`);
}, 60000);
}
onStop() {
clearInterval(this.timer);
}
}
CQNode.createRobot({
modules: [new Timer(1145141919)],
});