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

Function handler

plugins/schedulelist.js:8–33  ·  view source on GitHub ↗
(sock, message, args, context)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

loadSchedulesFunction · 0.90
formatTimeLeftFunction · 0.90

Tested by

no test coverage detected