refactor onebot action context modules

This commit is contained in:
DrSmoothl committed 2026-05-12 14:40:48 +08:00
1 parent 8636222d91
commit 5ce8aa60de
8 files changed
+871 -729

No files matched your search

@@ -0,0 +1,29 @@
import type { Bridge } from '../../bridge/bridge';
export async function handleGroupAddRequest(
bridge: Bridge,
flag: string,
approve: boolean,
reason: string,
): Promise<void> {
// flag format: "add:groupId:uid" or "invite:groupId:uid" (from event-converter)
const parts = flag.split(':');
if (parts.length < 3) throw new Error('invalid group request flag');
const groupId = parseInt(parts[1], 10);
if (!groupId) throw new Error('invalid group_id in flag');
const requests = await bridge.fetchGroupRequests();
const matching = requests.find(r => r.groupId === groupId);
if (!matching) {
throw new Error('matching group request not found');
}
await bridge.setGroupAddRequest(
groupId,
matching.sequence,
matching.eventType,
approve,
reason,
matching.filtered,
);
}