Spaces:
Runtime error
Runtime error
File size: 1,281 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 |
const config = require('../config');
const { cmd, commands } = require('../command');
const wiki = require('wikipedia');
// Define the Wikipedia search command
cmd({
pattern: "wiki",
desc: "Search Wikipedia for information",
category: "main",
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 {
// Check if a query was provided
if (!q) {
return reply('Please provide a search query.');
}
// Fetch summary from Wikipedia
const summary = await wiki.summary(q);
// Format the reply
let replyText = `
*π Wikipedia Summary π*
π *Query*: _${q}_
π¬ *Title*: _${summary.title}_
π *Summary*: _${summary.extract}_
π *URL*: ${summary.content_urls.desktop.page}
> @ Powdered By SubZero `;
// Send the reply with the thumbnail image
await conn.sendMessage(from, { image: { url: summary.originalimage.source }, caption: replyText }, { quoted: mek });
} catch (e) {
console.log(e);
reply(`Error: ${e.message}`);
}
});
|