UNPKG

mm_chatbot

Version:

这是超级美眉QQ+微信机器人框架,用于开发个人微信聊天、群管机器人

98 lines (90 loc) 1.92 kB
const path = require( 'path'); const Common = require("./common.js"); /** * QQ处理类 */ class QQ extends Common { /** * 构造函数 * @param {Object} config 配置参数 */ constructor(config) { super(config); /** * QQ集群 */ this.qqs = {}; } } /** * 处理微信消息 * @param {Object} msg 消息载体 */ QQ.prototype.handle = function(msg) { var type = "text"; return { type, bot: { user_id: 0, username: "", nickname: "" }, from: { user_id: 0, username: "", nickname: "", group_id: 0, group_name: "" }, to: { user_id: 0, username: "", nickname: "" }, content: msg.text(), file: msg.file } } // /** // * 应用程序处理 // */ // QQ.prototype.run = async function(e) { // // 接收到的消息 // var content = e.msg; // var type = 'text'; // if (e.message && e.message.length) { // type = e.message[0].type; // } // var cs = this.getCmdClass(content); // if (cs && cs.cmd_name) { // var from = e.sender; // from.group_id = e.group_id; // from.group_name = e.group_name; // var to = { // nickname: e.bot.nickname, // user_id: e.self_id // } // var ret = await $.app.cmd.run(e, cs, from, to, type, content); // var content = ret.tip || ret.message; // if (content) { // var msg; // if (typeof(content) == 'string') { // if (content.indexOf("<") === 0) { // msg = await $.reply.h5(content); // } else if (content.indexOf('data:') === 0) { // } else if (content.length > $.package.config.to_img_length) { // msg = await $.reply.md(content); // } else { // msg = content; // } // } else { // msg = content; // } // /** 回复 */ // await e.reply(msg, false, { // at: $.package.config.at // }) // } // } // } module.exports = QQ;