0.0.1 • Published 3 years ago
oicq-plugin-hitokoto v0.0.1
oicq-plugin-hitokoto
每日一言 才不是网抑云
npm i oicq-plugin-hitokoto
参数介绍
- hitokoto
- 参数
- bot 为机器人实例,params 可选参数,默认 '?c=a&c=b&c=c'
- 方法
- hitokoto.bind(bot)
- hitokoto.unbind(bot)
- hitokoto.get(params)
- 参数
关于 hitokoto 相关参数可访问 https://hitokoto.cn/usage
简单示例
const hitokoto = require('oicq-plugin-hitokoto');
//启用插件,bot 为 oicq 实例
hitokoto.bind(bot);
//卸载插件
hitokoto.unbind(bot);
关键字可触发,正则表达式^(来|说)(点|些|段)骚话$
若需要定时发送,可以使用 node-schedule
npm i node-schedule
进阶示例
const schedule = require('node-schedule');
const hitokoto = require('oicq-plugin-hitokoto');
// 自定义参数
const cron = '0 0 0 * *';
const params = '?c=a&c=b';
// 群或好友集合
const senders = new Map('...');
// 定时器
schedule.scheduleJob(cron, () => {
hitokoto.get(params)
.then(data => {
senders.forEach((val, key) => {
bot.sendGroupMsg(key, data);
// or
bot.sendPrivateMsg(key, data);
});
})
.catch(err => {
bot.logger.error(err.message);
})
});