|
|
|
|
|
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.get('/', (req, res) => { |
|
|
res.send(` |
|
|
<html> |
|
|
<head> |
|
|
<title>Bot Status</title> |
|
|
</head> |
|
|
<body style="text-align: center; margin-top: 50px; font-family: Arial, sans-serif;"> |
|
|
<h1 style="color: green;">✅ Connected to Telegram</h1> |
|
|
<p>Your bot is up and running!</p> |
|
|
</body> |
|
|
</html> |
|
|
`); |
|
|
}); |
|
|
|
|
|
|
|
|
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; |
|
|
const filePath = `./temp/${title.replace(/[^\w\s]/gi, '')}.mp4`; |
|
|
|
|
|
|
|
|
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" |
|
|
}); |
|
|
|
|
|
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."); |
|
|
} |
|
|
}); |
|
|
|
|
|
|
|
|
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 { |
|
|
|
|
|
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; |
|
|
const filename = `./${video.title.replace(/[^a-zA-Z0-9]/g, "_")}.mp3`; |
|
|
|
|
|
|
|
|
await bot.sendPhoto(chatId, thumbnail, { |
|
|
caption: `🎶 *Music Player* 🎶\n\n` + |
|
|
`🎵 *Title:* ${video.title}\n` + |
|
|
`🔗 [Watch on YouTube](${video.url})\n\n*ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ*`, |
|
|
parse_mode: "Markdown", |
|
|
}); |
|
|
|
|
|
|
|
|
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); |
|
|
}); |
|
|
|
|
|
|
|
|
await bot.sendAudio(chatId, filename, { |
|
|
caption: `🎧 *Here's your song:*\n🎵 *Title:* ${video.title}\n\n*ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ*`, |
|
|
parse_mode: "Markdown", |
|
|
}); |
|
|
|
|
|
|
|
|
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 <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; |
|
|
const filename = `./temp/${Date.now()}.mp3`; |
|
|
|
|
|
|
|
|
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); |
|
|
}); |
|
|
} 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 = {}; |
|
|
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(/\/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; |
|
|
const filename = `./temp/${Date.now()}.mp4`; |
|
|
|
|
|
|
|
|
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); |
|
|
}); |
|
|
} 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"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function getDirectPixelDrainLink(fileUrl) { |
|
|
try { |
|
|
const response = await axios.get(fileUrl, { maxRedirects: 0, validateStatus: (status) => status < 400 }); |
|
|
return response.headers.location || fileUrl; |
|
|
} catch (error) { |
|
|
console.error("Error validating PixelDrain link:"); |
|
|
throw new Error("Invalid or inaccessible PixelDrain link."); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
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."); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
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 <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" } |
|
|
] |
|
|
] |
|
|
} |
|
|
}); |
|
|
} |
|
|
}); |