MCPcopy Create free account
hub / github.com/GlobalTechInfo/MEGA-MDX / handler

Function handler

plugins/warnings.ts:35–57  ·  view source on GitHub ↗
(sock: any, message: any, args: any, context: BotContext)

Source from the content-addressed store, hash-verified

33 groupOnly: true,
34
35 async handler(sock: any, message: any, args: any, context: BotContext) {
36 const { chatId, channelInfo } = context;
37
38 const mentionedJidList = message.message?.extendedTextMessage?.contextInfo?.mentionedJid || [];
39
40 if (mentionedJidList.length === 0) {
41 await sock.sendMessage(chatId, {
42 text: 'Please mention a user to check warnings.',
43 ...channelInfo
44 }, { quoted: message });
45 return;
46 }
47
48 const userToCheck = mentionedJidList[0];
49 const warnings = await loadWarnings();
50 const warningCount = (warnings[chatId] && warnings[chatId][userToCheck]) || 0;
51
52 await sock.sendMessage(chatId, {
53 text: `@${userToCheck.split('@')[0]} has ${warningCount} warning(s).\n\nStorage: ${HAS_DB ? 'Database' : 'File System'}`,
54 mentions: [userToCheck],
55 ...channelInfo
56 }, { quoted: message });
57 }
58};
59

Callers

nothing calls this directly

Calls 1

loadWarningsFunction · 0.85

Tested by

no test coverage detected