import { definePlugin, wait, type oicq } from 'kivibot' const REG = { self: /^\s*([赞超草])我\s*$/, // 不需要匹配其他词就改为 /^\s*赞我\s*$/ other: /^\s*([赞超草])[它她他]/i, // 不需要匹配其他词就改为 /^\s*赞[它她他]\s*$/ } export default definePlugin({ name: '点赞', version: '1.0.0', setup(ctx) { ctx.handle('message.group', async (e) => { const selfMatches = e.raw_message.match(REG.self) if (selfMatches) { await responseLike.call(ctx.bot, e.sender.user_id, e.group, e.seq) return } const otherMatches = e.raw_message.match(REG.other) const id = +(e.message.find((m) => m.type === 'at')?.qq ?? 0) if (otherMatches && id && !Number.isNaN(id)) { await responseLike.call(ctx.bot, id, e.group, e.seq) return } }) }, }) async function responseLike(this: oicq.Client, id: number, group: oicq.Group, seq: number) { let count = 0 try { while (true) { const isOK = await this.sendLike(id, 10) if (isOK) { count += 10 } else { break } } } catch {} if (count) { await group.setReaction(seq, '201', 1) } else { await group.setReaction(seq, '174', 1) } }