mirror of
https://github.com/Jerryplusy/crystelf-plugin.git
synced 2025-07-04 14:19:19 +00:00
广播功能
This commit is contained in:
parent
823b9852a9
commit
f93261bfb2
@ -1,6 +1,7 @@
|
|||||||
import botControl from '../lib/core/botControl.js';
|
import botControl from '../lib/core/botControl.js';
|
||||||
import configControl from '../lib/config/configControl.js';
|
import configControl from '../lib/config/configControl.js';
|
||||||
import schedule from 'node-schedule';
|
import schedule from 'node-schedule';
|
||||||
|
import axios from 'axios';
|
||||||
|
|
||||||
export default class ReportBots extends plugin {
|
export default class ReportBots extends plugin {
|
||||||
constructor() {
|
constructor() {
|
||||||
@ -12,12 +13,12 @@ export default class ReportBots extends plugin {
|
|||||||
reg: '^#crystelf同步$',
|
reg: '^#crystelf同步$',
|
||||||
fnc: 'manualReport',
|
fnc: 'manualReport',
|
||||||
permission: 'master',
|
permission: 'master',
|
||||||
} /*,
|
},
|
||||||
{
|
{
|
||||||
reg: '^#crystelf广播(.+)$',
|
reg: '^#crystelf广播(.+)$',
|
||||||
fnc: 'broadcast',
|
fnc: 'broadcast',
|
||||||
permission: 'master',
|
permission: 'master',
|
||||||
},*/,
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
schedule.scheduleJob('*/30 * * * *', () => this.autoReport());
|
schedule.scheduleJob('*/30 * * * *', () => this.autoReport());
|
||||||
@ -41,4 +42,28 @@ export default class ReportBots extends plugin {
|
|||||||
e.reply('crystelf Bot同步失败:核心未连接..', true);
|
e.reply('crystelf Bot同步失败:核心未连接..', true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async broadcast(e) {
|
||||||
|
const msg = e?.msg?.match(/^#crystelf广播(.+)$/)?.[1]?.trim();
|
||||||
|
if (!msg) {
|
||||||
|
return e.reply('广播内容不能为空');
|
||||||
|
}
|
||||||
|
e.reply(`开始广播消息到所有群..`);
|
||||||
|
try {
|
||||||
|
const sendData = {
|
||||||
|
token: configControl.get('coreConfig')?.token,
|
||||||
|
message: msg.toString(),
|
||||||
|
};
|
||||||
|
const url = configControl.get('coreConfig')?.coreUrl;
|
||||||
|
const returnData = await axios.post(url, sendData);
|
||||||
|
if (returnData?.success) {
|
||||||
|
return e.reply(`操作成功:${returnData?.data.toString()}`);
|
||||||
|
} else {
|
||||||
|
return e.reply(`广播出现错误,请检查日志..`);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
logger.error(`广播执行异常: ${err.message}`);
|
||||||
|
return e.reply('广播过程中发生错误,请检查日志..');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user