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

Function handler

plugins/schedulelist.ts:11–41  ·  view source on GitHub ↗
(sock: any, message: any, args: any[], context: BotContext)

Source from the content-addressed store, hash-verified

9 usage: '.schedulelist',
10
11 async handler(sock: any, message: any, args: any[], context: BotContext) {
12 const chatId = context.chatId || message.key.remoteJid;
13 const senderId = context.senderId || message.key.remoteJid;
14 const channelInfo = context.channelInfo || {};
15
16 const schedules = await loadSchedules();
17
18 // Show schedules for this chat
19 const mine = schedules.filter(s => s.chatId === chatId || s.senderId === senderId);
20
21 if (mine.length === 0) {
22 return await sock.sendMessage(chatId, {
23 text: '📭 *No scheduled messages found*\n\nUse `.schedule <time> <message>` to schedule one!',
24 ...channelInfo
25 }, { quoted: message });
26 }
27
28 const now = Date.now();
29 const lines = mine.map((s, i) => {
30 const timeLeft = formatTimeLeft(s.sendAt - now);
31 const preview = s.message.length > 40
32 ? s.message.substring(0, 40) + '...'
33 : s.message;
34 return `${i + 1}. 📌 *ID:* ${s.id} | ⏳ ${timeLeft}\n 💬 ${preview}`;
35 }).join('\n\n');
36
37 await sock.sendMessage(chatId, {
38 text: `*⏰ SCHEDULED MESSAGES (${mine.length})*\n\n${lines}\n\n_Use .schedulecancel <ID> to cancel_`,
39 ...channelInfo
40 }, { quoted: message });
41 }
42};

Callers

nothing calls this directly

Calls 2

loadSchedulesFunction · 0.85
formatTimeLeftFunction · 0.85

Tested by

no test coverage detected