在原消息被撤回时自动撤回转发的消息
This commit is contained in:
parent
cf84683859
commit
378194db66
35
index.ts
35
index.ts
@ -94,7 +94,7 @@ async function app() {
|
||||
// 对收到的消息进行处理
|
||||
// message 本质相当于同时绑定了 FriendMessage GroupMessage TempMessage
|
||||
// 你也可以单独对某一类消息进行监听
|
||||
mirai.on('GroupMessage', async (msg) => {
|
||||
mirai.on('GroupMessage', async msg => {
|
||||
const fromGroup = msg.sender.group.id
|
||||
if (!groups.find(({ group }) => group === fromGroup)) {
|
||||
return
|
||||
@ -204,25 +204,36 @@ async function app() {
|
||||
}
|
||||
}
|
||||
finally {
|
||||
releaseMutex();
|
||||
releaseMutex()
|
||||
}
|
||||
})
|
||||
|
||||
// 调用 mirai-ts 封装的 mirai-api-http 发送指令
|
||||
/*console.log("send command help");
|
||||
const data = await mirai.api.command.send("help", []);
|
||||
console.log("帮助信息:" + data);*/
|
||||
|
||||
// 处理各种事件类型
|
||||
// 事件订阅说明(名称均与 mirai-api-http 中事件名一致)
|
||||
// https://github.com/RedBeanN/node-mirai/blob/master/event.md
|
||||
// console.log("on other event");
|
||||
// https://github.com/project-mirai/mirai-api-http/blob/master/EventType.md#群消息撤回
|
||||
mirai.on("GroupRecallEvent", ({ operator }) => {
|
||||
if (operator) {
|
||||
const text = `${operator.memberName} 撤回了一条消息,并拜托你不要再发色图了。`;
|
||||
console.log(text);
|
||||
mirai.api.sendGroupMessage(text, operator.group.id);
|
||||
mirai.on('GroupRecallEvent', async event => {
|
||||
const releaseMutex = await mutex.acquire()
|
||||
try {
|
||||
for (const group of groups) {
|
||||
if (group.group === event.group.id) {
|
||||
continue
|
||||
}
|
||||
const matched = group.stored.translate(event.messageId)
|
||||
if (!matched) {
|
||||
continue
|
||||
}
|
||||
try {
|
||||
await mirai.api.recall(matched.id)
|
||||
}
|
||||
catch (e) {
|
||||
console.warn(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
releaseMutex()
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user