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

Function handler

plugins/imdb.ts:9–66  ·  view source on GitHub ↗
(sock: any, message: any, args: any, context: BotContext)

Source from the content-addressed store, hash-verified

7 description: 'Get detailed information about a movie or series from IMDB',
8 usage: '.imdb <movie/series title>',
9 async handler(sock: any, message: any, args: any, context: BotContext) {
10 const chatId = context.chatId || message.key.remoteJid;
11 const text = args.join(' ').trim();
12
13 if (!text) {
14 await sock.sendMessage(chatId, {
15 text: '*Please provide a movie or series title.*\nExample: `.imdb Inception`',
16 quoted: message
17 });
18 return;
19 }
20 try {
21 const res = await fetch(`https://api.popcat.xyz/imdb?q=${encodeURIComponent(text)}`);
22 if (!res.ok) throw new Error(`API request failed with status ${res.status}`);
23 const json = await res.json() as any as any;
24 const ratings = (json.ratings || [])
25 .map((r: any) => `⭐ *${r.source}:* ${r.value}`)
26 .join('\n') || 'No ratings available';
27
28 const movieInfo = `
29🎬 *${json.title || 'N/A'}* (${json.year || 'N/A'})
30🎭 *Genres:* ${json.genres || 'N/A'}
31📺 *Type:* ${json.type || 'N/A'}
32📝 *Plot:* ${json.plot || 'N/A'}
33⭐ *IMDB Rating:* ${json.rating || 'N/A'} (${json.votes || 'N/A'} votes)
34🏆 *Awards:* ${json.awards || 'N/A'}
35🎬 *Director:* ${json.director || 'N/A'}
36✍️ *Writer:* ${json.writer || 'N/A'}
37👨‍👩‍👧‍👦 *Actors:* ${json.actors || 'N/A'}
38⏱️ *Runtime:* ${json.runtime || 'N/A'}
39📅 *Released:* ${json.released || 'N/A'}
40🌐 *Country:* ${json.country || 'N/A'}
41🗣️ *Languages:* ${json.languages || 'N/A'}
42💰 *Box Office:* ${json.boxoffice || 'N/A'}
43💽 *DVD Release:* ${json.dvd || 'N/A'}
44🏢 *Production:* ${json.production || 'N/A'}
45🔗 *Website:* ${json.website || 'N/A'}
46
47*Ratings:*
48${ratings}
49 `.trim();
50 if (json.poster) {
51 await sock.sendMessage(chatId, {
52 image: { url: json.poster },
53 caption: movieInfo,
54 quoted: message
55 });
56 } else {
57 await sock.sendMessage(chatId, { text: movieInfo, quoted: message });
58 }
59 } catch(error: any) {
60 console.error('IMDB Command Error:', error);
61 await sock.sendMessage(chatId, {
62 text: '❌ Failed to fetch movie information. Please try again later.',
63 quoted: message
64 });
65 }
66 }

Callers

nothing calls this directly

Calls 1

jsonMethod · 0.80

Tested by

no test coverage detected