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

Function handler

plugins/imdb.js:7–65  ·  view source on GitHub ↗
(sock, message, args, context)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 1

jsonMethod · 0.80

Tested by

no test coverage detected