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

Function handler

plugins/delcmd.ts:52–96  ·  view source on GitHub ↗
(sock: any, message: any, args: any, context: BotContext)

Source from the content-addressed store, hash-verified

50 ownerOnly: true,
51
52 async handler(sock: any, message: any, args: any, context: BotContext) {
53 const { chatId } = context;
54
55 let hash = args.join(' ');
56
57 if (message.message?.extendedTextMessage?.contextInfo?.quotedMessage?.stickerMessage) {
58 const fileSha256 = message.message.extendedTextMessage.contextInfo.quotedMessage.stickerMessage.fileSha256;
59 if (fileSha256) {
60 hash = Buffer.from(fileSha256).toString('base64');
61 }
62 }
63
64 if (!hash) {
65 return await sock.sendMessage(chatId, {
66 text: '✳️ Please enter the command name or reply to a sticker'
67 }, { quoted: message });
68 }
69
70 const stickers = await getStickerCommands();
71
72 // Find by text name if hash not found
73 if (!stickers[hash]) {
74 const found = Object.entries(stickers).find(([, v]: any) => v.text === hash);
75 if (found) hash = found[0];
76 }
77
78 if (stickers[hash] && stickers[hash].locked) {
79 return await sock.sendMessage(chatId, {
80 text: '✳️ You cannot delete this command'
81 }, { quoted: message });
82 }
83
84 if (!stickers[hash]) {
85 return await sock.sendMessage(chatId, {
86 text: '⚠️ Command not found'
87 }, { quoted: message });
88 }
89
90 delete stickers[hash];
91 await saveStickerCommands(stickers);
92
93 await sock.sendMessage(chatId, {
94 text: '✅ Command deleted'
95 }, { quoted: message });
96 }
97};

Callers

nothing calls this directly

Calls 2

getStickerCommandsFunction · 0.70
saveStickerCommandsFunction · 0.70

Tested by

no test coverage detected