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

Function handler

plugins/siminfo.ts:15–67  ·  view source on GitHub ↗
(sock: any, message: any, args: any[], context: BotContext)

Source from the content-addressed store, hash-verified

13 usage: '.siminfo <phone number with country code>\nExample: .siminfo +923001234567',
14
15 async handler(sock: any, message: any, args: any[], context: BotContext) {
16 const { chatId, channelInfo } = context;
17 const input = args.join('').trim().replace(/\s+/g, '');
18
19 if (!input) {
20 return await sock.sendMessage(chatId, {
21 text: `📱 *SIM / Phone Info*\n\n` +
22 `*Usage:* \`.siminfo <number>\`\n\n` +
23 `*Examples:*\n` +
24 `• \`.siminfo +923001234567\` — Pakistan\n` +
25 `• \`.siminfo +14155552671\` — USA\n` +
26 `• \`.siminfo +447911123456\` — UK\n` +
27 `• \`.siminfo +971501234567\` — UAE\n\n` +
28 `ℹ️ Include country code with or without +`,
29 ...channelInfo
30 }, { quoted: message });
31 }
32
33 try {
34 const scriptPath = path.join(process.cwd(), 'lib', 'siminfo.py');
35 const { stdout } = await execAsync(`python3 "${scriptPath}" "${input}"`, { timeout: 10000 });
36 const data = JSON.parse(stdout.trim());
37
38 if (data.error) {
39 return await sock.sendMessage(chatId, {
40 text: `❌ ${data.error}`,
41 ...channelInfo
42 }, { quoted: message });
43 }
44
45 const validIcon = data.valid ? '✅' : '⚠️';
46 const carrierLine = data.carrier !== 'Unknown' ? `\n📶 *Carrier:* ${data.carrier}` : '';
47
48 await sock.sendMessage(chatId, {
49 text: `📱 *Phone Number Info*\n\n` +
50 `🔢 *Number:* ${data.number}\n` +
51 `${data.flag} *Country:* ${data.country}\n` +
52 `🌍 *Region:* ${data.region}\n` +
53 `🏷️ *Country Code:* ${data.country_code}\n` +
54 `📞 *National Number:* ${data.national_number}\n` +
55 `📡 *Line Type:* ${data.line_type}` +
56 `${carrierLine}\n` +
57 `${validIcon} *Valid:* ${data.valid ? 'Yes' : 'Possibly invalid (check length)'}`,
58 ...channelInfo
59 }, { quoted: message });
60
61 } catch (error: any) {
62 await sock.sendMessage(chatId, {
63 text: `❌ Lookup failed: ${error.message}`,
64 ...channelInfo
65 }, { quoted: message });
66 }
67 }
68};

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected