// Import necessary modules const express = require('express'); const { sinhalaSub } = require("mrnima-moviedl"); const FormData = require('form-data'); const { catbox } = require('./catbox'); // Import the Catbox uploader const { exec } = require("child_process"); const yts = require('yt-search'); // // Initialize Express app for HTTP server const app = express(); const PORT = process.env.PORT || 3000; // Basic HTML response for health check app.get('/', (req, res) => { res.send(` Bot Status

✅ Connected to Telegram

Your bot is up and running!

`); }); // Start the HTTP server app.listen(PORT, () => { console.log(`Server is running on http://localhost:${PORT}`); }); // const TelegramBot = require('node-telegram-bot-api'); const axios = require('axios'); const fs = require('fs'); const apiKey = '7398508893:AAFqoZK_n0FNZ5I9_5L4BpyDSh3YvatZ3B8'; // Replace 'YOUR_TELEGRAM_BOT_TOKEN' with your bot token const bot = new TelegramBot('7398508893:AAFE6xOytstrMZ0PpRa3ieH6SLBy9TR9vq4', { polling: true }); // Set up a list for tracking muted users const mutedUsers = new Set(); // Anti-link feature variable let antiLinkActive = false; // Check if user is admin const isAdmin = async (chatId, userId) => { try { const member = await bot.getChatMember(chatId, userId); return member.status === 'administrator' || member.status === 'creator'; } catch (error) { return false; } }; // /tiktok command bot.onText(/\/(tiktok|tt|ttmedia)(?: (.+))?/, async (msg, match) => { const chatId = msg.chat.id; const text = match[2]; // Extract the TikTok link from the command if (!text) { // If no TikTok link is provided, send a usage guide return bot.sendMessage(chatId, "❌ Please provide a TikTok link.\nExample: `/tiktok https://www.tiktok.com/@username/video/1234567890`"); } bot.sendMessage(chatId, "🔄 Fetching your TikTok media... Please wait."); try { // Fetch TikTok media using the external API const response = await axios.get(`https://api.paxsenix.biz.id/dl/tiktok?url=${encodeURIComponent(text)}`); const data = response.data; if (data && data.downloadsUrl) { // Send the video await bot.sendVideo(chatId, data.downloadsUrl.video); // Send the audio await bot.sendAudio(chatId, data.downloadsUrl.music); } else { bot.sendMessage(chatId, "❌ Unable to fetch TikTok media. Please check the link and try again."); } } catch (error) { console.error("Error during TikTok download command:"); bot.sendMessage(chatId, "❌ An error occurred while processing your request. Please try again later."); } }); bot.onText(/\/couplepp/, async (msg) => { const chatId = msg.chat.id; try { // Inform the user that the bot is fetching the pictures await bot.sendMessage(chatId, "🔍 *Fetching couple profile pictures...*", { parse_mode: "Markdown" }); // Fetch the data from the API const apiUrl = "https://api.maskser.me/api/randomgambar/couplepp"; const response = await axios.get(apiUrl); if (response.data.status) { const { male, female } = response.data.result; // Send the male picture await bot.sendPhoto(chatId, male, { caption: "👦 *Male Picture*", parse_mode: "Markdown" }); // Send the female picture await bot.sendPhoto(chatId, female, { caption: "👧 *Female Picture*", parse_mode: "Markdown" }); } else { bot.sendMessage(chatId, "❌ Failed to fetch couple pictures. Please try again later."); } } catch (error) { console.error("Error fetching couple pictures:"); bot.sendMessage(chatId, "❌ An error occurred while fetching couple pictures. Please try again."); } }); // Handle /gpt command bot.onText(/\/gpt (.+)/, async (msg, match) => { const chatId = msg.chat.id; const query = match[1]?.trim(); if (!query) { return bot.sendMessage(chatId, "❌ Please provide a prompt after the /gpt command.\nExample: `/gpt What is AI?`", { parse_mode: "Markdown", }); } try { // Show typing indicator await bot.sendChatAction(chatId, "typing"); // Make a request to the new GPT API const apiUrl = `https://api.paxsenix.biz.id/ai/gpt4?text=${encodeURIComponent(query)}`; const { data } = await axios.get(apiUrl); // Check the API response if (!data.ok || !data.message) { return bot.sendMessage(chatId, `❌ GPT API Error: Unable to fetch a response. Please try again later.`); } // Send the GPT response to the user await bot.sendMessage(chatId, `${data.message}`, { parse_mode: "Markdown" }); } catch (error) { console.error("Error fetching GPT response:"); await bot.sendMessage(chatId, "❌ An error occurred while fetching the GPT response. Please try again later."); } }); bot.onText(/\/url/, async (msg) => { const chatId = msg.chat.id; // Check if the message is a reply to an image or video const fileId = msg.reply_to_message?.photo?.[msg.reply_to_message.photo.length - 1]?.file_id || msg.reply_to_message?.video?.file_id; if (!fileId) { return bot.sendMessage(chatId, "❗ *Reply to an image or video with /url to get a public link.*", { parse_mode: "Markdown" }); } try { // React to indicate processing const processingMsg = await bot.sendMessage(chatId, "⏳ *Uploading your file...*", { parse_mode: "Markdown" }); // Download the file locally const filePath = await bot.downloadFile(fileId, "./downloads"); // Upload the file to Catbox const uploadResponse = await catbox(filePath); // Check and send the result if (uploadResponse.url) { await bot.sendMessage(chatId, `✅ *Upload Successful!*\n\n🔗 *URL:*\n${uploadResponse.url}\n\n*ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ*`, { parse_mode: "Markdown" }); } else { await bot.sendMessage(chatId, "❌ *Upload Failed. Please try again.*", { parse_mode: "Markdown" }); } // Clean up the downloaded file fs.unlinkSync(filePath); await bot.deleteMessage(chatId, processingMsg.message_id); } catch (error) { console.error("Error in /url command:"); bot.sendMessage(chatId, `❌ *An error occurred`, { parse_mode: "Markdown" }); } }); bot.onText(/\/remini/, async (msg) => { const chatId = msg.chat.id; // Check if the message is a reply to an image const fileId = msg.reply_to_message?.photo?.[msg.reply_to_message.photo.length - 1]?.file_id; if (!fileId) { return bot.sendMessage(chatId, "❗ *Reply to an image with /remini to enhance it.*", { parse_mode: "Markdown" }); } try { // React to indicate processing const processingMsg = await bot.sendMessage(chatId, "⏳ *Enhancing your image...*", { parse_mode: "Markdown" }); // Download the image locally const filePath = await bot.downloadFile(fileId, "./downloads"); // Upload the image to Catbox const uploadResponse = await catbox(filePath); if (!uploadResponse.url) { fs.unlinkSync(filePath); // Clean up the downloaded file return bot.sendMessage(chatId, "❌ *Upload Failed. Please try again.*", { parse_mode: "Markdown" }); } const imageUrl = uploadResponse.url; // Get the uploaded image URL // Call the Remini API with the uploaded image URL const enhancedImageUrl = `https://bk9.fun/tools/enhance?url=${encodeURIComponent(imageUrl)}`; // Send the enhanced image back to the user await bot.sendPhoto(chatId, enhancedImageUrl, { caption: `✅ *Successfully Enhanced Your Image!*\n\n*ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ*`, parse_mode: "Markdown", }); // Clean up the downloaded file fs.unlinkSync(filePath); await bot.deleteMessage(chatId, processingMsg.message_id); } catch (error) { console.error("Error in /remini command:"); bot.sendMessage(chatId, `❌ *An error occurred`, { parse_mode: "Markdown" }); } }); bot.onText(/\/video (.+)/, async (msg, match) => { const chatId = msg.chat.id; const query = match[1]?.trim(); if (!query) { return bot.sendMessage(chatId, "❗ *Usage*: `/video `", { parse_mode: 'Markdown' }); } try { const searchMsg = await bot.sendMessage(chatId, "🔍 *Searching for your video...*", { parse_mode: "Markdown" }); // Step 1: Search for the video const search = await yts(query); const video = search.all[0]; // Take the first result if (!video) { return bot.sendMessage(chatId, "❌ Video not found!"); } // Step 2: Fetch video download link from the API const apiUrl = `https://apis.davidcyriltech.my.id/download/ytmp4`; const response = await axios.get(apiUrl, { params: { url: video.url } }); const { success, result } = response.data; if (success && result) { const { title, download_url } = result; const filePath = `./temp/${title.replace(/[^\w\s]/gi, '')}.mp4`; // Step 3: Download video locally const writer = fs.createWriteStream(filePath); const videoStream = await axios({ url: download_url, method: 'GET', responseType: 'stream' }); videoStream.data.pipe(writer); await new Promise((resolve, reject) => { writer.on('finish', resolve); writer.on('error', reject); }); await bot.sendVideo(chatId, download_url, { caption: `🎬 *Here is your video:*\n🎥 *${title}*\n\n*ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ*`, parse_mode: "Markdown" }); // Step 5: Delete the file after sending fs.unlinkSync(filePath); } else { bot.sendMessage(chatId, "❌ Failed to fetch the video. Please try again."); } await bot.deleteMessage(chatId, searchMsg.message_id); } catch (err) { console.error("Error in /video command:", err); bot.sendMessage(chatId, "❌ An error occurred while processing your request."); } }); // /play command bot.onText(/\/play(?: (.+))?/, async (msg, match) => { const chatId = msg.chat.id; const inputText = match[1]; if (!inputText) { return bot.sendMessage(chatId, "❌ Please provide the song name.\nExample: `/play Faded by Alan Walker`"); } try { // Notify user that the bot is searching await bot.sendMessage(chatId, "🔍 Searching for your song..."); // Perform a YouTube search const search = await yts(inputText); const video = search.all[0]; if (!video) { return bot.sendMessage(chatId, "❌ Sorry, I couldn't find the song. Try another keyword."); } // Fetch the song download link using the new API const apiUrl = `https://apis.davidcyriltech.my.id/download/ytmp3?url=${encodeURIComponent(video.url)}`; const response = await axios.get(apiUrl); const { success, result } = response.data; if (success && result) { const { title, thumbnail, download_url } = result; const filename = `./${video.title.replace(/[^a-zA-Z0-9]/g, "_")}.mp3`; // Send song details with thumbnail await bot.sendPhoto(chatId, thumbnail, { caption: `🎶 *Music Player* 🎶\n\n` + `🎵 *Title:* ${video.title}\n` + `🔗 [Watch on YouTube](${video.url})\n\n*ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ*`, parse_mode: "Markdown", }); // Download the audio file const writer = fs.createWriteStream(filename); const { data } = await axios({ url: download_url, method: "GET", responseType: "stream", }); data.pipe(writer); await new Promise((resolve, reject) => { writer.on("finish", resolve); writer.on("error", reject); }); // Send the locally saved audio file await bot.sendAudio(chatId, filename, { caption: `🎧 *Here's your song:*\n🎵 *Title:* ${video.title}\n\n*ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ*`, parse_mode: "Markdown", }); // Delete the file after sending fs.unlink(filename, (err) => { if (err) console.error("Error deleting file:", err); }); } else { bot.sendMessage(chatId, "❌ Unable to download the song. Please try again later."); } } catch (error) { console.error("Error during /play command:", error); bot.sendMessage(chatId, "❌ An error occurred while processing your request. Please try again later."); } }); bot.onText(/\/ytmp3 (.+)/, async (msg, match) => { const chatId = msg.chat.id; const youtubeLink = match[1]?.trim(); if (!youtubeLink) { return bot.sendMessage(chatId, "❗ *Usage*: `/ytmp3 `\nExample: `/ytmp3 https://youtube.com/watch?v=iI34LYmJ1Fs`", { parse_mode: 'Markdown' }); } try { const loadingMsg = await bot.sendMessage(chatId, "🔍 *Processing your audio...*", { parse_mode: "Markdown" }); // Fetch audio download link const apiUrl = `https://apis.davidcyriltech.my.id/download/ytmp3`; const response = await axios.get(apiUrl, { params: { url: youtubeLink } }); const { success, result } = response.data; if (success && result) { const { title, download_url } = result; const filename = `./temp/${Date.now()}.mp3`; // Download the audio locally const audioResponse = await axios({ url: download_url, method: "GET", responseType: "stream", }); const writer = fs.createWriteStream(filename); audioResponse.data.pipe(writer); writer.on("finish", async () => { await bot.sendAudio(chatId, download_url, { caption: `🎧 *${title}*\n\n*ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ*`, parse_mode: "Markdown" }); fs.unlinkSync(filename); // Delete after sending }); } else { bot.sendMessage(chatId, "❌ Failed to fetch the audio. Please check the link and try again."); } await bot.deleteMessage(chatId, loadingMsg.message_id); } catch (err) { console.error("Error in /ytmp3 command:", err); bot.sendMessage(chatId, "❌ An error occurred while processing your request."); } }); let chatbotActive = {}; // Stores active chatbot users let conversationIds = {}; // Stores conversation ID for each user bot.onText(/\/gitclone (.+)/, async (msg, match) => { const chatId = msg.chat.id; const repoUrl = match[1]?.trim(); if (!repoUrl) { return bot.sendMessage(chatId, "❗ *Usage*: `/gitclone `\nExample: `/gitclone https://github.com/DeeCeeXxx2/Queen_Anita-V3`", { parse_mode: 'Markdown' }); } if (!repoUrl.includes("github.com")) { return bot.sendMessage(chatId, "❌ *Invalid GitHub link! Please provide a valid URL.*"); } try { let regex = /(?:https|git)(?::\/\/|@)github\.com[\/:]([^\/:]+)\/(.+)/i; let [, user, repo] = repoUrl.match(regex) || []; repo = repo.replace(/.git$/, ""); let zipUrl = `https://api.github.com/repos/${user}/${repo}/zipball`; // Fetch file name from GitHub API let response = await fetch(zipUrl, { method: "HEAD" }); let filename = response.headers.get("content-disposition").match(/attachment; filename=(.*)/)[1]; await bot.sendDocument(chatId, zipUrl, { caption: `📦 *Repository:* ${repo}\n🔗 *Download Link:* [Click Here](${zipUrl})\n\n*ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ*`, parse_mode: "Markdown", fileName: filename + ".zip", mimetype: "application/zip" }); } catch (err) { console.error("Error in /gitclone command:", err); bot.sendMessage(chatId, "❌ *An error occurred while fetching the repository. Please try again later.*"); } }); bot.onText(/\/chatbot$/, async (msg) => { const chatId = msg.chat.id; await bot.sendMessage( chatId, "❗ *Invalid Command!*\n\nUse:\n✅ `/chatbot on` - To activate AI chat\n❌ `/chatbot off` - To deactivate AI chat", { parse_mode: "Markdown" } ); }); bot.onText(/\/mediafire (.+)/, async (msg, match) => { const chatId = msg.chat.id; const mediafireUrl = match[1]?.trim(); if (!mediafireUrl) { return bot.sendMessage(chatId, "❗ *Usage*: `/mediafire `\nExample: `/mediafire https://www.mediafire.com/file/n6tgcrktbnov1oy/Queen_Anita-V4.zip/file`", { parse_mode: 'Markdown' }); } try { const loadingMsg = await bot.sendMessage(chatId, "📥 *Fetching file details...*", { parse_mode: "Markdown" }); const apiUrl = `https://apis.davidcyriltech.my.id/mediafire?url=${encodeURIComponent(mediafireUrl)}`; const response = await axios.get(apiUrl); const { success, result } = response.data; if (success && result) { const { fileName, downloadLink } = result; const filePath = path.join(__dirname, "temp", fileName.replace(/[^\w\s]/gi, "_")); // Step 1: Download the file locally const writer = fs.createWriteStream(filePath); const fileResponse = await axios({ url: downloadLink, method: "GET", responseType: "stream", }); fileResponse.data.pipe(writer); await new Promise((resolve, reject) => { writer.on("finish", resolve); writer.on("error", reject); }); // Step 2: Send the file await bot.sendDocument(chatId, filePath, { caption: `📦 *File Name:* ${fileName}\n\n*ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ*`, parse_mode: "Markdown", }); // Step 3: Delete the file after sending fs.unlinkSync(filePath); } else { bot.sendMessage(chatId, "❌ *Failed to fetch file details! Please check the MediaFire URL and try again.*"); } await bot.deleteMessage(chatId, loadingMsg.message_id); } catch (error) { console.error("Error in /mediafire command:", error); bot.sendMessage(chatId, "❌ *An error occurred while processing your request. Please try again later.*"); } }); bot.onText(/\/ss (.+)/, async (msg, match) => { const chatId = msg.chat.id; const websiteUrl = match[1]?.trim(); if (!websiteUrl) { return bot.sendMessage(chatId, "❗ *Usage*: `/ssweb `\nExample: `/ssweb https://example.com`", { parse_mode: 'Markdown' }); } try { const loadingMsg = await bot.sendMessage(chatId, "📸 *Capturing screenshot...*", { parse_mode: "Markdown" }); const apiUrl = `https://apis.davidcyriltech.my.id/ssweb?url=${encodeURIComponent(websiteUrl)}`; await bot.sendPhoto(chatId, apiUrl, { caption: `🖼️ *Screenshot of:* ${websiteUrl}`, parse_mode: "Markdown" }); await bot.deleteMessage(chatId, loadingMsg.message_id); } catch (error) { console.error("Error in /ssweb command:", error); bot.sendMessage(chatId, "❌ *Failed to capture the screenshot. Please try again later.*"); } }); bot.onText(/\/ytmp4 (.+)/, async (msg, match) => { const chatId = msg.chat.id; const youtubeLink = match[1]?.trim(); if (!youtubeLink) { return bot.sendMessage(chatId, "❗ *Usage*: `/ytmp4 `\nExample: `/ytmp4 https://youtube.com/watch?v=iI34LYmJ1Fs`", { parse_mode: 'Markdown' }); } try { const loadingMsg = await bot.sendMessage(chatId, "🔍 *Processing your video...*", { parse_mode: "Markdown" }); // Fetch video download link const apiUrl = `https://apis.davidcyriltech.my.id/download/ytmp4`; const response = await axios.get(apiUrl, { params: { url: youtubeLink } }); const { success, result } = response.data; if (success && result) { const { title, download_url } = result; const filename = `./temp/${Date.now()}.mp4`; // Download the video locally const videoResponse = await axios({ url: download_url, method: "GET", responseType: "stream", }); const writer = fs.createWriteStream(filename); videoResponse.data.pipe(writer); writer.on("finish", async () => { await bot.sendVideo(chatId, download_url, { caption: `🎬 *${title}*\n\n*ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ*`, parse_mode: "Markdown" }); fs.unlinkSync(filename); // Delete after sending }); } else { bot.sendMessage(chatId, "❌ Failed to fetch the video. Please check the link and try again."); } await bot.deleteMessage(chatId, loadingMsg.message_id); } catch (err) { console.error("Error in /ytmp4 command:", err); bot.sendMessage(chatId, "❌ An error occurred while processing your request."); } }); const path = require("path"); // Utility: Validate and fetch direct PixelDrain link async function getDirectPixelDrainLink(fileUrl) { try { const response = await axios.get(fileUrl, { maxRedirects: 0, validateStatus: (status) => status < 400 }); return response.headers.location || fileUrl; // Return direct link } catch (error) { console.error("Error validating PixelDrain link:"); throw new Error("Invalid or inaccessible PixelDrain link."); } } // Utility: Download file from PixelDrain and save it locally async function downloadFile(fileUrl, downloadPath) { try { const response = await axios({ url: fileUrl, method: "GET", responseType: "stream", }); const writer = fs.createWriteStream(downloadPath); response.data.pipe(writer); return new Promise((resolve, reject) => { writer.on("finish", () => { console.log(`File downloaded to: ${downloadPath}`); resolve(); }); writer.on("error", (err) => { console.error("Download error:"); reject(err); }); }); } catch (error) { console.error("Error downloading file:", ); throw new Error("Failed to download file."); } } // Utility: Stream file directly to Telegram async function streamFileToTelegram(chatId, filePath, caption) { try { await bot.sendDocument(chatId, filePath, { caption: caption }); console.log("File streamed successfully to Telegram."); } catch (error) { console.error("Error streaming file:"); throw new Error("Failed to stream file to Telegram."); } } bot.onText(/\/bible (.+)/, async (msg, match) => { const chatId = msg.chat.id; const chapterInput = match[1]?.trim(); if (!chapterInput) { return bot.sendMessage( chatId, "❗ *Usage*: `/bible `\nExample: `/bible john 3:16`", { parse_mode: "Markdown" } ); } const BASE_URL = "https://bible-api.com"; try { // Fetch the chapter data from the Bible API const response = await axios.get(`${BASE_URL}/${encodeURIComponent(chapterInput)}`); if (!response.data) { throw new Error("Failed to fetch the Bible chapter. Please check the input and try again."); } const chapterData = response.data; // Format the Bible chapter message const bibleChapter = ` 📖 *The Holy Bible*\n 📜 *Chapter:* ${chapterData.reference}\n 📚 *Translation:* ${chapterData.translation_name}\n 📖 *Number of Verses:* ${chapterData.verses.length}\n 🔮 *Chapter Content:*\n${chapterData.text} `; // Send the formatted message with an image await bot.sendPhoto(chatId, "./atomic.jpg", { caption: bibleChapter, parse_mode: "Markdown", }); } catch (error) { console.error("Error in /bible command:"); bot.sendMessage(chatId, `❌ Error: `); } }); bot.onText(/\/text2image (.+)/, async (msg, match) => { const chatId = msg.chat.id; const prompt = match[1]; // Extract the prompt from the command // Check if the user provided a prompt if (!prompt) { return bot.sendMessage(chatId, "❌ *Please provide a prompt!* \n\nUsage: `/magicstudio `", { parse_mode: "Markdown" }); } try { // Inform the user the process has started await bot.sendMessage(chatId, "✨ *Generating image... Please wait!*", { parse_mode: "Markdown" }); // API URL to generate the image const apiUrl = `https://bk9.fun/ai/magicstudio?prompt=${encodeURIComponent(prompt)}`; // Fetch the generated image from the API const response = await axios.get(apiUrl, { responseType: "stream" }); // Send the image back to the user await bot.sendPhoto(chatId, response.data, { caption: `🖼️ *Here's your generated image for:* \`${prompt}\`\n\n*ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ*`, parse_mode: "Markdown" }); } catch (error) { console.error("Error generating image:"); bot.sendMessage(chatId, "❌ *Failed to generate the image. Please try again later!*", { parse_mode: "Markdown" }); } }); // /apk command bot.onText(/\/apk (.+)/, async (msg, match) => { const chatId = msg.chat.id; const packageName = match[1]?.trim(); if (!packageName) { return bot.sendMessage(chatId, "❗ *Usage*: `/apk `\nExample: `/apk com.whatsapp`", { parse_mode: "Markdown" }); } try { // Step 1: Fetch APK details from the API const apiUrl = `https://bk9.fun/download/apk?id=${encodeURIComponent(packageName)}`; const response = await axios.get(apiUrl); const { status, BK9 } = response.data; if (!status || !BK9) { return bot.sendMessage(chatId, "❌ APK details not found. Please check the package name and try again."); } // Step 2: Prepare APK details message const apkDetails = `📱 *APK Details*\n\n` + `*Name:* ${BK9.name}\n` + `*Last Updated:* ${BK9.lastup}\n` + `*Package:* \`${BK9.package}\`\n\n` + `\n\n*ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ*`; const downloadLink = BK9.dllink; // Step 3: Create Inline Keyboard Button for download link const inlineKeyboard = [ [ { text: "📥 Download APK", url: downloadLink, }, ], ]; const options = { reply_markup: { inline_keyboard: inlineKeyboard, }, parse_mode: "Markdown", }; // Step 4: Send APK details with the download button await bot.sendPhoto(chatId, BK9.icon, { caption: apkDetails, ...options, }); } catch (error) { console.error("Error fetching APK details:"); await bot.sendMessage(chatId, "❌ An error occurred while fetching APK details. Please try again."); } }); // /movie command bot.onText(/\/movie (.+)/, async (msg, match) => { const chatId = msg.chat.id; const query = match[1]?.trim(); if (!query) { return bot.sendMessage(chatId, "❌ *Please provide a search query!*\nExample: `/movie Deadpool`", { parse_mode: "Markdown" }); } try { // Step 1: Search SinhalaSub for movies const sinhala = await sinhalaSub(); const results = await sinhala.search(query); const movies = results.result.slice(0, 10); // Limit results to 10 if (!movies.length) { return bot.sendMessage(chatId, `❌ No results found for: *${query}*`, { parse_mode: "Markdown" }); } // Step 2: Create Inline Keyboard Buttons for movies const inlineKeyboard = movies.map((movie, index) => [ { text: `${index + 1}. ${movie.title}`, callback_data: `movie_${index}`, // Unique identifier for each movie }, ]); const options = { reply_markup: { inline_keyboard: inlineKeyboard, }, parse_mode: "Markdown", }; await bot.sendMessage(chatId, `📽️ *Search Results for:* \`${query}\`\n\nSelect a movie from the list:`, options); // Step 3: Handle movie selection bot.on("callback_query", async (callbackQuery) => { const { data, message } = callbackQuery; // Check if the callback is for this movie selection if (data.startsWith("movie_")) { const selectedIndex = parseInt(data.split("_")[1], 10); const selectedMovie = movies[selectedIndex]; const apiUrl = `https://api-site-2.vercel.app/api/sinhalasub/movie?url=${encodeURIComponent(selectedMovie.link)}`; try { // Step 4: Fetch download links const { data: movieData } = await axios.get(apiUrl); const movieDetails = movieData.result; const downloadLinks = movieDetails.dl_links || []; if (!downloadLinks.length) { return bot.sendMessage(chatId, "❌ No PixelDrain links found for this movie."); } // Step 5: Create Inline Keyboard Buttons for direct download links const qualityKeyboard = downloadLinks.map((link) => { const pixelDrainId = link.link.split("/").pop(); // Extract the file ID const directDownloadLink = `https://pixeldrain.com/api/file/${pixelDrainId}?download`; // Use /download endpoint return [ { text: `${link.quality} - ${link.size}`, url: directDownloadLink, // Direct download link }, ]; }); const qualityOptions = { reply_markup: { inline_keyboard: qualityKeyboard, }, parse_mode: "Markdown", }; await bot.sendMessage( chatId, `🎥 *Available Qualities for:* \`${movieDetails.title}\`\n\nSelect a quality to download directly:\n\n*ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ*`, qualityOptions ); // Acknowledge the callback to avoid timeout errors bot.answerCallbackQuery(callbackQuery.id); } catch (error) { console.error("Error fetching movie details:"); await bot.sendMessage(chatId, "❌ Failed to fetch movie details. Please try again."); } } }); } catch (error) { console.error("Error executing /movie command:"); await bot.sendMessage(chatId, "❌ An error occurred while processing your request."); } }); bot.onText(/\/shazam/, async (msg) => { const chatId = msg.chat.id; // Ensure the command is a reply to an audio or video message const fileId = msg.reply_to_message?.audio?.file_id || msg.reply_to_message?.video?.file_id; if (!fileId) { return bot.sendMessage(chatId, "❌ Please reply to an audio or video file with /shazam to identify it."); } try { // Notify the user that the bot is processing the file const processingMsg = await bot.sendMessage(chatId, "🎵 Identifying the audio... Please wait!"); // Download the file locally const filePath = await bot.downloadFile(fileId, "./downloads"); // Upload the file to Catbox const uploadResponse = await catbox(filePath); if (!uploadResponse.url) { throw new Error("Failed to upload the file for analysis."); } // Call Shazam API const shazamApiUrl = `https://api.paxsenix.biz.id/tools/shazam?url=${encodeURIComponent(uploadResponse.url)}`; const shazamResponse = await axios.get(shazamApiUrl); const shazamResult = shazamResponse.data; // Handle Shazam API response if (shazamResult?.ok && shazamResult?.track) { const { title, artist, url } = shazamResult.track; const resultMessage = `🎶 *Audio Identified:*\n\n` + `🎵 *Title:* ${title}\n` + `🎤 *Artist:* ${artist}\n` + `[🔗 Listen on Shazam](${url})\n\n` + `*ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ*`; await bot.sendMessage(chatId, resultMessage, { parse_mode: "Markdown" }); } else { bot.sendMessage(chatId, "❌ Unable to identify the audio. Please try again with a different file."); } // Cleanup local file fs.unlinkSync(filePath); await bot.deleteMessage(chatId, processingMsg.message_id); } catch (error) { console.error("Error in /shazam command:"); bot.sendMessage(chatId, "⚠️ An error occurred while processing your request. Please try again later."); } }); bot.onText(/\/(image|img)(?: (.+))?/, async (msg, match) => { const chatId = msg.chat.id; const query = match[2]; // Extract the search query from the command if (!query) { return bot.sendMessage( chatId, "❌ Please provide a search query.\n\n*Usage:* `/image `\n*Example:* `/image cats`", { parse_mode: "Markdown" } ); } bot.sendMessage(chatId, "🔍 Searching for images... Please wait."); try { // Call the Bing Image Search API const apiResponse = await axios.get(`https://api.siputzx.my.id/api/s/bimg`, { params: { query: query } }); if (apiResponse.status === 200 && apiResponse.data.status) { const images = apiResponse.data.data; if (!images || images.length === 0) { return bot.sendMessage(chatId, `❌ No images found for "${query}". Please try another query.`); } // Limit to max 5 images const maxImages = Math.min(images.length, 5); for (let i = 0; i < maxImages; i++) { await bot.sendPhoto(chatId, images[i], { caption: `🔎 *Image Search Result:*\n\n📄 *Query:* "${query}"\n📷 *Image ${i + 1}/${maxImages}*\n\n*ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ*`, parse_mode: "Markdown" }); } } else { bot.sendMessage(chatId, "❌ Failed to fetch images. Please try again later."); } } catch (error) { console.error("Error in /imagesearch command:"); bot.sendMessage( chatId, `⚠️ An error occurred:\n\n*Message:*`, { parse_mode: "Markdown" } ); } }); bot.onText(/\/(spotifysearch)(?: (.+))?/, async (msg, match) => { const chatId = msg.chat.id; const query = match[2]; // Extract the search query from the command if (!query) { return bot.sendMessage( chatId, "❌ Please provide a search query.\n\n*Usage:* `/spotifysearch `\n*Example:* `/spotifysearch Spectre`", { parse_mode: "Markdown" } ); } bot.sendMessage(chatId, "🔍 Searching for tracks on Spotify... Please wait."); try { // Call the Spotify Search API const apiResponse = await axios.get(`https://api.giftedtech.my.id/api/search/spotifysearch`, { params: { apikey: "gifted-md", query: query } }); if (apiResponse.status === 200 && apiResponse.data.success) { const tracks = apiResponse.data.results; if (!tracks || tracks.length === 0) { return bot.sendMessage(chatId, `❌ No tracks found for "${query}". Please try another query.`); } // Limit to max 5 tracks const maxTracks = Math.min(tracks.length, 5); let message = `🎧 *Spotify Search Results:*\n\n`; tracks.slice(0, maxTracks).forEach((track, index) => { message += `🎵 *${index + 1}. ${track.title}*\n` + `👤 *Artist:* ${track.artist}\n` + `⏱️ *Duration:* ${track.duration}\n` + `🔗 [Listen on Spotify](${track.url})\n\n`; }); bot.sendMessage(chatId, message, { parse_mode: "Markdown" }); } else { bot.sendMessage(chatId, "❌ Failed to fetch tracks. Please try again later."); } } catch (error) { console.error("Error in /spotifysearch command:"); bot.sendMessage( chatId, `⚠️ An error occurred:\n\n*Message:*`, { parse_mode: "Markdown" } ); } }); bot.onText(/\/(spotify-download|spotdl)(?: (.+))?/, async (msg, match) => { const chatId = msg.chat.id; const spotifyUrl = match[2]; // Extract the Spotify track URL from the command if (!spotifyUrl) { return bot.sendMessage( chatId, "❌ Please provide a Spotify track URL.\n\n*Usage:* `/spotify-download `\n*Example:* `/spotify-download https://open.spotify.com/track/2DGa7iaidT5s0qnINlwMjJ`", { parse_mode: "Markdown" } ); } bot.sendMessage(chatId, "🔄 Fetching your Spotify track... Please wait."); try { // Call the Spotify Download API const apiResponse = await axios.get(`https://api.giftedtech.my.id/api/download/spotifydl`, { params: { apikey: "gifted-md", url: spotifyUrl } }); if (apiResponse.status === 200 && apiResponse.data.success) { const track = apiResponse.data.result; const caption = `🎵 *Spotify Track Downloaded:*\n\n` + `🔹 *Title:* ${track.title}\n` + `⏱️ *Duration:* ${track.duration}\n` + `🎧 *Quality:* ${track.quality}`; // Send the audio file to the user await bot.sendAudio(chatId, track.download_url, { caption: caption, parse_mode: "Markdown", thumb: track.thumbnail, // Optional: Thumbnail as album art }); } else { bot.sendMessage(chatId, "❌ Failed to fetch track details. Please check the Spotify URL and try again."); } } catch (error) { console.error("Error in /spotify-download command:"); bot.sendMessage( chatId, `⚠️ An error occurred:\n\n*Message:*`, { parse_mode: "Markdown" } ); } }); bot.onText(/\/(song)(?: (.+))?/, async (msg, match) => { const chatId = msg.chat.id; const query = match[2]; // Extract the search query from the command if (!query) { return bot.sendMessage( chatId, "❌ Please provide a search query.\n\n*Usage:* `/song `\n*Example:* `/song faded`", { parse_mode: "Markdown" } ); } bot.sendMessage(chatId, "🔍 Searching for songs on Spotify... Please wait."); try { // Call the Spotify Search API const searchResponse = await axios.get(`https://api.giftedtech.my.id/api/search/spotifysearch`, { params: { apikey: "gifted", query: query } }); if (searchResponse.status === 200 && searchResponse.data.success && searchResponse.data.results.length > 0) { const results = searchResponse.data.results; // Create inline keyboard buttons for the search results const buttons = results.slice(0, 10).map((item) => [ { text: `${item.title} - ${item.artist}`, callback_data: `song_${item.id}` } ]); bot.sendMessage(chatId, "🎶 Select a song to download:", { reply_markup: { inline_keyboard: buttons } }); } else { bot.sendMessage(chatId, "❌ No songs found. Please try a different query."); } } catch (error) { console.error("Error in /song command:"); bot.sendMessage(chatId, `⚠️ An error occurred:\n\n*Message:*`, { parse_mode: "Markdown" }); } }); // Handle button clicks for song selection bot.on("callback_query", async (callbackQuery) => { const chatId = callbackQuery.message.chat.id; const data = callbackQuery.data; if (data.startsWith("song_")) { const trackId = data.split("_")[1]; bot.sendMessage(chatId, "🔄 Downloading your song... Please wait."); try { // Call the Spotify Download API const downloadResponse = await axios.get(`https://api.giftedtech.my.id/api/download/spotifydl`, { params: { apikey: "gifted", url: `https://open.spotify.com/track/${trackId}` } }); if (downloadResponse.status === 200 && downloadResponse.data.success) { const track = downloadResponse.data.result; // Send the audio file await bot.sendAudio(chatId, track.download_url, { caption: `🔹 *Title:* ${track.title}\n` + `⏱️ *Duration:* ${track.duration}\n` + `🎧 *Quality:* ${track.quality}\n\n*ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ*`, parse_mode: "Markdown", thumb: track.thumbnail // Optional: Thumbnail as album art }); } else { bot.sendMessage(chatId, "❌ Failed to download the song. Please try again."); } } catch (error) { console.error("Error during song download:"); bot.sendMessage(chatId, `⚠️ An error occurred:\n\n*Message:*`, { parse_mode: "Markdown" }); } } }); // /facebook command bot.onText(/\/(facebook|fb|fbdl|fbdownload)(?: (.+))?/, async (msg, match) => { const chatId = msg.chat.id; const text = match[2]; // Extract the Facebook video link from the command // Guide if no link is provided if (!text) { return bot.sendMessage(chatId, "❌ Please provide a Facebook video link.\nExample: `/fb https://www.facebook.com/reel/1256751708994400?mibextid=rS40aB7S9Ucbxw6v`"); } // Notify user of processing bot.sendMessage(chatId, "🔄 Fetching your Facebook video... Please wait."); try { // Fetch video data using the new API const apiResponse = await axios.get('https://bk9.fun/download/fb', { params: { url: text }, }); const responseData = apiResponse.data; // Check if the API response is valid if (responseData.status && responseData.BK9) { const videoData = responseData.BK9; const hdLink = videoData.hd || videoData.sd; // Use HD link if available, fallback to SD const videoTitle = videoData.title || "Facebook Video"; // Send the video file directly await bot.sendVideo(chatId, hdLink, { caption: `ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ`, parse_mode: 'Markdown', }); } else { bot.sendMessage(chatId, "❌ Failed to fetch the video. Please check the link and try again."); } } catch (error) { console.error("Error in Facebook Downloader:"); bot.sendMessage(chatId, "❌ An error occurred while processing your request. Please try again later."); } }); // Temporary storage for mapping callback data to URLs const twitterDownloadLinks = new Map(); bot.onText(/\/twitter (.+)/, async (msg, match) => { const chatId = msg.chat.id; const twitterUrl = match[1]?.trim(); // Validate input if (!twitterUrl || !twitterUrl.startsWith("http")) { return bot.sendMessage(chatId, "❌ Please provide a valid Twitter link.\nExample: `/twitter https://x.com/elonmusk/status/1870904082564555012`"); } // Notify user of processing bot.sendMessage(chatId, "🔄 Fetching Twitter media... Please wait."); try { // Fetch data from the API const apiUrl = `https://api.paxsenix.biz.id/dl/twitter?url=${encodeURIComponent(twitterUrl)}`; const response = await axios.get(apiUrl); const data = response.data; // Check if API returned valid data if (!data.ok) { return bot.sendMessage(chatId, "❌ Failed to fetch Twitter media. Please check the link and try again."); } // Generate unique identifiers for the buttons const uniqueIdHD = `HD_${Date.now()}`; const uniqueIdSD = `SD_${Date.now()}`; const uniqueIdAudio = `Audio_${Date.now()}`; // Store URLs in the mapping if (data.HD) twitterDownloadLinks.set(uniqueIdHD, data.HD); if (data.SD) twitterDownloadLinks.set(uniqueIdSD, data.SD); if (data.audio) twitterDownloadLinks.set(uniqueIdAudio, data.audio); // Inline keyboard for video quality selection const inlineKeyboard = []; if (data.HD) inlineKeyboard.push([{ text: "HD Video", callback_data: uniqueIdHD }]); if (data.SD) inlineKeyboard.push([{ text: "SD Video", callback_data: uniqueIdSD }]); if (data.audio) inlineKeyboard.push([{ text: "Audio Only", callback_data: uniqueIdAudio }]); // Send preview with inline buttons await bot.sendPhoto(chatId, data.thumb, { caption: `🌟 *ATOMIC TWITTER DOWNLOADER!*\n\n🎉 *ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ*\n\nSelect the desired quality below:`, parse_mode: "Markdown", reply_markup: { inline_keyboard: inlineKeyboard, }, }); } catch (error) { console.error("Error in Twitter Downloader:"); bot.sendMessage(chatId, "❌ An error occurred while processing your request. Please try again later."); } }); // Handle callback queries for Twitter downloads bot.on("callback_query", async (callbackQuery) => { const chatId = callbackQuery.message.chat.id; const data = callbackQuery.data; // Check if the callback data exists in the mapping const url = twitterDownloadLinks.get(data); if (url) { // Notify user that the download is in progress await bot.sendMessage(chatId, "📥 Downloading your media..."); try { // Determine the type based on the callback data if (data.startsWith("HD") || data.startsWith("SD")) { await bot.sendVideo(chatId, url, { caption: `🎬ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ` }); } else if (data.startsWith("Audio")) { await bot.sendAudio(chatId, url, { caption: "🎵 ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ!" }); } // Remove the mapping after successful download twitterDownloadLinks.delete(data); } catch (error) { console.error(`Error sending media:`); await bot.sendMessage(chatId, "❌ Failed to send the requested media. Please try again later."); } } else { bot.sendMessage(chatId, ""); } // Acknowledge the callback query to avoid timeout bot.answerCallbackQuery(callbackQuery.id); }); // /instagram command bot.onText(/\/(instagram|ig|igvideo|igimage|igdownload|instadl)(?: (.+))?/, async (msg, match) => { const chatId = msg.chat.id; const text = match[2]; // Extract the Instagram URL from the command // Guide if no link is provided if (!text || !text.startsWith('http')) { return bot.sendMessage(chatId, "❌ Please provide a valid Instagram link.\nExample: `/instagram https://www.instagram.com/reel/DDgvfkAuBMI/`"); } // Notify user of processing bot.sendMessage(chatId, "🔄 Fetching your Instagram media... Please wait."); try { // Fetch Instagram media data using the API const apiResponse = await axios.get('https://api.paxsenix.biz.id/dl/ig', { params: { url: text }, }); const responseData = apiResponse.data; // Check if the API response is valid if (responseData.ok && responseData.url && responseData.url.length > 0) { const media = responseData.url[0]; // Assume the first item is the main media const mediaUrl = media.url; const mediaType = media.type || "video"; // Default to video if (mediaType === "video") { // Send the video await bot.sendVideo(chatId, mediaUrl, { caption: `*ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ*`, parse_mode: "Markdown", }); } else { // Send the image await bot.sendPhoto(chatId, mediaUrl, { caption: `*ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ*`, parse_mode: "Markdown", }); } } else { bot.sendMessage(chatId, "❌ Failed to fetch media. Please check the link and try again."); } } catch (error) { console.error("Error in Instagram Downloader:"); bot.sendMessage(chatId, "❌ An error occurred while processing your request. Please try again later."); } }); // Anti-link command // Anti-link toggle commands (Admins only) bot.onText(/\/antilink (on|off)/, async (msg, match) => { const chatId = msg.chat.id; const userId = msg.from.id; const action = match[1]; // Check if the user is an admin if (await isAdmin(chatId, userId)) { if (action === 'on') { antiLinkActive = true; bot.sendMessage(chatId, "Anti-link is now activated!"); } else if (action === 'off') { antiLinkActive = false; bot.sendMessage(chatId, "Anti-link is now deactivated!"); } } else { bot.sendMessage(chatId, "You don't have permission to use this command."); } }); bot.onText(/\/xvideodownload (.+)?/, async (msg, match) => { const chatId = msg.chat.id; const input = match[1]?.trim(); // Get the user-provided URL (if any) // Check for the last stored video URL or input const url = input || (global.db?.data?.users?.[msg.from.id]?.lastVideoUrl); if (!url) { return bot.sendMessage(chatId, "❌ *No video URL found!*\nPlease provide a valid video link or use `/videosearch` first.", { parse_mode: "Markdown", }); } try { // Step 1: Call the video download API const apiUrl = `https://api.agatz.xyz/api/xvideodown?url=${encodeURIComponent(url)}`; const response = await axios.get(apiUrl); const result = response.data; // Step 2: Check if the API returned a valid response if (result.status === 200 && result.data?.url) { const videoStreamUrl = result.data.url; // Step 3: Download the video content const videoResponse = await axios({ url: videoStreamUrl, method: 'GET', responseType: 'stream', }); // Step 4: Send the video to the user const videoInfo = result.data; const body = `🎥 *Video Details:*\n\n` + `🔤 *Title:* ${videoInfo.title}\n` + `👀 *Views:* ${videoInfo.views}\n` + `👍 *Likes:* ${videoInfo.like_count}\n` + `👎 *Dislikes:* ${videoInfo.dislike_count}\n` + `⭐ *Votes:* ${videoInfo.vote}\n` + `🔗 *Source:* [Watch Original Video](${url})\n\n` + `*ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ™*`; await bot.sendMessage(chatId, body, { parse_mode: "Markdown" }); bot.sendVideo(chatId, videoResponse.data, { caption: `*ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ*`, parse_mode: "Markdown", }); } else { bot.sendMessage(chatId, "❌ Failed to fetch the video. Please try again later."); } } catch (error) { console.error("Video Download Error:"); bot.sendMessage(chatId, "❌ An error occurred while downloading the video. Please try again."); } }); bot.onText(/\/videodownload (.+)?/, async (msg, match) => { const chatId = msg.chat.id; const input = match[1]?.trim(); // Get the user-provided URL (if any) // Check for the last stored video URL or input const url = input || (global.db?.data?.users?.[msg.from.id]?.lastVideoUrl); if (!url) { return bot.sendMessage(chatId, "❌ *No video URL found!*\nPlease provide a valid video link or use `/xvideosearch` first.", { parse_mode: "Markdown", }); } try { // Step 1: Call the video download API const apiUrl = `https://api.agatz.xyz/api/xvideodown?url=${encodeURIComponent(url)}`; const response = await axios.get(apiUrl); const result = response.data; // Step 2: Check if the API returned a valid response if (result.status === 200 && result.data?.url) { const videoInfo = result.data; const videoUrl = videoInfo.url; // Step 3: Prepare the video details for the user const body = `🎥 *Video Details:*\n\n` + `🔤 *Title:* ${videoInfo.title}\n` + `👀 *Views:* ${videoInfo.views}\n` + `👍 *Likes:* ${videoInfo.like_count}\n` + `👎 *Dislikes:* ${videoInfo.dislike_count}\n` + `⭐ *Votes:* ${videoInfo.vote}\n` + `🔗 *URL:* [Watch Original Video](${url})\n\n` + `*ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ*`; // Step 4: Send the video thumbnail and downloadable video to the user await bot.sendPhoto(chatId, videoInfo.thumb, { caption: body, parse_mode: "Markdown", }); await bot.sendVideo(chatId, videoUrl, { caption: `*ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ*`, parse_mode: "Markdown", }); } else { bot.sendMessage(chatId, "❌ Failed to fetch the video. Please try again later."); } } catch (error) { console.error("Video Download Error:"); bot.sendMessage(chatId, "❌ An error occurred while downloading the video. Please try again."); } }); const { randomUUID } = require("crypto"); // /text2speech command bot.onText(/\/text2speech (.+)/, async (msg, match) => { const chatId = msg.chat.id; const input = match[1].trim(); if (!input) { return bot.sendMessage(chatId, "❌ *Please provide text to convert to speech!*\nExample: `/text2speech Hello world | en`", { parse_mode: "Markdown", }); } try { // Split input into text and optional language code const [text, lang] = input.split("|").map((item) => item.trim()); const language = lang || "en"; // Default to 'en' if no language provided if (!text) { return bot.sendMessage(chatId, "❌ *Please provide valid text for the speech conversion.*", { parse_mode: "Markdown", }); } const encodedText = encodeURIComponent(text); const apiUrl = `https://bk9.fun/tools/tts?q=${encodedText}&lang=${language}`; // Step 1: Fetch the audio file const response = await axios({ method: "GET", url: apiUrl, responseType: "stream", }); // Generate a random filename for the audio const fileName = `${randomUUID()}.mp3`; const filePath = `./${fileName}`; // Step 2: Save the audio stream to a file const writer = fs.createWriteStream(filePath); response.data.pipe(writer); writer.on("finish", async () => { try { // Step 3: Send the audio file to the user await bot.sendAudio(chatId, filePath, { caption: `🎙️ *Text-to-Speech Result*\n🌐 *Language:* ${language.toUpperCase()}`, parse_mode: "Markdown", }); // Cleanup: Delete the temporary file fs.unlinkSync(filePath); console.log(`Temporary file ${fileName} deleted successfully.`); } catch (sendError) { console.error("Error sending TTS file:"); bot.sendMessage(chatId, "❌ Failed to send the generated audio file."); if (fs.existsSync(filePath)) fs.unlinkSync(filePath); // Ensure cleanup } }); writer.on("error", (error) => { console.error("Error saving TTS file:"); bot.sendMessage(chatId, "❌ Failed to generate or send the audio."); }); } catch (error) { console.error("TTS Error:"); bot.sendMessage(chatId, "❌ An error occurred while generating speech. Please try again."); } }); // /dog command bot.onText(/\/dog/, async (msg) => { const chatId = msg.chat.id; try { const response = await axios.get('https://dog.ceo/api/breeds/image/random'); const dogUrl = response.data.message; bot.sendPhoto(chatId, dogUrl); } catch (error) { bot.sendMessage(chatId, 'Could not fetch a dog picture at the moment. Please try again later.'); } }); // Function to get currency conversion rate from ExchangeRate-API async function getCurrencyConversion(amount, fromCurrency, toCurrency) { try { // Request currency conversion data from ExchangeRate-API const response = await axios.get(`https://v6.exchangerate-api.com/v6/${apiKey}/latest/${fromCurrency}`); const rates = response.data.conversion_rates; const conversionRate = rates[toCurrency]; if (conversionRate) { const convertedAmount = (amount * conversionRate).toFixed(2); return `${amount} ${fromCurrency} = ${convertedAmount} ${toCurrency}`; } else { return `Sorry, I couldn't find the conversion rate for ${toCurrency}.`; } } catch (error) { console.error('Error fetching currency conversion:'); return 'Oops! Something went wrong. Please try again later.'; } } // Command handler for /currency bot.onText(/\/currency (\d+\.?\d*) (\w+) to (\w+)/, async (msg, match) => { const chatId = msg.chat.id; const amount = parseFloat(match[1]); const fromCurrency = match[2].toUpperCase(); const toCurrency = match[3].toUpperCase(); // Validate the amount if (isNaN(amount) || amount <= 0) { bot.sendMessage(chatId, 'Please provide a valid amount to convert. Example: /currency 100 USD to EUR'); return; } const conversionResult = await getCurrencyConversion(amount, fromCurrency, toCurrency); bot.sendMessage(chatId, conversionResult); }); // Flag to indicate when an admin has issued /setgrouppic let awaitingGroupPic = new Map(); // /setgrouppic command (admins only) bot.onText(/\/setgrouppic/, async (msg) => { const chatId = msg.chat.id; const userId = msg.from.id; if (msg.chat.type !== 'group' && msg.chat.type !== 'supergroup') { bot.sendMessage(chatId, 'This command can only be used in group chats.'); return; } // Check if the user is an admin if (await isAdmin(chatId, userId)) { bot.sendMessage(chatId, 'Please send the new group picture as a photo.'); awaitingGroupPic.set(chatId, userId); // Track the admin who issued the command } else { bot.sendMessage(chatId, "You don't have permission to use this command."); } }); // Handle photo uploads for /setgrouppic bot.on('photo', async (msg) => { const chatId = msg.chat.id; const userId = msg.from.id; // Check if we are awaiting a photo from an admin if (awaitingGroupPic.get(chatId) === userId) { const photoId = msg.photo[msg.photo.length - 1].file_id; try { const file = await bot.getFile(photoId); const downloadPath = await bot.downloadFile(photoId, './'); await bot.setChatPhoto(chatId, fs.createReadStream(downloadPath)); bot.sendMessage(chatId, 'Group picture updated successfully!'); // Clean up fs.unlinkSync(downloadPath); awaitingGroupPic.delete(chatId); // Remove the flag after setting the picture } catch (error) { console.error('Error:'); bot.sendMessage(chatId, 'Failed to update group picture. Make sure I have the required permissions.'); } } }); // Kick command bot.onText(/\/kick/, async (msg) => { const chatId = msg.chat.id; if (msg.reply_to_message) { const userId = msg.reply_to_message.from.id; // User to kick must be mentioned in reply const requesterId = msg.from.id; // ID of the person issuing the command if (await isAdmin(chatId, requesterId)) { try { await bot.kickChatMember(chatId, userId); bot.sendMessage(chatId, "User has been kicked."); // Optionally, unban the user immediately to allow them to rejoin if necessary setTimeout(() => { bot.unbanChatMember(chatId, userId); }, 1000); } catch (err) { console.error("Failed to kick user:"); bot.sendMessage(chatId, "Failed to kick user. Ensure I have appropriate permissions."); } } else { bot.sendMessage(chatId, "You don't have permission to use this command."); } } else { bot.sendMessage(chatId, "Please reply to a user's message to kick them."); } }); // Mute command // Mute command bot.onText(/\/mute/, async (msg) => { const chatId = msg.chat.id; const requesterId = msg.from.id; // Check if the user issuing the command is an admin if (await isAdmin(chatId, requesterId)) { if (msg.reply_to_message) { const userId = msg.reply_to_message.from.id; // User to mute must be mentioned in reply mutedUsers.add(userId); bot.sendMessage(chatId, `User has been muted.`); } else { bot.sendMessage(chatId, "Please reply to a user's message to mute them."); } } else { bot.sendMessage(chatId, "You don't have permission to use this command."); } }); // Function to get anime details from Jikan API async function getAnimeInfo(animeName) { try { const response = await axios.get(`https://api.jikan.moe/v4/anime?q=${animeName}&limit=1`); const anime = response.data.data[0]; if (anime) { const title = anime.title; const synopsis = anime.synopsis; const rating = anime.rating; const imageUrl = anime.images.jpg.image_url; const url = anime.url; return { info: `*${title}*\n\n${synopsis}\n\n*Rating:* ${rating}\n\n[More Info](${url})`, imageUrl: imageUrl, }; } else { return { info: 'No anime found with that name.', imageUrl: null }; } } catch (error) { console.error('Error fetching anime info:'); return { info: 'Oops! Something went wrong.', imageUrl: null }; } } // Command handler for /anime bot.onText(/\/anime (.+)/, async (msg, match) => { const chatId = msg.chat.id; const animeName = match[1]; const { info, imageUrl } = await getAnimeInfo(animeName); // Send the information as a message bot.sendMessage(chatId, info, { parse_mode: 'Markdown' }); // If an image URL is available, send the image if (imageUrl) { bot.sendPhoto(chatId, imageUrl); } }); // Unmute command bot.onText(/\/unmute/, (msg) => { const chatId = msg.chat.id; if (msg.reply_to_message) { const userId = msg.reply_to_message.from.id; // User to unmute must be mentioned in reply mutedUsers.delete(userId); bot.sendMessage(chatId, `User has been unmuted.`); } else { bot.sendMessage(chatId, "Please reply to a user's message to unmute them."); } }); // Promote command bot.onText(/\/promote/, async (msg) => { const chatId = msg.chat.id; if (msg.reply_to_message) { const userId = msg.reply_to_message.from.id; // User to promote must be mentioned in reply if (await isAdmin(chatId, msg.from.id)) { try { await bot.promoteChatMember(chatId, userId, { can_change_info: true, can_post_messages: true, can_edit_messages: true, can_delete_messages: true, can_invite_users: true, can_restrict_members: true, can_pin_messages: true, can_promote_members: true }); bot.sendMessage(chatId, "User has been promoted to admin."); } catch (err) { bot.sendMessage(chatId, "Failed to promote user."); } } else { bot.sendMessage(chatId, "You don't have permission to use this command."); } } else { bot.sendMessage(chatId, "Please reply to a user's message to promote them."); } }); // Demote command bot.onText(/\/demote/, async (msg) => { const chatId = msg.chat.id; if (msg.reply_to_message) { const userId = msg.reply_to_message.from.id; // User to demote must be mentioned in reply if (await isAdmin(chatId, msg.from.id)) { try { await bot.promoteChatMember(chatId, userId, { can_change_info: false, can_post_messages: false, can_edit_messages: false, can_delete_messages: false, can_invite_users: false, can_restrict_members: false, can_pin_messages: false, can_promote_members: false }); bot.sendMessage(chatId, "User has been demoted."); } catch (err) { bot.sendMessage(chatId, "Failed to demote user."); } } else { bot.sendMessage(chatId, "You don't have permission to use this command."); } } else { bot.sendMessage(chatId, "Please reply to a user's message to demote them."); } }); // Set name command bot.onText(/\/setname (.+)/, async (msg, match) => { const chatId = msg.chat.id; const newName = match[1]; if (await isAdmin(chatId, msg.from.id)) { try { await bot.setChatTitle(chatId, newName); bot.sendMessage(chatId, `Group name has been changed to "${newName}".`); } catch (err) { bot.sendMessage(chatId, "Failed to change group name."); } } else { bot.sendMessage(chatId, "You don't have permission to use this command."); } }); // /meme command bot.onText(/\/meme/, async (msg) => { const chatId = msg.chat.id; try { const response = await axios.get('https://meme-api.herokuapp.com/gimme'); const memeUrl = response.data.url; bot.sendPhoto(chatId, memeUrl); } catch (error) { bot.sendMessage(chatId, 'Could not retrieve a meme at the moment. Please try again later.'); } }); // /joke command bot.onText(/\/joke/, async (msg) => { const chatId = msg.chat.id; try { const response = await axios.get('https://official-joke-api.appspot.com/random_joke'); const joke = `${response.data.setup} - ${response.data.punchline}`; bot.sendMessage(chatId, joke); } catch (error) { bot.sendMessage(chatId, 'Failed to fetch a joke. Please try again later.'); } }); // /text2pdf command bot.onText(/\/text2pdf (.+)/, async (msg, match) => { const chatId = msg.chat.id; const inputText = match[1].trim(); if (!inputText) { return bot.sendMessage( chatId, "❌ *Please provide the text to convert into a PDF!*\nExample: `/text2pdf Hello, this is a test.`", { parse_mode: "Markdown" } ); } try { // Encode the text to be sent in the URL const encodedText = encodeURIComponent(inputText); const pdfUrl = `https://bk9.fun/tools/pdf?q=${encodedText}`; // Step 1: Fetch the PDF file const response = await axios({ method: "GET", url: pdfUrl, responseType: "stream", }); // Generate a random file name for the PDF const fileName = `document_${Date.now()}.pdf`; const filePath = `./${fileName}`; // Step 2: Save the PDF stream to a file const writer = require("fs").createWriteStream(filePath); response.data.pipe(writer); writer.on("finish", async () => { // Step 3: Send the PDF file to the user await bot.sendDocument(chatId, filePath, { caption: `✅ Your PDF file has been generated successfully!\n*ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ*`, parse_mode: "Markdown", }); // Cleanup: Delete the temporary file require("fs").unlinkSync(filePath); console.log(`Temporary file ${fileName} deleted successfully.`); }); writer.on("error", (error) => { console.error("Error saving PDF file:"); bot.sendMessage(chatId, "❌ Failed to generate or send the PDF file."); }); } catch (error) { console.error("PDF Generation Error:"); bot.sendMessage(chatId, "❌ An error occurred while generating the PDF. Please try again."); } }); bot.onText(/\/xvideosearch (.+)/, async (msg, match) => { const chatId = msg.chat.id; const query = match[1].trim(); if (!query) { return bot.sendMessage(chatId, "❌ *Please provide a search query!*\nExample: `/xvideosearch step sister`", { parse_mode: "Markdown", }); } try { // Step 1: Call the video search API const apiUrl = `https://api.agatz.xyz/api/xvideo?message=${encodeURIComponent(query)}`; const response = await axios.get(apiUrl); const result = response.data; // Step 2: Check if results exist if (result.status === 200 && result.data.length > 0) { const videoInfo = result.data[0]; // Get the first video result // Step 3: Prepare the message body const body = `🎥 *Video Search Result:*\n\n` + `🔤 *Title:* ${videoInfo.title}\n` + `⏱️ *Duration:* ${videoInfo.duration}\n\nᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ`; // Step 4: Add an inline keyboard button with the video link const options = { parse_mode: "Markdown", reply_markup: { inline_keyboard: [ [ { text: "🔗 Watch Video", url: videoInfo.url, }, ], ], }, }; // Step 5: Send the video thumbnail and details to the user with the button await bot.sendPhoto(chatId, videoInfo.thumb, { caption: body, ...options, }); } else { bot.sendMessage(chatId, "❌ No results found. Please try a different query."); } } catch (error) { console.error("Video Search Error:"); bot.sendMessage(chatId, "❌ An error occurred while fetching the search results. Please try again."); } }); // Tag all command bot.onText(/\/tagall/, async (msg) => { const chatId = msg.chat.id; if (await isAdmin(chatId, msg.from.id)) { const members = await bot.getChatAdministrators(chatId); const memberMentions = members.map(member => { return member.user.username ? `@${member.user.username}` : member.user.first_name; }).join(', '); bot.sendMessage(chatId, `Tagging all members:\n${memberMentions}`); } else { bot.sendMessage(chatId, "You don't have permission to use this command."); } }); // Define the /Aza command bot.onText(/\/support/, (msg) => { const chatId = msg.chat.id; const response = "9066528353 OPAY 🇳🇬\nPlease support Developer."; // Send the message bot.sendMessage(chatId, response); }); // Define the /owner command bot.onText(/\/owner/, (msg) => { const chatId = msg.chat.id; const response = "@deecee_x"; // Send the message bot.sendMessage(chatId, response); }); // /setdescription command bot.onText(/\/setdescription (.+)/, (msg, match) => { const chatId = msg.chat.id; const description = match[1]; if (msg.chat.type !== 'group' && msg.chat.type !== 'supergroup') { bot.sendMessage(chatId, 'This command can only be used in group chats.'); return; } // Check if the user is an admin bot.getChatMember(chatId, msg.from.id).then(member => { if (member.status === 'administrator' || member.status === 'creator') { bot.setChatDescription(chatId, description) .then(() => { bot.sendMessage(chatId, 'Group description updated successfully!'); }) .catch((error) => { console.error('Error:'); bot.sendMessage(chatId, 'Failed to update group description. Make sure I have the required permissions.'); }); } else { bot.sendMessage(chatId, 'Only group admins can use this command.'); } }).catch(error => { console.error('Error fetching chat member:'); bot.sendMessage(chatId, 'An error occurred while verifying your admin status.'); }); }); // Get link command bot.onText(/\/getlink/, async (msg) => { const chatId = msg.chat.id; if (await isAdmin(chatId, msg.from.id)) { try { const link = await bot.exportChatInviteLink(chatId); bot.sendMessage(chatId, `Here is your invite link: ${link}`); } catch (err) { bot.sendMessage(chatId, "Failed to get the invite link."); } } else { bot.sendMessage(chatId, "You don't have permission to use this command."); } }); // Welcome and goodbye messages bot.on('new_chat_members', (msg) => { const chatId = msg.chat.id; msg.new_chat_members.forEach(user => { bot.sendMessage(chatId, `Welcome ${user.first_name} to the group!`); }); }); bot.on('left_chat_member', (msg) => { const chatId = msg.chat.id; const user = msg.left_chat_member; bot.sendMessage(chatId, `${user.first_name} has left the group.`); }); // Anti-link functionality bot.on('message', (msg) => { const chatId = msg.chat.id; // Check if anti-link is active if (antiLinkActive && msg.entities) { msg.entities.forEach(entity => { if (entity.type === "url") { bot.deleteMessage(chatId, msg.message_id) .then(() => { bot.sendMessage(chatId, "Links are not allowed in this group."); }) .catch(err => { console.error("Failed to delete message:"); }); } }); } // Mute functionality if (mutedUsers.has(msg.from.id)) { bot.deleteMessage(chatId, msg.message_id) .catch(err => { console.error("Failed to delete muted user message:"); }); } }); bot.onText(/\/txt2image (.+)/, async (msg, match) => { const chatId = msg.chat.id; const prompt = match[1]; // Extract the prompt from the command // Check if the user provided a prompt if (!prompt) { return bot.sendMessage(chatId, "❌ *Please provide a prompt!* \n\nUsage: `/magicstudio `", { parse_mode: "Markdown" }); } try { // Inform the user the process has started await bot.sendMessage(chatId, "✨ *Generating image... Please wait!*", { parse_mode: "Markdown" }); // API URL to generate the image const apiUrl = `https://bk9.fun/ai/magicstudio?prompt=${encodeURIComponent(prompt)}`; // Fetch the generated image from the API const response = await axios.get(apiUrl, { responseType: "stream" }); // Send the image back to the user await bot.sendPhoto(chatId, response.data, { caption: `🖼️ *Here's your generated image for:* \`${prompt}\`\n\nᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ`, parse_mode: "Markdown" }); } catch (error) { console.error("Error generating image:"); bot.sendMessage(chatId, "❌ *Failed to generate the image. Please try again later!*", { parse_mode: "Markdown" }); } }); bot.onText(/\/flux(?: (.+))?/, async (msg, match) => { const chatId = msg.chat.id; const prompt = match[1]; // Extract the user's prompt from the command if (!prompt) { // If no prompt is provided, send a usage guide return bot.sendMessage(chatId, "❌ Please provide a prompt to generate an image.\n\nExample: `/flux cat`", { parse_mode: "Markdown" }); } bot.sendMessage(chatId, "🔄 Generating your image... Please wait."); try { // Call the Flux API to generate the image const apiUrl = `https://apis.davidcyriltech.my.id/flux?prompt=${encodeURIComponent(prompt)}`; // Send the generated image to the user await bot.sendPhoto(chatId, apiUrl, { caption: `✨ *Flux Image Generated*\n\n🔹 *Prompt:* ${prompt}\n*ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ*`, parse_mode: "Markdown", }); } catch (error) { console.error("Error during /flux command:"); bot.sendMessage(chatId, "❌ An error occurred while generating the image. Please try again later."); } }); const { shannzCdn } = require("./uploader"); // Import new uploader module bot.on("message", async (msg) => { const chatId = msg.chat.id; const text = msg.text?.trim().toLowerCase(); if (text === "remini" && msg.reply_to_message?.photo) { try { await bot.sendMessage(chatId, "⏳ Processing your image..."); // Step 1: Download Image from Telegram const fileId = msg.reply_to_message.photo[msg.reply_to_message.photo.length - 1].file_id; const file = await bot.getFile(fileId); const fileUrl = `https://api.telegram.org/file/bot${process.env.BOT_TOKEN}/${file.file_path}`; const localFilePath = path.join(__dirname, "downloads", `${fileId}.jpg`); const writer = fs.createWriteStream(localFilePath); const imageResponse = await axios({ url: fileUrl, method: "GET", responseType: "stream" }); imageResponse.data.pipe(writer); await new Promise((resolve, reject) => { writer.on("finish", resolve); writer.on("error", reject); }); // Step 2: Upload Image to Shannz CDN const uploadResponse = await shannzCdn(localFilePath); console.log("Shannz CDN Response:", uploadResponse); if (!uploadResponse || !uploadResponse.url) { fs.unlinkSync(localFilePath); return bot.sendMessage(chatId, "❌ Failed to upload the image. Please try again."); } const imageUrl = uploadResponse.url; console.log("Uploaded Image URL:", imageUrl); // Step 3: Send Image to Remini API const enhanceUrl = `https://bk9.fun/tools/enhance?url=${encodeURIComponent(imageUrl)}`; console.log("Enhancement API URL:", enhanceUrl); // Step 4: Send Enhanced Image to User await bot.sendPhoto(chatId, enhanceUrl, { caption: "✨ *Image Enhanced Successfully!*", parse_mode: "Markdown", }); fs.unlinkSync(localFilePath); // Cleanup } catch (error) { console.error("Error enhancing image:"); bot.sendMessage(chatId, `❌ Error`); } } }); // Handle /delete Command bot.onText(/\/delete/, async (msg) => { const chatId = msg.chat.id; if (msg.reply_to_message) { try { await bot.deleteMessage(chatId, msg.reply_to_message.message_id); await bot.deleteMessage(chatId, msg.message_id); } catch (error) { bot.sendMessage(chatId, "❌ Unable to delete the message. Check my permissions."); } } else { bot.sendMessage(chatId, "❌ Please reply to a message to delete it."); } }); // Delete Message Command bot.onText(/\/delete/, async (msg) => { const chatId = msg.chat.id; if (msg.reply_to_message) { const messageId = msg.reply_to_message.message_id; try { // Delete the replied message await bot.deleteMessage(chatId, messageId); // Optionally delete the command message await bot.deleteMessage(chatId, msg.message_id); // Confirmation message await bot.sendMessage(chatId, "✅ Message deleted successfully.", { reply_to_message_id: msg.message_id }); } catch (error) { console.error("Delete message error:"); bot.sendMessage( chatId, "❌ Failed to delete the message. Ensure I have the necessary permissions.", { reply_to_message_id: msg.message_id } ); } } else { bot.sendMessage(chatId, "❌ Please reply to the message you want to delete.", { reply_to_message_id: msg.message_id }); } }); // Start the bot bot.onText(/\/help/, (msg) => { const chatId = msg.chat.id; bot.sendMessage(chatId, "Hi I Am Atomic! Use /start for available commands."); }); // Store the start time when the bot starts const startTime = Date.now(); // Command to get bot runtime bot.onText(/\/runtime/, (msg) => { const chatId = msg.chat.id; // Calculate runtime const uptimeMs = Date.now() - startTime; const uptimeSeconds = Math.floor(uptimeMs / 1000); const hours = Math.floor(uptimeSeconds / 3600); const minutes = Math.floor((uptimeSeconds % 3600) / 60); const seconds = uptimeSeconds % 60; // Send back the bot runtime bot.sendMessage(chatId, `The bot has been running for ${hours} hours, ${minutes} minutes, and ${seconds} seconds.`); }); // /ping command bot.onText(/\/ping/, (msg) => { const chatId = msg.chat.id; const start = Date.now(); // Record the start time bot.sendMessage(chatId, 'Pong!').then(() => { const end = Date.now(); // Record the end time const ping = end - start; // Calculate the difference in milliseconds bot.sendMessage(chatId, `Response time: ${ping} ms`); }); }); // Unified /start command bot.onText(/\/start/, (msg) => { const chatId = msg.chat.id; // First page: Download Commands const helpMessageDownload = ` *🔥 ATOMIC BOT MENU 🔥* ⬇️ *Download Commands*: - 🎶 /play : Download and play music from YouTube. - 🎶 /song : Download and play music from Spotify. - 🎥 /tiktok : Download TikTok videos. - 📸 /instagram : Download Instagram media. - 📘 /fb : Download Facebook videos. - 🎥 /video : Download Music Videos. - 🎶 /ytmp3 : Download Music Videos. - 🎥 /ytmp4 : Download and play music. - 📦 /mediafire : Downloads MediaFire Files - 📦 /apk : Downloads Apk. - 📦 /gitclone : Downloads files from github - 🎬 /movie : Downloads movies. - 🎬 /twitter : Downloads twitter videos. `; bot.sendMessage(chatId, helpMessageDownload, { parse_mode: 'Markdown', reply_markup: { inline_keyboard: [ [{ text: "➡️ NEXT", callback_data: "help_next_1" }] ] } }); }); // Handle button clicks for pagination bot.on('callback_query', (query) => { const chatId = query.message.chat.id; // First "NEXT" button (from Download Menu to Admin Commands) if (query.data === "help_next_1") { const helpMessageAdmin = `🤖 *AI Commands*: - 🤖 /chatbot : Interact with ai models without using any prefix - 🤖 /gpt : Get an AI-powered response. - 🔊 /text2speech : Convert text to speech. - 🪄 /text2image : Generates Any Ai Image of your choice. - 🪄 /flux : Generates Any Realistic Ai Images. `; bot.editMessageText(helpMessageAdmin, { chat_id: chatId, message_id: query.message.message_id, parse_mode: 'Markdown', reply_markup: { inline_keyboard: [ [ { text: "⬅️ BACK", callback_data: "help_back_0" }, { text: "➡️ NEXT", callback_data: "help_next_2" } ] ] } }); } // Second "NEXT" button (from Admin Commands to AI Menu) if (query.data === "help_next_2") { const helpMessageAI = ` 🛠️ *Admin Commands*: - 👮‍♂️ /kick: Kick a user (reply to their message). - 🤐 /mute: Mute a user (reply to their message). - 🔓 /unmute: Unmute a user (reply to their message). - 📈 /promote: Promote a user to admin (reply to their message). - 📉 /demote: Demote an admin (reply to their message). - 📝 /setname : Change the group name. - 🔗 /getlink: Get the group invite link. - 🚫 /antilink: Toggle anti-link feature. - 🖼️ /setgrouppic: Change the group picture. - ✏️ /setdescription : Update group description. `; bot.editMessageText(helpMessageAI, { chat_id: chatId, message_id: query.message.message_id, parse_mode: 'Markdown', reply_markup: { inline_keyboard: [ [ { text: "⬅️ BACK", callback_data: "help_back_1" }, { text: "➡️ NEXT", callback_data: "help_next_3" } ] ] } }); } // Third "NEXT" button (from AI Menu to Tools Menu) if (query.data === "help_next_3") { const helpMessageTools = ` 🔧 *Special Menu*: - 🥵 /xvideosearch: searches for adult videos - 👙 /xvideodownload: downloads adult videos `; bot.editMessageText(helpMessageTools, { chat_id: chatId, message_id: query.message.message_id, parse_mode: 'Markdown', reply_markup: { inline_keyboard: [ [ { text: "⬅️ BACK", callback_data: "help_back_2" }, { text: "➡️ NEXT", callback_data: "help_next_4" } ] ] } }); } // Third "NEXT" button (from AI Menu to Tools Menu) if (query.data === "help_next_4") { const helpMessageTools = ` 🔧 *Tools Menu*: - 📄 /txt2pdf: Convert text to PDF. (coming soon) - 🖇️ /url: Coverts Video, Photo, any file to url - 📸 /ss: screenshots a website - 😍 /remini: Enhances any low quality image - 🥰 /couplepp: sends couples pics - 🖼️ /image: searchs for images on the internet - 🎙️ /shazam: identifies any music on a video or audio file `; bot.editMessageText(helpMessageTools, { chat_id: chatId, message_id: query.message.message_id, parse_mode: 'Markdown', reply_markup: { inline_keyboard: [ [ { text: "⬅️ BACK", callback_data: "help_back_3" }, { text: "➡️ NEXT", callback_data: "help_next_5" } ] ] } }); } // Fourth "NEXT" button (from Tools Menu to Utility Commands) if (query.data === "help_next_5") { const helpMessageUtility = ` 📊 *Utility Commands*: - ⏳ /runtime: Check the bot's uptime. - 🏓 /ping: Check bot's response time. - 💸 /currency to : Convert currencies (e.g., /currency 100 USD to EUR). - 🗑️ /delete: Delete a specific message (reply to it). `; bot.editMessageText(helpMessageUtility, { chat_id: chatId, message_id: query.message.message_id, parse_mode: 'Markdown', reply_markup: { inline_keyboard: [ [ { text: "⬅️ BACK", callback_data: "help_back_4" }, { text: "➡️ NEXT", callback_data: "help_next_6" } ] ] } }); } // Fifth "NEXT" button (from Utility Commands to Other Commands) if (query.data === "help_next_6") { const helpMessageOther = ` 🙋‍♂️ *Other Commands*: - 👑 /owner: Show the owner details. - 🤝 /support: Support the developer. - 📢 /tagall: Tag all group members. - 🚀 /start: Welcome message and introduction. - ❓ /help: Show this help menu. *ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ* `; bot.editMessageText(helpMessageOther, { chat_id: chatId, message_id: query.message.message_id, parse_mode: 'Markdown', reply_markup: { inline_keyboard: [ [ { text: "⬅️ BACK", callback_data: "help_back_5" } ] ] } }); } // Handle "BACK" buttons if (query.data === "help_back_0") { bot.editMessageText(helpMessageDownload, { chat_id: chatId, message_id: query.message.message_id, parse_mode: 'Markdown', reply_markup: { inline_keyboard: [ [{ text: "➡️ NEXT", callback_data: "help_next_1" }] ] } }); } if (query.data === "help_back_1") { const helpMessageAdmin = ` 🛠️ *Admin Commands*: - 👮‍♂️ /kick: Kick a user (reply to their message). - 🤐 /mute: Mute a user (reply to their message). - 🔓 /unmute: Unmute a user (reply to their message). - 📈 /promote: Promote a user to admin (reply to their message). - 📉 /demote: Demote an admin (reply to their message). - 📝 /setname : Change the group name. - 🔗 /getlink: Get the group invite link. - 🚫 /antilink: Toggle anti-link feature. - 🖼️ /setgrouppic: Change the group picture. - ✏️ /setdescription : Update group description. `; bot.editMessageText(helpMessageAdmin, { chat_id: chatId, message_id: query.message.message_id, parse_mode: 'Markdown', reply_markup: { inline_keyboard: [ [ { text: "⬅️ BACK", callback_data: "help_back_0" }, { text: "➡️ NEXT", callback_data: "help_next_2" } ] ] } }); } if (query.data === "help_back_2") { const helpMessageAI = ` 🤖 *AI Commands*: - 🤖 /gpt : Answers any question. - 🔊 /text2speech : Convert text to speech. (coming soon) - 🔊 /text2speech : Convert text to speech. - 🪄 /text2image : Generates Any Ai Image of your choice. - 🪄 /flux : Generates Any Realistic Ai Images. `; bot.editMessageText(helpMessageAI, { chat_id: chatId, message_id: query.message.message_id, parse_mode: 'Markdown', reply_markup: { inline_keyboard: [ [ { text: "⬅️ BACK", callback_data: "help_back_1" }, { text: "➡️ NEXT", callback_data: "help_next_3" } ] ] } }); } if (query.data === "help_back_3") { const helpMessageTools = ` 🔧 *Special Menu*: - 🥵 /xvideosearch: searches for adult videos - 👙 /xvideodownload: downloads adult videos `; bot.editMessageText(helpMessageTools, { chat_id: chatId, message_id: query.message.message_id, parse_mode: 'Markdown', reply_markup: { inline_keyboard: [ [ { text: "⬅️ BACK", callback_data: "help_back_2" }, { text: "➡️ NEXT", callback_data: "help_next_4" } ] ] } }); } if (query.data === "help_back_3") { const helpMessageTools = ` 🔧 *Tools Menu*: - 📄 /txt2pdf: Convert text to PDF. - 🖇️ /url: Coverts Video, Photo, any file to url - 😍 /remini: Enhances any low quality image - 🖼️ /image: searchs for images on the internet - 🎙️ /shazam: identifies any music on a video or audio file `; bot.editMessageText(helpMessageTools, { chat_id: chatId, message_id: query.message.message_id, parse_mode: 'Markdown', reply_markup: { inline_keyboard: [ [ { text: "⬅️ BACK", callback_data: "help_back_2" }, { text: "➡️ NEXT", callback_data: "help_next_4" } ] ] } }); } if (query.data === "help_back_4") { const helpMessageUtility = ` 📊 *Utility Commands*: - ⏳ /runtime: Check the bot's uptime. - 🏓 /ping: Check bot's response time. - 💸 /currency to : Convert currencies (e.g., /currency 100 USD to EUR). - 🗑️ /delete: Delete a specific message (reply to it). `; bot.editMessageText(helpMessageUtility, { chat_id: chatId, message_id: query.message.message_id, parse_mode: 'Markdown', reply_markup: { inline_keyboard: [ [ { text: "⬅️ BACK", callback_data: "help_back_3" }, { text: "➡️ NEXT", callback_data: "help_next_5" } ] ] } }); } });