@dislido/cqnode

no description

Stats

StarsIssuesVersionUpdatedCreatedSize
@dislido/cqnode
213.0.0-beta32 years ago3 years agoMinified + gzip package size for @dislido/cqnode in KB

Readme

简介

CQNode是一个基于酷QCoolQ HTTP API 插件的Node.js的QQ机器人开发框架

安装

npm i @dislido/cqnode


示例

复读

只需要几行代码即可实现一个简单的复读功能

// repeat.js
class Repeat extends CQNode.Module {
  onMessage(data, resp) {
    return resp.reply(`收到消息: ${data.msg}`);
  }
}

// index.js
const CQNode = require('@dislido/cqnode');
CQNode.createRobot({
  modules: [{ entry: './repeat' }],
});

定时器

简单的主动发送消息示例

// timer.js
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);
  }
}

// index.js
const CQNode = require('@dislido/cqnode');
CQNode.createRobot({
  modules: [{ entry: './timer', config: { group: 114514 } }],
});

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.