| |
| const express = require('express'); |
| const { sinhalaSub } = require("mrnima-moviedl"); |
|
|
| const FormData = require('form-data'); |
|
|
| const { catbox } = require('./catbox'); |
|
|
|
|
| const { exec } = require("child_process"); |
|
|
| const yts = require("yt-search") |
|
|
|
|
| |
| const app = express(); |
| const PORT = process.env.PORT || 3000; |
|
|
|
|
|
|
| |
| 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'; |
| |
| const bot = new TelegramBot('7398508893:AAFE6xOytstrMZ0PpRa3ieH6SLBy9TR9vq4', { polling: true }); |
|
|
| |
| const mutedUsers = new Set(); |
|
|
| |
| let antiLinkActive = false; |
|
|
| |
| const isAdmin = async (chatId, userId) => { |
| try { |
| const member = await bot.getChatMember(chatId, userId); |
| return member.status === 'administrator' || member.status === 'creator'; |
| } catch (error) { |
| return false; |
| } |
| }; |
|
|
|
|
|
|
|
|
|
|
| |
| bot.onText(/\/(tiktok|tt|ttmedia)(?: (.+))?/, async (msg, match) => { |
| const chatId = msg.chat.id; |
| const text = match[2]; |
|
|
| if (!text) { |
| |
| 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 { |
| |
| const response = await axios.get(`https://api.paxsenix.biz.id/dl/tiktok?url=${encodeURIComponent(text)}`); |
| const data = response.data; |
|
|
| if (data && data.downloadsUrl) { |
| |
| await bot.sendVideo(chatId, data.downloadsUrl.video); |
|
|
| |
| 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 { |
| |
| await bot.sendMessage(chatId, "๐ *Fetching couple profile pictures...*", { parse_mode: "Markdown" }); |
|
|
| |
| 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; |
|
|
| |
| await bot.sendPhoto(chatId, male, { |
| caption: "๐ฆ *Male Picture*", |
| parse_mode: "Markdown" |
| }); |
|
|
| |
| 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."); |
| } |
| }); |
|
|
|
|
| |
| 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 { |
| |
| await bot.sendChatAction(chatId, "typing"); |
|
|
| |
| const apiUrl = `https://api.paxsenix.biz.id/ai/gpt4?text=${encodeURIComponent(query)}`; |
| const { data } = await axios.get(apiUrl); |
|
|
| |
|
|
| |
| if (!data.ok || !data.message) { |
| return bot.sendMessage(chatId, `โ GPT API Error: Unable to fetch a response. Please try again later.`); |
| } |
|
|
| |
| 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; |
|
|
| |
| 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 { |
| |
| const processingMsg = await bot.sendMessage(chatId, "โณ *Uploading your file...*", { parse_mode: "Markdown" }); |
|
|
| |
| const filePath = await bot.downloadFile(fileId, "./downloads"); |
|
|
| |
| const uploadResponse = await catbox(filePath); |
|
|
| |
| 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" }); |
| } |
|
|
| |
| 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; |
|
|
| |
| 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 { |
| |
| const processingMsg = await bot.sendMessage(chatId, "โณ *Enhancing your image...*", { parse_mode: "Markdown" }); |
|
|
| |
| const filePath = await bot.downloadFile(fileId, "./downloads"); |
|
|
| |
| const uploadResponse = await catbox(filePath); |
|
|
| if (!uploadResponse.url) { |
| fs.unlinkSync(filePath); |
| return bot.sendMessage(chatId, "โ *Upload Failed. Please try again.*", { parse_mode: "Markdown" }); |
| } |
|
|
| const imageUrl = uploadResponse.url; |
|
|
| |
| const enhancedImageUrl = `https://bk9.fun/tools/enhance?url=${encodeURIComponent(imageUrl)}`; |
|
|
| |
| await bot.sendPhoto(chatId, enhancedImageUrl, { |
| caption: `โ
*Successfully Enhanced Your Image!*\n\n*แดแดแดกแดสแดแด
สส แด
แดแด ษชแด
แดสสษชส แดแดแดส*`, |
| parse_mode: "Markdown", |
| }); |
|
|
| |
| 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 <search term>`", { parse_mode: 'Markdown' }); |
| } |
|
|
| try { |
| const searchMsg = await bot.sendMessage(chatId, "๐ *Searching for your video...*", { parse_mode: "Markdown" }); |
|
|
| const search = await yts(query); |
| const video = search.all[0]; |
| if (!video) { |
| return bot.sendMessage(chatId, "โ Video not found!"); |
| } |
|
|
| 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; |
|
|
| await bot.sendVideo(chatId, download_url, { |
| caption: `๐ฌ *Here is your video:*\n๐ฅ *${title}*\n\n*แดแดแดกแดสแดแด
สส แด
แดแด ษชแด
แดสสษชส แดแดแดส*`, |
| parse_mode: "Markdown" |
| }); |
| } 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."); |
| } |
| }); |
|
|
| |
| bot.onText(/\/ytmp4 (.+)/, async (msg, match) => { |
| const chatId = msg.chat.id; |
| const youtubeLink = match[1]?.trim(); |
|
|
| if (!youtubeLink) { |
| return bot.sendMessage(chatId, "โ *Usage*: `/ytmp4 <YouTube link>`\nExample: `/ytmp4 https://youtube.com/watch?v=iI34LYmJ1Fs`", { parse_mode: 'Markdown' }); |
| } |
|
|
| try { |
| const loadingMsg = await bot.sendMessage(chatId, "๐ *Processing your video...*", { parse_mode: "Markdown" }); |
|
|
| 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; |
|
|
| await bot.sendVideo(chatId, download_url, { |
| caption: `๐ฌ *${title}*\n\n*แดแดแดกแดสแดแด
สส แด
แดแด ษชแด
แดสสษชส แดแดแดส*`, |
| parse_mode: "Markdown" |
| }); |
| } 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."); |
| } |
| }); |
|
|
| |
| bot.onText(/\/ytmp3 (.+)/, async (msg, match) => { |
| const chatId = msg.chat.id; |
| const youtubeLink = match[1]?.trim(); |
|
|
| if (!youtubeLink) { |
| return bot.sendMessage(chatId, "โ *Usage*: `/ytmp3 <YouTube link>`\nExample: `/ytmp3 https://youtube.com/watch?v=iI34LYmJ1Fs`", { parse_mode: 'Markdown' }); |
| } |
|
|
| try { |
| const loadingMsg = await bot.sendMessage(chatId, "๐ *Processing your audio...*", { parse_mode: "Markdown" }); |
|
|
| 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; |
|
|
| await bot.sendAudio(chatId, download_url, { |
| caption: `๐ง *${title}*\n\n*แดแดแดกแดสแดแด
สส แด
แดแด ษชแด
แดสสษชส แดแดแดส*`, |
| parse_mode: "Markdown" |
| }); |
| } 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."); |
| } |
| }); |
|
|
|
|
|
|
|
|
| |
| 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`", { parse_mode: "Markdown" }); |
| } |
|
|
| try { |
| await bot.sendMessage(chatId, "๐ Searching for your song..."); |
|
|
| 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."); |
| } |
|
|
| 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; |
|
|
| await bot.sendPhoto(chatId, thumbnail, { |
| caption: `๐ถ *Music Player* ๐ถ\n\n` + |
| `๐ต *Title:* ${title}\n` + |
| `๐ [Watch on YouTube](${video.url})\n\n` + |
| `*แดแดแดกแดสแดแด
สส แด
แดแด ษชแด
แดสสษชส แดแดแดส*`, |
| parse_mode: "Markdown", |
| }); |
|
|
| await bot.sendAudio(chatId, download_url, { |
| caption: `๐ง *Here's your song:*\n๐ต *Title:* ${title}\n\n*แดแดแดกแดสแดแด
สส แด
แดแด ษชแด
แดสสษชส แดแดแดส*`, |
| parse_mode: "Markdown", |
| }); |
| } 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."); |
| } |
| }); |
|
|
|
|
| |
|
|
| let chatbotActive = {}; |
| let conversationIds = {}; |
|
|
| bot.onText(/\/gitclone (.+)/, async (msg, match) => { |
| const chatId = msg.chat.id; |
| const repoUrl = match[1]?.trim(); |
|
|
| if (!repoUrl) { |
| return bot.sendMessage(chatId, "โ *Usage*: `/gitclone <GitHub Repo URL>`\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`; |
|
|
| |
| 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 <MediaFire Link>`\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, "_")); |
|
|
| |
| 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); |
| }); |
|
|
| |
| await bot.sendDocument(chatId, filePath, { |
| caption: `๐ฆ *File Name:* ${fileName}\n\n*แดแดแดกแดสแดแด
สส แด
แดแด ษชแด
แดสสษชส แดแดแดส*`, |
| parse_mode: "Markdown", |
| }); |
|
|
| |
| 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 <Website URL>`\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(/\/bible (.+)/, async (msg, match) => { |
| const chatId = msg.chat.id; |
| const chapterInput = match[1]?.trim(); |
|
|
| if (!chapterInput) { |
| return bot.sendMessage( |
| chatId, |
| "โ *Usage*: `/bible <chapter and verse>`\nExample: `/bible john 3:16`", |
| { parse_mode: "Markdown" } |
| ); |
| } |
|
|
| const BASE_URL = "https://bible-api.com"; |
|
|
| try { |
| |
| 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; |
|
|
| |
| 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} |
| `; |
|
|
| |
| 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]; |
|
|
| |
| if (!prompt) { |
| return bot.sendMessage(chatId, "โ *Please provide a prompt!* \n\nUsage: `/magicstudio <prompt>`", { parse_mode: "Markdown" }); |
| } |
|
|
| try { |
| |
| await bot.sendMessage(chatId, "โจ *Generating image... Please wait!*", { parse_mode: "Markdown" }); |
|
|
| |
| const apiUrl = `https://bk9.fun/ai/magicstudio?prompt=${encodeURIComponent(prompt)}`; |
|
|
| |
| const response = await axios.get(apiUrl, { responseType: "stream" }); |
|
|
| |
| 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(/\/apk (.+)/, async (msg, match) => { |
| const chatId = msg.chat.id; |
| const packageName = match[1]?.trim(); |
|
|
| if (!packageName) { |
| return bot.sendMessage(chatId, "โ *Usage*: `/apk <package_name>`\nExample: `/apk com.whatsapp`", { parse_mode: "Markdown" }); |
| } |
|
|
| try { |
| |
| 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."); |
| } |
|
|
| |
| 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; |
|
|
| |
| const inlineKeyboard = [ |
| [ |
| { |
| text: "๐ฅ Download APK", |
| url: downloadLink, |
| }, |
| ], |
| ]; |
|
|
| const options = { |
| reply_markup: { |
| inline_keyboard: inlineKeyboard, |
| }, |
| parse_mode: "Markdown", |
| }; |
|
|
| |
| 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."); |
| } |
| }); |
|
|
|
|
| |
| 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 { |
| |
| const sinhala = await sinhalaSub(); |
| const results = await sinhala.search(query); |
| const movies = results.result.slice(0, 10); |
|
|
| if (!movies.length) { |
| return bot.sendMessage(chatId, `โ No results found for: *${query}*`, { parse_mode: "Markdown" }); |
| } |
|
|
| |
| const inlineKeyboard = movies.map((movie, index) => [ |
| { |
| text: `${index + 1}. ${movie.title}`, |
| callback_data: `movie_${index}`, |
| }, |
| ]); |
|
|
| 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); |
|
|
| |
| bot.on("callback_query", async (callbackQuery) => { |
| const { data, message } = callbackQuery; |
|
|
| |
| 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 { |
| |
| 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."); |
| } |
|
|
| |
| const qualityKeyboard = downloadLinks.map((link) => { |
| const pixelDrainId = link.link.split("/").pop(); |
| const directDownloadLink = `https://pixeldrain.com/api/file/${pixelDrainId}?download`; |
| return [ |
| { |
| text: `${link.quality} - ${link.size}`, |
| url: directDownloadLink, |
| }, |
| ]; |
| }); |
|
|
| 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 |
| ); |
|
|
| |
| 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; |
|
|
| |
| 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 { |
| |
| const processingMsg = await bot.sendMessage(chatId, "๐ต Identifying the audio... Please wait!"); |
|
|
| |
| const filePath = await bot.downloadFile(fileId, "./downloads"); |
|
|
| |
| const uploadResponse = await catbox(filePath); |
| if (!uploadResponse.url) { |
| throw new Error("Failed to upload the file for analysis."); |
| } |
|
|
| |
| const shazamApiUrl = `https://api.paxsenix.biz.id/tools/shazam?url=${encodeURIComponent(uploadResponse.url)}`; |
| const shazamResponse = await axios.get(shazamApiUrl); |
| const shazamResult = shazamResponse.data; |
|
|
| |
| 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."); |
| } |
|
|
| |
| 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]; |
|
|
| if (!query) { |
| return bot.sendMessage( |
| chatId, |
| "โ Please provide a search query.\n\n*Usage:* `/image <query>`\n*Example:* `/image cats`", |
| { parse_mode: "Markdown" } |
| ); |
| } |
|
|
| bot.sendMessage(chatId, "๐ Searching for images... Please wait."); |
|
|
| try { |
| |
| 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.`); |
| } |
|
|
| |
| 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]; |
|
|
| if (!query) { |
| return bot.sendMessage( |
| chatId, |
| "โ Please provide a search query.\n\n*Usage:* `/spotifysearch <query>`\n*Example:* `/spotifysearch Spectre`", |
| { parse_mode: "Markdown" } |
| ); |
| } |
|
|
| bot.sendMessage(chatId, "๐ Searching for tracks on Spotify... Please wait."); |
|
|
| try { |
| |
| 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.`); |
| } |
|
|
| |
| 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]; |
|
|
| if (!spotifyUrl) { |
| return bot.sendMessage( |
| chatId, |
| "โ Please provide a Spotify track URL.\n\n*Usage:* `/spotify-download <Spotify URL>`\n*Example:* `/spotify-download https://open.spotify.com/track/2DGa7iaidT5s0qnINlwMjJ`", |
| { parse_mode: "Markdown" } |
| ); |
| } |
|
|
| bot.sendMessage(chatId, "๐ Fetching your Spotify track... Please wait."); |
|
|
| try { |
| |
| 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}`; |
|
|
| |
| await bot.sendAudio(chatId, track.download_url, { |
| caption: caption, |
| parse_mode: "Markdown", |
| thumb: track.thumbnail, |
| }); |
| } 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]; |
|
|
| if (!query) { |
| return bot.sendMessage( |
| chatId, |
| "โ Please provide a search query.\n\n*Usage:* `/song <song title>`\n*Example:* `/song faded`", |
| { parse_mode: "Markdown" } |
| ); |
| } |
|
|
| bot.sendMessage(chatId, "๐ Searching for songs on Spotify... Please wait."); |
|
|
| try { |
| |
| 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; |
|
|
| |
| 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" }); |
| } |
| }); |
|
|
| |
| 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 { |
| |
| 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; |
|
|
| |
| 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 |
| }); |
| } 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" }); |
| } |
| } |
| }); |
|
|
| |
| bot.onText(/\/(facebook|fb|fbdl|fbdownload)(?: (.+))?/, async (msg, match) => { |
| const chatId = msg.chat.id; |
| const text = match[2]; |
|
|
| |
| if (!text) { |
| return bot.sendMessage(chatId, "โ Please provide a Facebook video link.\nExample: `/fb https://www.facebook.com/reel/1256751708994400?mibextid=rS40aB7S9Ucbxw6v`"); |
| } |
|
|
| |
| bot.sendMessage(chatId, "๐ Fetching your Facebook video... Please wait."); |
|
|
| try { |
| |
| const apiResponse = await axios.get('https://bk9.fun/download/fb', { |
| params: { url: text }, |
| }); |
|
|
| const responseData = apiResponse.data; |
|
|
| |
| if (responseData.status && responseData.BK9) { |
| const videoData = responseData.BK9; |
| const hdLink = videoData.hd || videoData.sd; |
| const videoTitle = videoData.title || "Facebook Video"; |
|
|
| |
| 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."); |
| } |
| }); |
|
|
|
|
| |
| const twitterDownloadLinks = new Map(); |
|
|
| bot.onText(/\/twitter (.+)/, async (msg, match) => { |
| const chatId = msg.chat.id; |
| const twitterUrl = match[1]?.trim(); |
|
|
| |
| if (!twitterUrl || !twitterUrl.startsWith("http")) { |
| return bot.sendMessage(chatId, "โ Please provide a valid Twitter link.\nExample: `/twitter https://x.com/elonmusk/status/1870904082564555012`"); |
| } |
|
|
| |
| bot.sendMessage(chatId, "๐ Fetching Twitter media... Please wait."); |
|
|
| try { |
| |
| const apiUrl = `https://api.paxsenix.biz.id/dl/twitter?url=${encodeURIComponent(twitterUrl)}`; |
| const response = await axios.get(apiUrl); |
| const data = response.data; |
|
|
| |
| if (!data.ok) { |
| return bot.sendMessage(chatId, "โ Failed to fetch Twitter media. Please check the link and try again."); |
| } |
|
|
| |
| const uniqueIdHD = `HD_${Date.now()}`; |
| const uniqueIdSD = `SD_${Date.now()}`; |
| const uniqueIdAudio = `Audio_${Date.now()}`; |
|
|
| |
| if (data.HD) twitterDownloadLinks.set(uniqueIdHD, data.HD); |
| if (data.SD) twitterDownloadLinks.set(uniqueIdSD, data.SD); |
| if (data.audio) twitterDownloadLinks.set(uniqueIdAudio, data.audio); |
|
|
| |
| 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 }]); |
|
|
| |
| 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."); |
| } |
| }); |
|
|
| |
| bot.on("callback_query", async (callbackQuery) => { |
| const chatId = callbackQuery.message.chat.id; |
| const data = callbackQuery.data; |
|
|
| |
| const url = twitterDownloadLinks.get(data); |
| if (url) { |
| |
| await bot.sendMessage(chatId, "๐ฅ Downloading your media..."); |
|
|
| try { |
| |
| if (data.startsWith("HD") || data.startsWith("SD")) { |
| await bot.sendVideo(chatId, url, { caption: `๐ฌแดแดแดกแดสแดแด
สส แด
แดแด ษชแด
แดสสษชส แดแดแดส` }); |
| } else if (data.startsWith("Audio")) { |
| await bot.sendAudio(chatId, url, { caption: "๐ต แดแดแดกแดสแดแด
สส แด
แดแด ษชแด
แดสสษชส แดแดแดส!" }); |
| } |
|
|
| |
| 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, ""); |
| } |
|
|
| |
| bot.answerCallbackQuery(callbackQuery.id); |
| }); |
|
|
| |
| bot.onText(/\/(instagram|ig|igvideo|igimage|igdownload|instadl)(?: (.+))?/, async (msg, match) => { |
| const chatId = msg.chat.id; |
| const text = match[2]; |
|
|
| |
| if (!text || !text.startsWith('http')) { |
| return bot.sendMessage(chatId, "โ Please provide a valid Instagram link.\nExample: `/instagram https://www.instagram.com/reel/DDgvfkAuBMI/`"); |
| } |
|
|
| |
| bot.sendMessage(chatId, "๐ Fetching your Instagram media... Please wait."); |
|
|
| try { |
| |
| const apiResponse = await axios.get('https://api.paxsenix.biz.id/dl/ig', { |
| params: { url: text }, |
| }); |
|
|
| const responseData = apiResponse.data; |
|
|
| |
| if (responseData.ok && responseData.url && responseData.url.length > 0) { |
| const media = responseData.url[0]; |
| const mediaUrl = media.url; |
| const mediaType = media.type || "video"; |
|
|
| if (mediaType === "video") { |
| |
| await bot.sendVideo(chatId, mediaUrl, { |
| caption: `*แดแดแดกแดสแดแด
สส แด
แดแด ษชแด
แดสสษชส แดแดแดส*`, |
| parse_mode: "Markdown", |
| }); |
| } else { |
| |
| 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."); |
| } |
| }); |
| |
| |
| bot.onText(/\/antilink (on|off)/, async (msg, match) => { |
| const chatId = msg.chat.id; |
| const userId = msg.from.id; |
| const action = match[1]; |
|
|
| |
| 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(); |
|
|
| |
| 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 { |
| |
| const apiUrl = `https://api.agatz.xyz/api/xvideodown?url=${encodeURIComponent(url)}`; |
| const response = await axios.get(apiUrl); |
| const result = response.data; |
|
|
| |
| if (result.status === 200 && result.data?.url) { |
| const videoStreamUrl = result.data.url; |
|
|
| |
| const videoResponse = await axios({ |
| url: videoStreamUrl, |
| method: 'GET', |
| responseType: 'stream', |
| }); |
|
|
| |
| 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(); |
|
|
| |
| 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 { |
| |
| const apiUrl = `https://api.agatz.xyz/api/xvideodown?url=${encodeURIComponent(url)}`; |
| const response = await axios.get(apiUrl); |
| const result = response.data; |
|
|
| |
| if (result.status === 200 && result.data?.url) { |
| const videoInfo = result.data; |
| const videoUrl = videoInfo.url; |
|
|
| |
| 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` + |
| `*แดแดแดกแดสแดแด
สส แด
แดแด ษชแด
แดสสษชส แดแดแดส*`; |
|
|
| |
| 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"); |
|
|
| |
| 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 { |
| |
| const [text, lang] = input.split("|").map((item) => item.trim()); |
| const language = lang || "en"; |
|
|
| 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}`; |
|
|
| |
| const response = await axios({ |
| method: "GET", |
| url: apiUrl, |
| responseType: "stream", |
| }); |
|
|
| |
| const fileName = `${randomUUID()}.mp3`; |
| const filePath = `./${fileName}`; |
|
|
| |
| const writer = fs.createWriteStream(filePath); |
| response.data.pipe(writer); |
|
|
| writer.on("finish", async () => { |
| try { |
| |
| await bot.sendAudio(chatId, filePath, { |
| caption: `๐๏ธ *Text-to-Speech Result*\n๐ *Language:* ${language.toUpperCase()}`, |
| parse_mode: "Markdown", |
| }); |
|
|
| |
| 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); |
| } |
| }); |
|
|
| 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."); |
| } |
| }); |
|
|
|
|
|
|
|
|
| |
| 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.'); |
| } |
| }); |
|
|
|
|
|
|
|
|
|
|
| |
| async function getCurrencyConversion(amount, fromCurrency, toCurrency) { |
| try { |
| |
| 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.'; |
| } |
| } |
|
|
| |
| 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(); |
|
|
| |
| 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); |
| }); |
|
|
|
|
|
|
|
|
|
|
| |
| let awaitingGroupPic = new Map(); |
|
|
| |
| 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; |
| } |
|
|
| |
| if (await isAdmin(chatId, userId)) { |
| bot.sendMessage(chatId, 'Please send the new group picture as a photo.'); |
| awaitingGroupPic.set(chatId, userId); |
| } else { |
| bot.sendMessage(chatId, "You don't have permission to use this command."); |
| } |
| }); |
|
|
| |
| bot.on('photo', async (msg) => { |
| const chatId = msg.chat.id; |
| const userId = msg.from.id; |
|
|
| |
| 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!'); |
|
|
| |
| fs.unlinkSync(downloadPath); |
| awaitingGroupPic.delete(chatId); |
| } catch (error) { |
| console.error('Error:'); |
| bot.sendMessage(chatId, 'Failed to update group picture. Make sure I have the required permissions.'); |
| } |
| } |
| }); |
|
|
| |
| bot.onText(/\/kick/, async (msg) => { |
| const chatId = msg.chat.id; |
|
|
| if (msg.reply_to_message) { |
| const userId = msg.reply_to_message.from.id; |
| const requesterId = msg.from.id; |
|
|
| if (await isAdmin(chatId, requesterId)) { |
| try { |
| await bot.kickChatMember(chatId, userId); |
| bot.sendMessage(chatId, "User has been kicked."); |
| |
| 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."); |
| } |
| }); |
|
|
| |
| |
| bot.onText(/\/mute/, async (msg) => { |
| const chatId = msg.chat.id; |
| const requesterId = msg.from.id; |
|
|
| |
| if (await isAdmin(chatId, requesterId)) { |
| if (msg.reply_to_message) { |
| const userId = msg.reply_to_message.from.id; |
| 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."); |
| } |
| }); |
|
|
| |
| 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 }; |
| } |
| } |
|
|
| |
| bot.onText(/\/anime (.+)/, async (msg, match) => { |
| const chatId = msg.chat.id; |
| const animeName = match[1]; |
|
|
| const { info, imageUrl } = await getAnimeInfo(animeName); |
|
|
| |
| bot.sendMessage(chatId, info, { parse_mode: 'Markdown' }); |
|
|
| |
| if (imageUrl) { |
| bot.sendPhoto(chatId, imageUrl); |
| } |
| }); |
|
|
|
|
|
|
| |
| bot.onText(/\/unmute/, (msg) => { |
| const chatId = msg.chat.id; |
| if (msg.reply_to_message) { |
| const userId = msg.reply_to_message.from.id; |
| mutedUsers.delete(userId); |
| bot.sendMessage(chatId, `User has been unmuted.`); |
| } else { |
| bot.sendMessage(chatId, "Please reply to a user's message to unmute them."); |
| } |
| }); |
|
|
| |
| bot.onText(/\/promote/, async (msg) => { |
| const chatId = msg.chat.id; |
| if (msg.reply_to_message) { |
| const userId = msg.reply_to_message.from.id; |
| 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."); |
| } |
| }); |
|
|
| |
| bot.onText(/\/demote/, async (msg) => { |
| const chatId = msg.chat.id; |
| if (msg.reply_to_message) { |
| const userId = msg.reply_to_message.from.id; |
| 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."); |
| } |
| }); |
|
|
| |
| 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."); |
| } |
| }); |
|
|
| |
| 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.'); |
| } |
| }); |
|
|
| |
| 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.'); |
| } |
| }); |
|
|
|
|
|
|
|
|
| |
| 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 { |
| |
| const encodedText = encodeURIComponent(inputText); |
| const pdfUrl = `https://bk9.fun/tools/pdf?q=${encodedText}`; |
|
|
| |
| const response = await axios({ |
| method: "GET", |
| url: pdfUrl, |
| responseType: "stream", |
| }); |
|
|
| |
| const fileName = `document_${Date.now()}.pdf`; |
| const filePath = `./${fileName}`; |
|
|
| |
| const writer = require("fs").createWriteStream(filePath); |
| response.data.pipe(writer); |
|
|
| writer.on("finish", async () => { |
| |
| await bot.sendDocument(chatId, filePath, { |
| caption: `โ
Your PDF file has been generated successfully!\n*แดแดแดกแดสแดแด
สส แด
แดแด ษชแด
แดสสษชส แดแดแดส*`, |
| parse_mode: "Markdown", |
| }); |
|
|
| |
| 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 { |
| |
| const apiUrl = `https://api.agatz.xyz/api/xvideo?message=${encodeURIComponent(query)}`; |
| const response = await axios.get(apiUrl); |
| const result = response.data; |
|
|
| |
| if (result.status === 200 && result.data.length > 0) { |
| const videoInfo = result.data[0]; |
|
|
| |
| const body = `๐ฅ *Video Search Result:*\n\n` + |
| `๐ค *Title:* ${videoInfo.title}\n` + |
| `โฑ๏ธ *Duration:* ${videoInfo.duration}\n\nแดแดแดกแดสแดแด
สส แด
แดแด ษชแด
แดสสษชส แดแดแดส`; |
|
|
| |
| const options = { |
| parse_mode: "Markdown", |
| reply_markup: { |
| inline_keyboard: [ |
| [ |
| { |
| text: "๐ Watch Video", |
| url: videoInfo.url, |
| }, |
| ], |
| ], |
| }, |
| }; |
|
|
| |
| 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."); |
| } |
| }); |
|
|
| |
| 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."); |
| } |
| }); |
|
|
| |
| bot.onText(/\/support/, (msg) => { |
| const chatId = msg.chat.id; |
| const response = "9066528353 OPAY ๐ณ๐ฌ\nPlease support Developer."; |
|
|
| |
| bot.sendMessage(chatId, response); |
| }); |
|
|
| |
| bot.onText(/\/owner/, (msg) => { |
| const chatId = msg.chat.id; |
| const response = "@deecee_x"; |
|
|
| |
| bot.sendMessage(chatId, response); |
| }); |
|
|
| |
| 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; |
| } |
|
|
| |
| 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.'); |
| }); |
| }); |
|
|
| |
| 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."); |
| } |
| }); |
|
|
| |
| 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.`); |
| }); |
|
|
| |
| bot.on('message', (msg) => { |
| const chatId = msg.chat.id; |
|
|
| |
| 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:"); |
| }); |
| } |
| }); |
| } |
|
|
| |
| 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]; |
|
|
| |
| if (!prompt) { |
| return bot.sendMessage(chatId, "โ *Please provide a prompt!* \n\nUsage: `/magicstudio <prompt>`", { parse_mode: "Markdown" }); |
| } |
|
|
| try { |
| |
| await bot.sendMessage(chatId, "โจ *Generating image... Please wait!*", { parse_mode: "Markdown" }); |
|
|
| |
| const apiUrl = `https://bk9.fun/ai/magicstudio?prompt=${encodeURIComponent(prompt)}`; |
|
|
| |
| const response = await axios.get(apiUrl, { responseType: "stream" }); |
|
|
| |
| 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]; |
|
|
| if (!prompt) { |
| |
| 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 { |
| |
| const apiUrl = `https://apis.davidcyriltech.my.id/flux?prompt=${encodeURIComponent(prompt)}`; |
| |
| |
| 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"); |
|
|
| 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..."); |
|
|
| |
| 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); |
| }); |
|
|
| |
| 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); |
|
|
| |
| const enhanceUrl = `https://bk9.fun/tools/enhance?url=${encodeURIComponent(imageUrl)}`; |
| console.log("Enhancement API URL:", enhanceUrl); |
|
|
| |
| await bot.sendPhoto(chatId, enhanceUrl, { |
| caption: "โจ *Image Enhanced Successfully!*", |
| parse_mode: "Markdown", |
| }); |
|
|
| fs.unlinkSync(localFilePath); |
| } catch (error) { |
| console.error("Error enhancing image:"); |
| bot.sendMessage(chatId, `โ Error`); |
| } |
| } |
| }); |
| |
| 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."); |
| } |
| }); |
| |
| bot.onText(/\/delete/, async (msg) => { |
| const chatId = msg.chat.id; |
|
|
| if (msg.reply_to_message) { |
| const messageId = msg.reply_to_message.message_id; |
|
|
| try { |
| |
| await bot.deleteMessage(chatId, messageId); |
| |
| await bot.deleteMessage(chatId, msg.message_id); |
|
|
| |
| 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 }); |
| } |
| }); |
|
|
| |
| bot.onText(/\/help/, (msg) => { |
| const chatId = msg.chat.id; |
| bot.sendMessage(chatId, "Hi I Am Atomic! Use /start for available commands."); |
| }); |
|
|
| |
| const startTime = Date.now(); |
|
|
| |
| bot.onText(/\/runtime/, (msg) => { |
| const chatId = msg.chat.id; |
| |
| |
| 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; |
|
|
| |
| bot.sendMessage(chatId, `The bot has been running for ${hours} hours, ${minutes} minutes, and ${seconds} seconds.`); |
| }); |
|
|
| |
| bot.onText(/\/ping/, (msg) => { |
| const chatId = msg.chat.id; |
| const start = Date.now(); |
|
|
| bot.sendMessage(chatId, 'Pong!').then(() => { |
| const end = Date.now(); |
| const ping = end - start; |
| bot.sendMessage(chatId, `Response time: ${ping} ms`); |
| }); |
| }); |
|
|
| |
| bot.onText(/\/start/, (msg) => { |
| const chatId = msg.chat.id; |
|
|
| |
| const helpMessageDownload = ` |
| *๐ฅ ATOMIC BOT MENU ๐ฅ* |
| |
| โฌ๏ธ *Download Commands*: |
| - ๐ถ /play <song name>: Download and play music from YouTube. |
| - ๐ถ /song <song name>: Download and play music from Spotify. |
| - ๐ฅ /tiktok <link>: Download TikTok videos. |
| - ๐ธ /instagram <link>: Download Instagram media. |
| - ๐ /fb <link>: Download Facebook videos. |
| - ๐ฅ /video <song name>: Download Music Videos. |
| - ๐ถ /ytmp3 <link>: Download Music Videos. |
| - ๐ฅ /ytmp4 <link>: Download and play music. |
| - ๐ฆ /mediafire <link>: Downloads MediaFire Files |
| - ๐ฆ /apk <app name>: Downloads Apk. |
| - ๐ฆ /gitclone <llnk>: Downloads files from github |
| - ๐ฌ /movie <movie name>: Downloads movies. |
| - ๐ฌ /twitter <link>: Downloads twitter videos. |
| `; |
|
|
| bot.sendMessage(chatId, helpMessageDownload, { |
| parse_mode: 'Markdown', |
| reply_markup: { |
| inline_keyboard: [ |
| [{ text: "โก๏ธ NEXT", callback_data: "help_next_1" }] |
| ] |
| } |
| }); |
| }); |
|
|
| |
| bot.on('callback_query', (query) => { |
| const chatId = query.message.chat.id; |
|
|
| |
| if (query.data === "help_next_1") { |
| const helpMessageAdmin = `๐ค *AI Commands*: |
| - ๐ค /chatbot <on / off>: Interact with ai models without using any prefix |
| - ๐ค /gpt <query>: Get an AI-powered response. |
| - ๐ /text2speech <text>: Convert text to speech. |
| - ๐ช /text2image <prompt>: Generates Any Ai Image of your choice. |
| - ๐ช /flux <prompt>: 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" } |
| ] |
| ] |
| } |
| }); |
| } |
|
|
| |
| 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 <new name>: Change the group name. |
| - ๐ /getlink: Get the group invite link. |
| - ๐ซ /antilink: Toggle anti-link feature. |
| - ๐ผ๏ธ /setgrouppic: Change the group picture. |
| - โ๏ธ /setdescription <text>: 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" } |
| ] |
| ] |
| } |
| }); |
| } |
|
|
| |
| if (query.data === "help_next_3") { |
| const helpMessageTools = ` |
| ๐ง *Special Menu*: |
| - ๐ฅต /xvideosearch: <query> searches for adult videos |
| - ๐ /xvideodownload: <link> 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_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" } |
| ] |
| ] |
| } |
| }); |
| } |
|
|
| |
| if (query.data === "help_next_5") { |
| const helpMessageUtility = ` |
| ๐ *Utility Commands*: |
| - โณ /runtime: Check the bot's uptime. |
| - ๐ /ping: Check bot's response time. |
| - ๐ธ /currency <amount> <from> to <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" } |
| ] |
| ] |
| } |
| }); |
| } |
|
|
| |
| 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" } |
| ] |
| ] |
| } |
| }); |
| } |
|
|
| |
| 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 <new name>: Change the group name. |
| - ๐ /getlink: Get the group invite link. |
| - ๐ซ /antilink: Toggle anti-link feature. |
| - ๐ผ๏ธ /setgrouppic: Change the group picture. |
| - โ๏ธ /setdescription <text>: 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 <query>: Answers any question. |
| - ๐ /text2speech <text>: Convert text to speech. (coming soon) |
| - ๐ /text2speech <text>: Convert text to speech. |
| - ๐ช /text2image <prompt>: Generates Any Ai Image of your choice. |
| - ๐ช /flux <prompt>: 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: <query> searches for adult videos |
| - ๐ /xvideodownload: <link> 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 <amount> <from> to <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" } |
| ] |
| ] |
| } |
| }); |
| } |
| }); |