Spaces:
Sleeping
Sleeping
File size: 2,024 Bytes
8d8b0ad |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
const axios = require('axios');
const { cmd } = require('../command');
const config = require('../config'); // Ensure your API key is in config
cmd({
pattern: "movie",
desc: "Fetch detailed information about a movie.",
category: "utility",
react: "π¬",
filename: __filename
},
async (conn, mek, m, { from, quoted, body, isCmd, command, args, q, isGroup, sender, senderNumber, botNumber2, botNumber, pushname, isMe, isOwner, groupMetadata, groupName, participants, groupAdmins, isBotAdmins, isAdmins, reply }) => {
try {
const movieName = args.join(' ');
if (!movieName) {
return reply("π½οΈ Please provide the name of the movie.");
}
const apiUrl = `http://www.omdbapi.com/?t=${encodeURIComponent(movieName)}&apikey=${config.OMDB_API_KEY}`;
const response = await axios.get(apiUrl);
const data = response.data;
if (data.Response === "False") {
return reply("π« Movie not found.");
}
const movieInfo = `
π¬ *Movie Information* π¬
π₯ *Title:* ${data.Title}
π
*Year:* ${data.Year}
π *Rated:* ${data.Rated}
π *Released:* ${data.Released}
β³ *Runtime:* ${data.Runtime}
π *Genre:* ${data.Genre}
π¬ *Director:* ${data.Director}
βοΈ *Writer:* ${data.Writer}
π *Actors:* ${data.Actors}
π *Plot:* ${data.Plot}
π *Language:* ${data.Language}
πΊπΈ *Country:* ${data.Country}
π *Awards:* ${data.Awards}
β *IMDB Rating:* ${data.imdbRating}
π³οΈ *IMDB Votes:* ${data.imdbVotes}
`;
// Define the image URL
const imageUrl = data.Poster && data.Poster !== 'N/A' ? data.Poster : config.ALIVE_IMG;
// Send the movie information along with the poster image
await conn.sendMessage(from, {
image: { url: imageUrl },
caption: `${movieInfo}\n> Β©α΄α΄α΄‘α΄Κα΄α΄
ΚΚ sα΄Κα΄’α΄Κα΄`
}, { quoted: mek });
} catch (e) {
console.log(e);
reply(`β Error: ${e.message}`);
}
});
|