DeeCeeXxx commited on
Commit
deef7da
·
verified ·
1 Parent(s): d35f627

Upload 9 files

Browse files
Files changed (9) hide show
  1. .gitattributes +1 -0
  2. Atomic.zip +3 -0
  3. Image/0.jpg +3 -0
  4. Image/DC.js +1 -0
  5. Procfile +1 -0
  6. app.json +16 -0
  7. app.json.bak +16 -0
  8. bot.js +2645 -0
  9. package.json +17 -85
.gitattributes CHANGED
@@ -36,3 +36,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
36
  davidcyrilapis-main/public/docs/background-music.mp3 filter=lfs diff=lfs merge=lfs -text
37
  public/docs/background-music.mp3 filter=lfs diff=lfs merge=lfs -text
38
  thumb.png filter=lfs diff=lfs merge=lfs -text
 
 
36
  davidcyrilapis-main/public/docs/background-music.mp3 filter=lfs diff=lfs merge=lfs -text
37
  public/docs/background-music.mp3 filter=lfs diff=lfs merge=lfs -text
38
  thumb.png filter=lfs diff=lfs merge=lfs -text
39
+ Image/0.jpg filter=lfs diff=lfs merge=lfs -text
Atomic.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:57ce84da49fc5ad268ec599708fda8329714bf769da6c6442292f49426a15c48
3
+ size 258276
Image/0.jpg ADDED

Git LFS Details

  • SHA256: 39f12f09d5074e1718a83e552760a15f0e411d13388e5e126da0c60921d01d51
  • Pointer size: 131 Bytes
  • Size of remote file: 134 kB
Image/DC.js ADDED
@@ -0,0 +1 @@
 
 
1
+
Procfile ADDED
@@ -0,0 +1 @@
 
 
1
+ web: node bot.js
app.json ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "Atomic",
3
+ "description": "A WhatsApp Bot Created By David Cyril",
4
+ "logo": "https://telegra.ph/file/f6230a0cb5b118fa01561.jpg",
5
+ "keywords": ["bot", "WhatsApp", "JavaScript"],
6
+ "success_url": "/",
7
+ "stack": "heroku-24",
8
+ "buildpacks": [
9
+ {
10
+ "url": "https://github.com/heroku/heroku-buildpack-nodejs.git"
11
+ }
12
+ ],
13
+ "scripts": {
14
+ "postdeploy": "node index.js"
15
+ }
16
+ }
app.json.bak ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "Queen Anita V4",
3
+ "description": "A WhatsApp Bot Created By David Cyril",
4
+ "logo": "https://telegra.ph/file/f6230a0cb5b118fa01561.jpg",
5
+ "keywords": ["bot", "WhatsApp", "JavaScript"],
6
+ "success_url": "/",
7
+ "stack": "heroku-24",
8
+ "buildpacks": [
9
+ {
10
+ "url": "https://github.com/heroku/heroku-buildpack-nodejs.git"
11
+ }
12
+ ],
13
+ "scripts": {
14
+ "postdeploy": "node index.js"
15
+ }
16
+ }
bot.js ADDED
@@ -0,0 +1,2645 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Import necessary modules
2
+ const express = require('express');
3
+ const { sinhalaSub } = require("mrnima-moviedl");
4
+
5
+ const FormData = require('form-data');
6
+
7
+ const { catbox } = require('./catbox'); // Import the Catbox uploader
8
+
9
+
10
+ const { exec } = require("child_process");
11
+
12
+
13
+ const yts = require('yt-search'); //
14
+ // Initialize Express app for HTTP server
15
+ const app = express();
16
+ const PORT = process.env.PORT || 3000;
17
+
18
+ // Basic HTML response for health check
19
+ app.get('/', (req, res) => {
20
+ res.send(`
21
+ <html>
22
+ <head>
23
+ <title>Bot Status</title>
24
+ </head>
25
+ <body style="text-align: center; margin-top: 50px; font-family: Arial, sans-serif;">
26
+ <h1 style="color: green;">✅ Connected to Telegram</h1>
27
+ <p>Your bot is up and running!</p>
28
+ </body>
29
+ </html>
30
+ `);
31
+ });
32
+
33
+ // Start the HTTP server
34
+ app.listen(PORT, () => {
35
+ console.log(`Server is running on http://localhost:${PORT}`);
36
+ });
37
+
38
+
39
+ //
40
+ const TelegramBot =
41
+ require('node-telegram-bot-api');
42
+ const axios = require('axios');
43
+ const fs = require('fs');
44
+ const apiKey = '7398508893:AAFqoZK_n0FNZ5I9_5L4BpyDSh3YvatZ3B8';
45
+ // Replace 'YOUR_TELEGRAM_BOT_TOKEN' with your bot token
46
+ const bot = new TelegramBot('7398508893:AAFE6xOytstrMZ0PpRa3ieH6SLBy9TR9vq4', { polling: true });
47
+
48
+ // Set up a list for tracking muted users
49
+ const mutedUsers = new Set();
50
+
51
+ // Anti-link feature variable
52
+ let antiLinkActive = false;
53
+
54
+ // Check if user is admin
55
+ const isAdmin = async (chatId, userId) => {
56
+ try {
57
+ const member = await bot.getChatMember(chatId, userId);
58
+ return member.status === 'administrator' || member.status === 'creator';
59
+ } catch (error) {
60
+ return false;
61
+ }
62
+ };
63
+
64
+
65
+
66
+
67
+
68
+ // /tiktok command
69
+ bot.onText(/\/(tiktok|tt|ttmedia)(?: (.+))?/, async (msg, match) => {
70
+ const chatId = msg.chat.id;
71
+ const text = match[2]; // Extract the TikTok link from the command
72
+
73
+ if (!text) {
74
+ // If no TikTok link is provided, send a usage guide
75
+ return bot.sendMessage(chatId, "❌ Please provide a TikTok link.\nExample: `/tiktok https://www.tiktok.com/@username/video/1234567890`");
76
+ }
77
+
78
+ bot.sendMessage(chatId, "🔄 Fetching your TikTok media... Please wait.");
79
+
80
+ try {
81
+ // Fetch TikTok media using the external API
82
+ const response = await axios.get(`https://api.paxsenix.biz.id/dl/tiktok?url=${encodeURIComponent(text)}`);
83
+ const data = response.data;
84
+
85
+ if (data && data.downloadsUrl) {
86
+ // Send the video
87
+ await bot.sendVideo(chatId, data.downloadsUrl.video);
88
+
89
+ // Send the audio
90
+ await bot.sendAudio(chatId, data.downloadsUrl.music);
91
+ } else {
92
+ bot.sendMessage(chatId, "❌ Unable to fetch TikTok media. Please check the link and try again.");
93
+ }
94
+ } catch (error) {
95
+ console.error("Error during TikTok download command:");
96
+ bot.sendMessage(chatId, "❌ An error occurred while processing your request. Please try again later.");
97
+ }
98
+ });
99
+
100
+
101
+ bot.onText(/\/couplepp/, async (msg) => {
102
+ const chatId = msg.chat.id;
103
+
104
+ try {
105
+ // Inform the user that the bot is fetching the pictures
106
+ await bot.sendMessage(chatId, "🔍 *Fetching couple profile pictures...*", { parse_mode: "Markdown" });
107
+
108
+ // Fetch the data from the API
109
+ const apiUrl = "https://api.maskser.me/api/randomgambar/couplepp";
110
+ const response = await axios.get(apiUrl);
111
+
112
+ if (response.data.status) {
113
+ const { male, female } = response.data.result;
114
+
115
+ // Send the male picture
116
+ await bot.sendPhoto(chatId, male, {
117
+ caption: "👦 *Male Picture*",
118
+ parse_mode: "Markdown"
119
+ });
120
+
121
+ // Send the female picture
122
+ await bot.sendPhoto(chatId, female, {
123
+ caption: "👧 *Female Picture*",
124
+ parse_mode: "Markdown"
125
+ });
126
+ } else {
127
+ bot.sendMessage(chatId, "❌ Failed to fetch couple pictures. Please try again later.");
128
+ }
129
+ } catch (error) {
130
+ console.error("Error fetching couple pictures:");
131
+ bot.sendMessage(chatId, "❌ An error occurred while fetching couple pictures. Please try again.");
132
+ }
133
+ });
134
+
135
+
136
+ // Handle /gpt command
137
+ bot.onText(/\/gpt (.+)/, async (msg, match) => {
138
+ const chatId = msg.chat.id;
139
+ const query = match[1]?.trim();
140
+
141
+ if (!query) {
142
+ return bot.sendMessage(chatId, "❌ Please provide a prompt after the /gpt command.\nExample: `/gpt What is AI?`", {
143
+ parse_mode: "Markdown",
144
+ });
145
+ }
146
+
147
+ try {
148
+ // Show typing indicator
149
+ await bot.sendChatAction(chatId, "typing");
150
+
151
+ // Make a request to the new GPT API
152
+ const apiUrl = `https://api.paxsenix.biz.id/ai/gpt4?text=${encodeURIComponent(query)}`;
153
+ const { data } = await axios.get(apiUrl);
154
+
155
+
156
+
157
+ // Check the API response
158
+ if (!data.ok || !data.message) {
159
+ return bot.sendMessage(chatId, `❌ GPT API Error: Unable to fetch a response. Please try again later.`);
160
+ }
161
+
162
+ // Send the GPT response to the user
163
+ await bot.sendMessage(chatId, `${data.message}`, { parse_mode: "Markdown" });
164
+ } catch (error) {
165
+ console.error("Error fetching GPT response:");
166
+ await bot.sendMessage(chatId, "❌ An error occurred while fetching the GPT response. Please try again later.");
167
+ }
168
+ });
169
+
170
+
171
+ bot.onText(/\/url/, async (msg) => {
172
+ const chatId = msg.chat.id;
173
+
174
+ // Check if the message is a reply to an image or video
175
+ const fileId = msg.reply_to_message?.photo?.[msg.reply_to_message.photo.length - 1]?.file_id ||
176
+ msg.reply_to_message?.video?.file_id;
177
+
178
+ if (!fileId) {
179
+ return bot.sendMessage(chatId, "❗ *Reply to an image or video with /url to get a public link.*", { parse_mode: "Markdown" });
180
+ }
181
+
182
+ try {
183
+ // React to indicate processing
184
+ const processingMsg = await bot.sendMessage(chatId, "⏳ *Uploading your file...*", { parse_mode: "Markdown" });
185
+
186
+ // Download the file locally
187
+ const filePath = await bot.downloadFile(fileId, "./downloads");
188
+
189
+ // Upload the file to Catbox
190
+ const uploadResponse = await catbox(filePath);
191
+
192
+ // Check and send the result
193
+ if (uploadResponse.url) {
194
+ await bot.sendMessage(chatId, `✅ *Upload Successful!*\n\n🔗 *URL:*\n${uploadResponse.url}\n\n*ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ*`, { parse_mode: "Markdown" });
195
+ } else {
196
+ await bot.sendMessage(chatId, "❌ *Upload Failed. Please try again.*", { parse_mode: "Markdown" });
197
+ }
198
+
199
+ // Clean up the downloaded file
200
+ fs.unlinkSync(filePath);
201
+ await bot.deleteMessage(chatId, processingMsg.message_id);
202
+ } catch (error) {
203
+ console.error("Error in /url command:");
204
+ bot.sendMessage(chatId, `❌ *An error occurred`, { parse_mode: "Markdown" });
205
+ }
206
+ });
207
+
208
+
209
+
210
+ bot.onText(/\/remini/, async (msg) => {
211
+ const chatId = msg.chat.id;
212
+
213
+ // Check if the message is a reply to an image
214
+ const fileId = msg.reply_to_message?.photo?.[msg.reply_to_message.photo.length - 1]?.file_id;
215
+
216
+ if (!fileId) {
217
+ return bot.sendMessage(chatId, "❗ *Reply to an image with /remini to enhance it.*", { parse_mode: "Markdown" });
218
+ }
219
+
220
+ try {
221
+ // React to indicate processing
222
+ const processingMsg = await bot.sendMessage(chatId, "⏳ *Enhancing your image...*", { parse_mode: "Markdown" });
223
+
224
+ // Download the image locally
225
+ const filePath = await bot.downloadFile(fileId, "./downloads");
226
+
227
+ // Upload the image to Catbox
228
+ const uploadResponse = await catbox(filePath);
229
+
230
+ if (!uploadResponse.url) {
231
+ fs.unlinkSync(filePath); // Clean up the downloaded file
232
+ return bot.sendMessage(chatId, "❌ *Upload Failed. Please try again.*", { parse_mode: "Markdown" });
233
+ }
234
+
235
+ const imageUrl = uploadResponse.url; // Get the uploaded image URL
236
+
237
+ // Call the Remini API with the uploaded image URL
238
+ const enhancedImageUrl = `https://bk9.fun/tools/enhance?url=${encodeURIComponent(imageUrl)}`;
239
+
240
+ // Send the enhanced image back to the user
241
+ await bot.sendPhoto(chatId, enhancedImageUrl, {
242
+ caption: `✅ *Successfully Enhanced Your Image!*\n\n*ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ*`,
243
+ parse_mode: "Markdown",
244
+ });
245
+
246
+ // Clean up the downloaded file
247
+ fs.unlinkSync(filePath);
248
+ await bot.deleteMessage(chatId, processingMsg.message_id);
249
+ } catch (error) {
250
+ console.error("Error in /remini command:");
251
+ bot.sendMessage(chatId, `❌ *An error occurred`, { parse_mode: "Markdown" });
252
+ }
253
+ });
254
+
255
+
256
+
257
+
258
+
259
+ bot.onText(/\/video (.+)/, async (msg, match) => {
260
+ const chatId = msg.chat.id;
261
+ const query = match[1]?.trim();
262
+
263
+ if (!query) {
264
+ return bot.sendMessage(chatId, "❗ *Usage*: `/video <search term>`", { parse_mode: 'Markdown' });
265
+ }
266
+
267
+ try {
268
+ const searchMsg = await bot.sendMessage(chatId, "🔍 *Searching for your video...*", { parse_mode: "Markdown" });
269
+
270
+ // Step 1: Search for the video
271
+ const search = await yts(query);
272
+ const video = search.all[0]; // Take the first result
273
+ if (!video) {
274
+ return bot.sendMessage(chatId, "❌ Video not found!");
275
+ }
276
+
277
+ // Step 2: Fetch video download link from the API
278
+ const apiUrl = `https://apis.davidcyriltech.my.id/download/ytmp4`;
279
+ const response = await axios.get(apiUrl, { params: { url: video.url } });
280
+ const { success, result } = response.data;
281
+
282
+ if (success && result) {
283
+ const { title, download_url } = result;
284
+ const filePath = `./temp/${title.replace(/[^\w\s]/gi, '')}.mp4`;
285
+
286
+ // Step 3: Download video locally
287
+ const writer = fs.createWriteStream(filePath);
288
+ const videoStream = await axios({
289
+ url: download_url,
290
+ method: 'GET',
291
+ responseType: 'stream'
292
+ });
293
+
294
+ videoStream.data.pipe(writer);
295
+
296
+ await new Promise((resolve, reject) => {
297
+ writer.on('finish', resolve);
298
+ writer.on('error', reject);
299
+ });
300
+
301
+ // Step 4: Send the video from local storage
302
+ await bot.sendVideo(chatId, filePath, {
303
+ caption: `🎬 *Here is your video:*\n🎥 *${title}*\n\n*ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ*`,
304
+ parse_mode: "Markdown"
305
+ });
306
+
307
+ // Step 5: Delete the file after sending
308
+ fs.unlinkSync(filePath);
309
+ } else {
310
+ bot.sendMessage(chatId, "❌ Failed to fetch the video. Please try again.");
311
+ }
312
+
313
+ await bot.deleteMessage(chatId, searchMsg.message_id);
314
+ } catch (err) {
315
+ console.error("Error in /video command:", err);
316
+ bot.sendMessage(chatId, "❌ An error occurred while processing your request.");
317
+ }
318
+ });
319
+
320
+ // /play command
321
+ bot.onText(/\/play(?: (.+))?/, async (msg, match) => {
322
+ const chatId = msg.chat.id;
323
+ const inputText = match[1];
324
+
325
+ if (!inputText) {
326
+ return bot.sendMessage(chatId, "❌ Please provide the song name.\nExample: `/play Faded by Alan Walker`");
327
+ }
328
+
329
+ try {
330
+ // Notify user that the bot is searching
331
+ await bot.sendMessage(chatId, "🔍 Searching for your song...");
332
+
333
+ // Perform a YouTube search
334
+ const search = await yts(inputText);
335
+ const video = search.all[0];
336
+
337
+ if (!video) {
338
+ return bot.sendMessage(chatId, "❌ Sorry, I couldn't find the song. Try another keyword.");
339
+ }
340
+
341
+ // Fetch the song download link using the new API
342
+ const apiUrl = `https://apis.davidcyriltech.my.id/download/ytmp3?url=${encodeURIComponent(video.url)}`;
343
+ const response = await axios.get(apiUrl);
344
+ const { success, result } = response.data;
345
+
346
+ if (success && result) {
347
+ const { title, thumbnail, download_url } = result;
348
+ const filename = `./${video.title.replace(/[^a-zA-Z0-9]/g, "_")}.mp3`;
349
+
350
+ // Send song details with thumbnail
351
+ await bot.sendPhoto(chatId, thumbnail, {
352
+ caption: `🎶 *Music Player* 🎶\n\n` +
353
+ `🎵 *Title:* ${video.title}\n` +
354
+ `🔗 [Watch on YouTube](${video.url})\n\n*ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ*`,
355
+ parse_mode: "Markdown",
356
+ });
357
+
358
+ // Download the audio file
359
+ const writer = fs.createWriteStream(filename);
360
+ const { data } = await axios({
361
+ url: download_url,
362
+ method: "GET",
363
+ responseType: "stream",
364
+ });
365
+
366
+ data.pipe(writer);
367
+
368
+ await new Promise((resolve, reject) => {
369
+ writer.on("finish", resolve);
370
+ writer.on("error", reject);
371
+ });
372
+
373
+ // Send the locally saved audio file
374
+ await bot.sendAudio(chatId, filename, {
375
+ caption: `🎧 *Here's your song:*\n🎵 *Title:* ${video.title}\n\n*ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ*`,
376
+ parse_mode: "Markdown",
377
+ });
378
+
379
+ // Delete the file after sending
380
+ fs.unlink(filename, (err) => {
381
+ if (err) console.error("Error deleting file:", err);
382
+ });
383
+ } else {
384
+ bot.sendMessage(chatId, "❌ Unable to download the song. Please try again later.");
385
+ }
386
+ } catch (error) {
387
+ console.error("Error during /play command:", error);
388
+ bot.sendMessage(chatId, "❌ An error occurred while processing your request. Please try again later.");
389
+ }
390
+ });
391
+ bot.onText(/\/ytmp3 (.+)/, async (msg, match) => {
392
+ const chatId = msg.chat.id;
393
+ const youtubeLink = match[1]?.trim();
394
+
395
+ if (!youtubeLink) {
396
+ return bot.sendMessage(chatId, "❗ *Usage*: `/ytmp3 <YouTube link>`\nExample: `/ytmp3 https://youtube.com/watch?v=iI34LYmJ1Fs`", { parse_mode: 'Markdown' });
397
+ }
398
+
399
+ try {
400
+ const loadingMsg = await bot.sendMessage(chatId, "🔍 *Processing your audio...*", { parse_mode: "Markdown" });
401
+
402
+ // Fetch audio download link
403
+ const apiUrl = `https://apis.davidcyriltech.my.id/download/ytmp3`;
404
+ const response = await axios.get(apiUrl, { params: { url: youtubeLink } });
405
+ const { success, result } = response.data;
406
+
407
+ if (success && result) {
408
+ const { title, download_url } = result;
409
+ const filename = `./temp/${Date.now()}.mp3`;
410
+
411
+ // Download the audio locally
412
+ const audioResponse = await axios({
413
+ url: download_url,
414
+ method: "GET",
415
+ responseType: "stream",
416
+ });
417
+
418
+ const writer = fs.createWriteStream(filename);
419
+ audioResponse.data.pipe(writer);
420
+
421
+ writer.on("finish", async () => {
422
+ await bot.sendAudio(chatId, filename, {
423
+ caption: `🎧 *${title}*\n\n*ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ*`,
424
+ parse_mode: "Markdown",
425
+ });
426
+
427
+ fs.unlinkSync(filename); // Delete after sending
428
+ });
429
+ } else {
430
+ bot.sendMessage(chatId, "❌ Failed to fetch the audio. Please check the link and try again.");
431
+ }
432
+
433
+ await bot.deleteMessage(chatId, loadingMsg.message_id);
434
+ } catch (err) {
435
+ console.error("Error in /ytmp3 command:", err);
436
+ bot.sendMessage(chatId, "❌ An error occurred while processing your request.");
437
+ }
438
+ });
439
+
440
+ let chatbotActive = {}; // Stores active chatbot users
441
+ let conversationIds = {}; // Stores conversation ID for each user
442
+
443
+ bot.onText(/\/gitclone (.+)/, async (msg, match) => {
444
+ const chatId = msg.chat.id;
445
+ const repoUrl = match[1]?.trim();
446
+
447
+ if (!repoUrl) {
448
+ return bot.sendMessage(chatId, "❗ *Usage*: `/gitclone <GitHub Repo URL>`\nExample: `/gitclone https://github.com/DeeCeeXxx2/Queen_Anita-V3`", { parse_mode: 'Markdown' });
449
+ }
450
+
451
+ if (!repoUrl.includes("github.com")) {
452
+ return bot.sendMessage(chatId, "❌ *Invalid GitHub link! Please provide a valid URL.*");
453
+ }
454
+
455
+ try {
456
+ let regex = /(?:https|git)(?::\/\/|@)github\.com[\/:]([^\/:]+)\/(.+)/i;
457
+ let [, user, repo] = repoUrl.match(regex) || [];
458
+ repo = repo.replace(/.git$/, "");
459
+ let zipUrl = `https://api.github.com/repos/${user}/${repo}/zipball`;
460
+
461
+ // Fetch file name from GitHub API
462
+ let response = await fetch(zipUrl, { method: "HEAD" });
463
+ let filename = response.headers.get("content-disposition").match(/attachment; filename=(.*)/)[1];
464
+
465
+ await bot.sendDocument(chatId, zipUrl, {
466
+ caption: `📦 *Repository:* ${repo}\n🔗 *Download Link:* [Click Here](${zipUrl})\n\n*ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ*`,
467
+ parse_mode: "Markdown",
468
+ fileName: filename + ".zip",
469
+ mimetype: "application/zip"
470
+ });
471
+ } catch (err) {
472
+ console.error("Error in /gitclone command:", err);
473
+ bot.sendMessage(chatId, "❌ *An error occurred while fetching the repository. Please try again later.*");
474
+ }
475
+ });
476
+
477
+ bot.onText(/\/chatbot$/, async (msg) => {
478
+ const chatId = msg.chat.id;
479
+
480
+ await bot.sendMessage(
481
+ chatId,
482
+ "❗ *Invalid Command!*\n\nUse:\n✅ `/chatbot on` - To activate AI chat\n❌ `/chatbot off` - To deactivate AI chat",
483
+ { parse_mode: "Markdown" }
484
+ );
485
+ });
486
+
487
+
488
+
489
+
490
+
491
+
492
+ bot.onText(/\/mediafire (.+)/, async (msg, match) => {
493
+ const chatId = msg.chat.id;
494
+ const mediafireUrl = match[1]?.trim();
495
+
496
+ if (!mediafireUrl) {
497
+ return bot.sendMessage(chatId, "❗ *Usage*: `/mediafire <MediaFire Link>`\nExample: `/mediafire https://www.mediafire.com/file/n6tgcrktbnov1oy/Queen_Anita-V4.zip/file`", { parse_mode: 'Markdown' });
498
+ }
499
+
500
+ try {
501
+ const loadingMsg = await bot.sendMessage(chatId, "📥 *Fetching file details...*", { parse_mode: "Markdown" });
502
+
503
+ const apiUrl = `https://apis.davidcyriltech.my.id/mediafire?url=${encodeURIComponent(mediafireUrl)}`;
504
+ const response = await axios.get(apiUrl);
505
+ const { success, result } = response.data;
506
+
507
+ if (success && result) {
508
+ const { fileName, downloadLink } = result;
509
+ const filePath = path.join(__dirname, "temp", fileName.replace(/[^\w\s]/gi, "_"));
510
+
511
+ // Step 1: Download the file locally
512
+ const writer = fs.createWriteStream(filePath);
513
+ const fileResponse = await axios({
514
+ url: downloadLink,
515
+ method: "GET",
516
+ responseType: "stream",
517
+ });
518
+
519
+ fileResponse.data.pipe(writer);
520
+
521
+ await new Promise((resolve, reject) => {
522
+ writer.on("finish", resolve);
523
+ writer.on("error", reject);
524
+ });
525
+
526
+ // Step 2: Send the file
527
+ await bot.sendDocument(chatId, filePath, {
528
+ caption: `📦 *File Name:* ${fileName}\n\n*ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ*`,
529
+ parse_mode: "Markdown",
530
+ });
531
+
532
+ // Step 3: Delete the file after sending
533
+ fs.unlinkSync(filePath);
534
+ } else {
535
+ bot.sendMessage(chatId, "❌ *Failed to fetch file details! Please check the MediaFire URL and try again.*");
536
+ }
537
+
538
+ await bot.deleteMessage(chatId, loadingMsg.message_id);
539
+ } catch (error) {
540
+ console.error("Error in /mediafire command:", error);
541
+ bot.sendMessage(chatId, "❌ *An error occurred while processing your request. Please try again later.*");
542
+ }
543
+ });
544
+
545
+ bot.onText(/\/ss (.+)/, async (msg, match) => {
546
+ const chatId = msg.chat.id;
547
+ const websiteUrl = match[1]?.trim();
548
+
549
+ if (!websiteUrl) {
550
+ return bot.sendMessage(chatId, "❗ *Usage*: `/ssweb <Website URL>`\nExample: `/ssweb https://example.com`", { parse_mode: 'Markdown' });
551
+ }
552
+
553
+ try {
554
+ const loadingMsg = await bot.sendMessage(chatId, "📸 *Capturing screenshot...*", { parse_mode: "Markdown" });
555
+
556
+ const apiUrl = `https://apis.davidcyriltech.my.id/ssweb?url=${encodeURIComponent(websiteUrl)}`;
557
+ await bot.sendPhoto(chatId, apiUrl, {
558
+ caption: `🖼️ *Screenshot of:* ${websiteUrl}`,
559
+ parse_mode: "Markdown"
560
+ });
561
+
562
+ await bot.deleteMessage(chatId, loadingMsg.message_id);
563
+ } catch (error) {
564
+ console.error("Error in /ssweb command:", error);
565
+ bot.sendMessage(chatId, "❌ *Failed to capture the screenshot. Please try again later.*");
566
+ }
567
+ });
568
+
569
+ bot.onText(/\/ytmp4 (.+)/, async (msg, match) => {
570
+ const chatId = msg.chat.id;
571
+ const youtubeLink = match[1]?.trim();
572
+
573
+ if (!youtubeLink) {
574
+ return bot.sendMessage(chatId, "❗ *Usage*: `/ytmp4 <YouTube link>`\nExample: `/ytmp4 https://youtube.com/watch?v=iI34LYmJ1Fs`", { parse_mode: 'Markdown' });
575
+ }
576
+
577
+ try {
578
+ const loadingMsg = await bot.sendMessage(chatId, "🔍 *Processing your video...*", { parse_mode: "Markdown" });
579
+
580
+ // Fetch video download link
581
+ const apiUrl = `https://apis.davidcyriltech.my.id/download/ytmp4`;
582
+ const response = await axios.get(apiUrl, { params: { url: youtubeLink } });
583
+ const { success, result } = response.data;
584
+
585
+ if (success && result) {
586
+ const { title, download_url } = result;
587
+ const filename = `./temp/${Date.now()}.mp4`;
588
+
589
+ // Download the video locally
590
+ const videoResponse = await axios({
591
+ url: download_url,
592
+ method: "GET",
593
+ responseType: "stream",
594
+ });
595
+
596
+ const writer = fs.createWriteStream(filename);
597
+ videoResponse.data.pipe(writer);
598
+
599
+ writer.on("finish", async () => {
600
+ await bot.sendVideo(chatId, filename, {
601
+ caption: `🎬 *${title}*\n\n*ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ*`,
602
+ parse_mode: "Markdown",
603
+ });
604
+
605
+ fs.unlinkSync(filename); // Delete after sending
606
+ });
607
+ } else {
608
+ bot.sendMessage(chatId, "❌ Failed to fetch the video. Please check the link and try again.");
609
+ }
610
+
611
+ await bot.deleteMessage(chatId, loadingMsg.message_id);
612
+ } catch (err) {
613
+ console.error("Error in /ytmp4 command:", err);
614
+ bot.sendMessage(chatId, "❌ An error occurred while processing your request.");
615
+ }
616
+ });
617
+
618
+
619
+ const path = require("path");
620
+
621
+
622
+
623
+ // Utility: Validate and fetch direct PixelDrain link
624
+ async function getDirectPixelDrainLink(fileUrl) {
625
+ try {
626
+ const response = await axios.get(fileUrl, { maxRedirects: 0, validateStatus: (status) => status < 400 });
627
+ return response.headers.location || fileUrl; // Return direct link
628
+ } catch (error) {
629
+ console.error("Error validating PixelDrain link:");
630
+ throw new Error("Invalid or inaccessible PixelDrain link.");
631
+ }
632
+ }
633
+
634
+ // Utility: Download file from PixelDrain and save it locally
635
+ async function downloadFile(fileUrl, downloadPath) {
636
+ try {
637
+ const response = await axios({
638
+ url: fileUrl,
639
+ method: "GET",
640
+ responseType: "stream",
641
+ });
642
+
643
+ const writer = fs.createWriteStream(downloadPath);
644
+ response.data.pipe(writer);
645
+
646
+ return new Promise((resolve, reject) => {
647
+ writer.on("finish", () => {
648
+ console.log(`File downloaded to: ${downloadPath}`);
649
+ resolve();
650
+ });
651
+ writer.on("error", (err) => {
652
+ console.error("Download error:");
653
+ reject(err);
654
+ });
655
+ });
656
+ } catch (error) {
657
+ console.error("Error downloading file:", );
658
+ throw new Error("Failed to download file.");
659
+ }
660
+ }
661
+
662
+ // Utility: Stream file directly to Telegram
663
+ async function streamFileToTelegram(chatId, filePath, caption) {
664
+ try {
665
+ await bot.sendDocument(chatId, filePath, { caption: caption });
666
+ console.log("File streamed successfully to Telegram.");
667
+ } catch (error) {
668
+ console.error("Error streaming file:");
669
+ throw new Error("Failed to stream file to Telegram.");
670
+ }
671
+ }
672
+
673
+ bot.onText(/\/bible (.+)/, async (msg, match) => {
674
+ const chatId = msg.chat.id;
675
+ const chapterInput = match[1]?.trim();
676
+
677
+ if (!chapterInput) {
678
+ return bot.sendMessage(
679
+ chatId,
680
+ "❗ *Usage*: `/bible <chapter and verse>`\nExample: `/bible john 3:16`",
681
+ { parse_mode: "Markdown" }
682
+ );
683
+ }
684
+
685
+ const BASE_URL = "https://bible-api.com";
686
+
687
+ try {
688
+ // Fetch the chapter data from the Bible API
689
+ const response = await axios.get(`${BASE_URL}/${encodeURIComponent(chapterInput)}`);
690
+ if (!response.data) {
691
+ throw new Error("Failed to fetch the Bible chapter. Please check the input and try again.");
692
+ }
693
+
694
+ const chapterData = response.data;
695
+
696
+ // Format the Bible chapter message
697
+ const bibleChapter = `
698
+ 📖 *The Holy Bible*\n
699
+ 📜 *Chapter:* ${chapterData.reference}\n
700
+ 📚 *Translation:* ${chapterData.translation_name}\n
701
+ 📖 *Number of Verses:* ${chapterData.verses.length}\n
702
+ 🔮 *Chapter Content:*\n${chapterData.text}
703
+ `;
704
+
705
+ // Send the formatted message with an image
706
+ await bot.sendPhoto(chatId, "./atomic.jpg", {
707
+ caption: bibleChapter,
708
+ parse_mode: "Markdown",
709
+ });
710
+ } catch (error) {
711
+ console.error("Error in /bible command:");
712
+ bot.sendMessage(chatId, `❌ Error: `);
713
+ }
714
+ });
715
+
716
+
717
+ bot.onText(/\/text2image (.+)/, async (msg, match) => {
718
+ const chatId = msg.chat.id;
719
+ const prompt = match[1]; // Extract the prompt from the command
720
+
721
+ // Check if the user provided a prompt
722
+ if (!prompt) {
723
+ return bot.sendMessage(chatId, "❌ *Please provide a prompt!* \n\nUsage: `/magicstudio <prompt>`", { parse_mode: "Markdown" });
724
+ }
725
+
726
+ try {
727
+ // Inform the user the process has started
728
+ await bot.sendMessage(chatId, "✨ *Generating image... Please wait!*", { parse_mode: "Markdown" });
729
+
730
+ // API URL to generate the image
731
+ const apiUrl = `https://bk9.fun/ai/magicstudio?prompt=${encodeURIComponent(prompt)}`;
732
+
733
+ // Fetch the generated image from the API
734
+ const response = await axios.get(apiUrl, { responseType: "stream" });
735
+
736
+ // Send the image back to the user
737
+ await bot.sendPhoto(chatId, response.data, {
738
+ caption: `🖼️ *Here's your generated image for:* \`${prompt}\`\n\n*ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ*`,
739
+ parse_mode: "Markdown"
740
+ });
741
+
742
+ } catch (error) {
743
+ console.error("Error generating image:");
744
+ bot.sendMessage(chatId, "❌ *Failed to generate the image. Please try again later!*", { parse_mode: "Markdown" });
745
+ }
746
+ });
747
+ // /apk command
748
+ bot.onText(/\/apk (.+)/, async (msg, match) => {
749
+ const chatId = msg.chat.id;
750
+ const packageName = match[1]?.trim();
751
+
752
+ if (!packageName) {
753
+ return bot.sendMessage(chatId, "❗ *Usage*: `/apk <package_name>`\nExample: `/apk com.whatsapp`", { parse_mode: "Markdown" });
754
+ }
755
+
756
+ try {
757
+ // Step 1: Fetch APK details from the API
758
+ const apiUrl = `https://bk9.fun/download/apk?id=${encodeURIComponent(packageName)}`;
759
+ const response = await axios.get(apiUrl);
760
+ const { status, BK9 } = response.data;
761
+
762
+ if (!status || !BK9) {
763
+ return bot.sendMessage(chatId, "❌ APK details not found. Please check the package name and try again.");
764
+ }
765
+
766
+ // Step 2: Prepare APK details message
767
+ const apkDetails = `📱 *APK Details*\n\n` +
768
+ `*Name:* ${BK9.name}\n` +
769
+ `*Last Updated:* ${BK9.lastup}\n` +
770
+ `*Package:* \`${BK9.package}\`\n\n` +
771
+ `\n\n*ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ*`;
772
+
773
+ const downloadLink = BK9.dllink;
774
+
775
+ // Step 3: Create Inline Keyboard Button for download link
776
+ const inlineKeyboard = [
777
+ [
778
+ {
779
+ text: "📥 Download APK",
780
+ url: downloadLink,
781
+ },
782
+ ],
783
+ ];
784
+
785
+ const options = {
786
+ reply_markup: {
787
+ inline_keyboard: inlineKeyboard,
788
+ },
789
+ parse_mode: "Markdown",
790
+ };
791
+
792
+ // Step 4: Send APK details with the download button
793
+ await bot.sendPhoto(chatId, BK9.icon, {
794
+ caption: apkDetails,
795
+ ...options,
796
+ });
797
+ } catch (error) {
798
+ console.error("Error fetching APK details:");
799
+ await bot.sendMessage(chatId, "❌ An error occurred while fetching APK details. Please try again.");
800
+ }
801
+ });
802
+
803
+
804
+ // /movie command
805
+ bot.onText(/\/movie (.+)/, async (msg, match) => {
806
+ const chatId = msg.chat.id;
807
+ const query = match[1]?.trim();
808
+
809
+ if (!query) {
810
+ return bot.sendMessage(chatId, "❌ *Please provide a search query!*\nExample: `/movie Deadpool`", { parse_mode: "Markdown" });
811
+ }
812
+
813
+ try {
814
+ // Step 1: Search SinhalaSub for movies
815
+ const sinhala = await sinhalaSub();
816
+ const results = await sinhala.search(query);
817
+ const movies = results.result.slice(0, 10); // Limit results to 10
818
+
819
+ if (!movies.length) {
820
+ return bot.sendMessage(chatId, `❌ No results found for: *${query}*`, { parse_mode: "Markdown" });
821
+ }
822
+
823
+ // Step 2: Create Inline Keyboard Buttons for movies
824
+ const inlineKeyboard = movies.map((movie, index) => [
825
+ {
826
+ text: `${index + 1}. ${movie.title}`,
827
+ callback_data: `movie_${index}`, // Unique identifier for each movie
828
+ },
829
+ ]);
830
+
831
+ const options = {
832
+ reply_markup: {
833
+ inline_keyboard: inlineKeyboard,
834
+ },
835
+ parse_mode: "Markdown",
836
+ };
837
+
838
+ await bot.sendMessage(chatId, `📽️ *Search Results for:* \`${query}\`\n\nSelect a movie from the list:`, options);
839
+
840
+ // Step 3: Handle movie selection
841
+ bot.on("callback_query", async (callbackQuery) => {
842
+ const { data, message } = callbackQuery;
843
+
844
+ // Check if the callback is for this movie selection
845
+ if (data.startsWith("movie_")) {
846
+ const selectedIndex = parseInt(data.split("_")[1], 10);
847
+ const selectedMovie = movies[selectedIndex];
848
+ const apiUrl = `https://api-site-2.vercel.app/api/sinhalasub/movie?url=${encodeURIComponent(selectedMovie.link)}`;
849
+
850
+ try {
851
+ // Step 4: Fetch download links
852
+ const { data: movieData } = await axios.get(apiUrl);
853
+ const movieDetails = movieData.result;
854
+ const downloadLinks = movieDetails.dl_links || [];
855
+
856
+ if (!downloadLinks.length) {
857
+ return bot.sendMessage(chatId, "❌ No PixelDrain links found for this movie.");
858
+ }
859
+
860
+ // Step 5: Create Inline Keyboard Buttons for direct download links
861
+ const qualityKeyboard = downloadLinks.map((link) => {
862
+ const pixelDrainId = link.link.split("/").pop(); // Extract the file ID
863
+ const directDownloadLink = `https://pixeldrain.com/api/file/${pixelDrainId}?download`; // Use /download endpoint
864
+ return [
865
+ {
866
+ text: `${link.quality} - ${link.size}`,
867
+ url: directDownloadLink, // Direct download link
868
+ },
869
+ ];
870
+ });
871
+
872
+ const qualityOptions = {
873
+ reply_markup: {
874
+ inline_keyboard: qualityKeyboard,
875
+ },
876
+ parse_mode: "Markdown",
877
+ };
878
+
879
+ await bot.sendMessage(
880
+ chatId,
881
+ `🎥 *Available Qualities for:* \`${movieDetails.title}\`\n\nSelect a quality to download directly:\n\n*ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ*`,
882
+ qualityOptions
883
+ );
884
+
885
+ // Acknowledge the callback to avoid timeout errors
886
+ bot.answerCallbackQuery(callbackQuery.id);
887
+ } catch (error) {
888
+ console.error("Error fetching movie details:");
889
+ await bot.sendMessage(chatId, "❌ Failed to fetch movie details. Please try again.");
890
+ }
891
+ }
892
+ });
893
+ } catch (error) {
894
+ console.error("Error executing /movie command:");
895
+ await bot.sendMessage(chatId, "❌ An error occurred while processing your request.");
896
+ }
897
+ });
898
+
899
+
900
+
901
+
902
+ bot.onText(/\/shazam/, async (msg) => {
903
+ const chatId = msg.chat.id;
904
+
905
+ // Ensure the command is a reply to an audio or video message
906
+ const fileId = msg.reply_to_message?.audio?.file_id || msg.reply_to_message?.video?.file_id;
907
+ if (!fileId) {
908
+ return bot.sendMessage(chatId, "❌ Please reply to an audio or video file with /shazam to identify it.");
909
+ }
910
+
911
+ try {
912
+ // Notify the user that the bot is processing the file
913
+ const processingMsg = await bot.sendMessage(chatId, "🎵 Identifying the audio... Please wait!");
914
+
915
+ // Download the file locally
916
+ const filePath = await bot.downloadFile(fileId, "./downloads");
917
+
918
+ // Upload the file to Catbox
919
+ const uploadResponse = await catbox(filePath);
920
+ if (!uploadResponse.url) {
921
+ throw new Error("Failed to upload the file for analysis.");
922
+ }
923
+
924
+ // Call Shazam API
925
+ const shazamApiUrl = `https://api.paxsenix.biz.id/tools/shazam?url=${encodeURIComponent(uploadResponse.url)}`;
926
+ const shazamResponse = await axios.get(shazamApiUrl);
927
+ const shazamResult = shazamResponse.data;
928
+
929
+ // Handle Shazam API response
930
+ if (shazamResult?.ok && shazamResult?.track) {
931
+ const { title, artist, url } = shazamResult.track;
932
+ const resultMessage = `🎶 *Audio Identified:*\n\n` +
933
+ `🎵 *Title:* ${title}\n` +
934
+ `🎤 *Artist:* ${artist}\n` +
935
+ `[🔗 Listen on Shazam](${url})\n\n` +
936
+ `*ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ*`;
937
+
938
+ await bot.sendMessage(chatId, resultMessage, { parse_mode: "Markdown" });
939
+ } else {
940
+ bot.sendMessage(chatId, "❌ Unable to identify the audio. Please try again with a different file.");
941
+ }
942
+
943
+ // Cleanup local file
944
+ fs.unlinkSync(filePath);
945
+ await bot.deleteMessage(chatId, processingMsg.message_id);
946
+ } catch (error) {
947
+ console.error("Error in /shazam command:");
948
+ bot.sendMessage(chatId, "⚠️ An error occurred while processing your request. Please try again later.");
949
+ }
950
+ });
951
+
952
+
953
+ bot.onText(/\/(image|img)(?: (.+))?/, async (msg, match) => {
954
+ const chatId = msg.chat.id;
955
+ const query = match[2]; // Extract the search query from the command
956
+
957
+ if (!query) {
958
+ return bot.sendMessage(
959
+ chatId,
960
+ "❌ Please provide a search query.\n\n*Usage:* `/image <query>`\n*Example:* `/image cats`",
961
+ { parse_mode: "Markdown" }
962
+ );
963
+ }
964
+
965
+ bot.sendMessage(chatId, "🔍 Searching for images... Please wait.");
966
+
967
+ try {
968
+ // Call the Bing Image Search API
969
+ const apiResponse = await axios.get(`https://api.siputzx.my.id/api/s/bimg`, {
970
+ params: { query: query }
971
+ });
972
+
973
+ if (apiResponse.status === 200 && apiResponse.data.status) {
974
+ const images = apiResponse.data.data;
975
+
976
+ if (!images || images.length === 0) {
977
+ return bot.sendMessage(chatId, `❌ No images found for "${query}". Please try another query.`);
978
+ }
979
+
980
+ // Limit to max 5 images
981
+ const maxImages = Math.min(images.length, 5);
982
+ for (let i = 0; i < maxImages; i++) {
983
+ await bot.sendPhoto(chatId, images[i], {
984
+ caption: `🔎 *Image Search Result:*\n\n📄 *Query:* "${query}"\n📷 *Image ${i + 1}/${maxImages}*\n\n*ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ*`,
985
+ parse_mode: "Markdown"
986
+ });
987
+ }
988
+ } else {
989
+ bot.sendMessage(chatId, "❌ Failed to fetch images. Please try again later.");
990
+ }
991
+ } catch (error) {
992
+ console.error("Error in /imagesearch command:");
993
+ bot.sendMessage(
994
+ chatId,
995
+ `⚠️ An error occurred:\n\n*Message:*`,
996
+ { parse_mode: "Markdown" }
997
+ );
998
+ }
999
+ });
1000
+
1001
+ bot.onText(/\/(spotifysearch)(?: (.+))?/, async (msg, match) => {
1002
+ const chatId = msg.chat.id;
1003
+ const query = match[2]; // Extract the search query from the command
1004
+
1005
+ if (!query) {
1006
+ return bot.sendMessage(
1007
+ chatId,
1008
+ "❌ Please provide a search query.\n\n*Usage:* `/spotifysearch <query>`\n*Example:* `/spotifysearch Spectre`",
1009
+ { parse_mode: "Markdown" }
1010
+ );
1011
+ }
1012
+
1013
+ bot.sendMessage(chatId, "🔍 Searching for tracks on Spotify... Please wait.");
1014
+
1015
+ try {
1016
+ // Call the Spotify Search API
1017
+ const apiResponse = await axios.get(`https://api.giftedtech.my.id/api/search/spotifysearch`, {
1018
+ params: { apikey: "gifted-md", query: query }
1019
+ });
1020
+
1021
+ if (apiResponse.status === 200 && apiResponse.data.success) {
1022
+ const tracks = apiResponse.data.results;
1023
+
1024
+ if (!tracks || tracks.length === 0) {
1025
+ return bot.sendMessage(chatId, `❌ No tracks found for "${query}". Please try another query.`);
1026
+ }
1027
+
1028
+ // Limit to max 5 tracks
1029
+ const maxTracks = Math.min(tracks.length, 5);
1030
+ let message = `🎧 *Spotify Search Results:*\n\n`;
1031
+ tracks.slice(0, maxTracks).forEach((track, index) => {
1032
+ message += `🎵 *${index + 1}. ${track.title}*\n` +
1033
+ `👤 *Artist:* ${track.artist}\n` +
1034
+ `⏱️ *Duration:* ${track.duration}\n` +
1035
+ `🔗 [Listen on Spotify](${track.url})\n\n`;
1036
+ });
1037
+
1038
+ bot.sendMessage(chatId, message, { parse_mode: "Markdown" });
1039
+ } else {
1040
+ bot.sendMessage(chatId, "❌ Failed to fetch tracks. Please try again later.");
1041
+ }
1042
+ } catch (error) {
1043
+ console.error("Error in /spotifysearch command:");
1044
+ bot.sendMessage(
1045
+ chatId,
1046
+ `⚠️ An error occurred:\n\n*Message:*`,
1047
+ { parse_mode: "Markdown" }
1048
+ );
1049
+ }
1050
+ });
1051
+
1052
+
1053
+ bot.onText(/\/(spotify-download|spotdl)(?: (.+))?/, async (msg, match) => {
1054
+ const chatId = msg.chat.id;
1055
+ const spotifyUrl = match[2]; // Extract the Spotify track URL from the command
1056
+
1057
+ if (!spotifyUrl) {
1058
+ return bot.sendMessage(
1059
+ chatId,
1060
+ "❌ Please provide a Spotify track URL.\n\n*Usage:* `/spotify-download <Spotify URL>`\n*Example:* `/spotify-download https://open.spotify.com/track/2DGa7iaidT5s0qnINlwMjJ`",
1061
+ { parse_mode: "Markdown" }
1062
+ );
1063
+ }
1064
+
1065
+ bot.sendMessage(chatId, "🔄 Fetching your Spotify track... Please wait.");
1066
+
1067
+ try {
1068
+ // Call the Spotify Download API
1069
+ const apiResponse = await axios.get(`https://api.giftedtech.my.id/api/download/spotifydl`, {
1070
+ params: { apikey: "gifted-md", url: spotifyUrl }
1071
+ });
1072
+
1073
+ if (apiResponse.status === 200 && apiResponse.data.success) {
1074
+ const track = apiResponse.data.result;
1075
+
1076
+ const caption = `🎵 *Spotify Track Downloaded:*\n\n` +
1077
+ `🔹 *Title:* ${track.title}\n` +
1078
+ `⏱️ *Duration:* ${track.duration}\n` +
1079
+ `🎧 *Quality:* ${track.quality}`;
1080
+
1081
+ // Send the audio file to the user
1082
+ await bot.sendAudio(chatId, track.download_url, {
1083
+ caption: caption,
1084
+ parse_mode: "Markdown",
1085
+ thumb: track.thumbnail, // Optional: Thumbnail as album art
1086
+ });
1087
+ } else {
1088
+ bot.sendMessage(chatId, "❌ Failed to fetch track details. Please check the Spotify URL and try again.");
1089
+ }
1090
+ } catch (error) {
1091
+ console.error("Error in /spotify-download command:");
1092
+ bot.sendMessage(
1093
+ chatId,
1094
+ `⚠️ An error occurred:\n\n*Message:*`,
1095
+ { parse_mode: "Markdown" }
1096
+ );
1097
+ }
1098
+ });
1099
+
1100
+
1101
+ bot.onText(/\/(song)(?: (.+))?/, async (msg, match) => {
1102
+ const chatId = msg.chat.id;
1103
+ const query = match[2]; // Extract the search query from the command
1104
+
1105
+ if (!query) {
1106
+ return bot.sendMessage(
1107
+ chatId,
1108
+ "❌ Please provide a search query.\n\n*Usage:* `/song <song title>`\n*Example:* `/song faded`",
1109
+ { parse_mode: "Markdown" }
1110
+ );
1111
+ }
1112
+
1113
+ bot.sendMessage(chatId, "🔍 Searching for songs on Spotify... Please wait.");
1114
+
1115
+ try {
1116
+ // Call the Spotify Search API
1117
+ const searchResponse = await axios.get(`https://api.giftedtech.my.id/api/search/spotifysearch`, {
1118
+ params: { apikey: "gifted", query: query }
1119
+ });
1120
+
1121
+ if (searchResponse.status === 200 && searchResponse.data.success && searchResponse.data.results.length > 0) {
1122
+ const results = searchResponse.data.results;
1123
+
1124
+ // Create inline keyboard buttons for the search results
1125
+ const buttons = results.slice(0, 10).map((item) => [
1126
+ { text: `${item.title} - ${item.artist}`, callback_data: `song_${item.id}` }
1127
+ ]);
1128
+
1129
+ bot.sendMessage(chatId, "🎶 Select a song to download:", {
1130
+ reply_markup: {
1131
+ inline_keyboard: buttons
1132
+ }
1133
+ });
1134
+ } else {
1135
+ bot.sendMessage(chatId, "❌ No songs found. Please try a different query.");
1136
+ }
1137
+ } catch (error) {
1138
+ console.error("Error in /song command:");
1139
+ bot.sendMessage(chatId, `⚠️ An error occurred:\n\n*Message:*`, { parse_mode: "Markdown" });
1140
+ }
1141
+ });
1142
+
1143
+ // Handle button clicks for song selection
1144
+ bot.on("callback_query", async (callbackQuery) => {
1145
+ const chatId = callbackQuery.message.chat.id;
1146
+ const data = callbackQuery.data;
1147
+
1148
+ if (data.startsWith("song_")) {
1149
+ const trackId = data.split("_")[1];
1150
+
1151
+ bot.sendMessage(chatId, "🔄 Downloading your song... Please wait.");
1152
+
1153
+ try {
1154
+ // Call the Spotify Download API
1155
+ const downloadResponse = await axios.get(`https://api.giftedtech.my.id/api/download/spotifydl`, {
1156
+ params: { apikey: "gifted", url: `https://open.spotify.com/track/${trackId}` }
1157
+ });
1158
+
1159
+ if (downloadResponse.status === 200 && downloadResponse.data.success) {
1160
+ const track = downloadResponse.data.result;
1161
+
1162
+ // Send the audio file
1163
+ await bot.sendAudio(chatId, track.download_url, {
1164
+ caption: `🔹 *Title:* ${track.title}\n` +
1165
+ `⏱️ *Duration:* ${track.duration}\n` +
1166
+ `🎧 *Quality:* ${track.quality}\n\n*ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ*`,
1167
+ parse_mode: "Markdown",
1168
+ thumb: track.thumbnail // Optional: Thumbnail as album art
1169
+ });
1170
+ } else {
1171
+ bot.sendMessage(chatId, "❌ Failed to download the song. Please try again.");
1172
+ }
1173
+ } catch (error) {
1174
+ console.error("Error during song download:");
1175
+ bot.sendMessage(chatId, `⚠️ An error occurred:\n\n*Message:*`, { parse_mode: "Markdown" });
1176
+ }
1177
+ }
1178
+ });
1179
+
1180
+ // /facebook command
1181
+ bot.onText(/\/(facebook|fb|fbdl|fbdownload)(?: (.+))?/, async (msg, match) => {
1182
+ const chatId = msg.chat.id;
1183
+ const text = match[2]; // Extract the Facebook video link from the command
1184
+
1185
+ // Guide if no link is provided
1186
+ if (!text) {
1187
+ return bot.sendMessage(chatId, "❌ Please provide a Facebook video link.\nExample: `/fb https://www.facebook.com/reel/1256751708994400?mibextid=rS40aB7S9Ucbxw6v`");
1188
+ }
1189
+
1190
+ // Notify user of processing
1191
+ bot.sendMessage(chatId, "🔄 Fetching your Facebook video... Please wait.");
1192
+
1193
+ try {
1194
+ // Fetch video data using the new API
1195
+ const apiResponse = await axios.get('https://bk9.fun/download/fb', {
1196
+ params: { url: text },
1197
+ });
1198
+
1199
+ const responseData = apiResponse.data;
1200
+
1201
+ // Check if the API response is valid
1202
+ if (responseData.status && responseData.BK9) {
1203
+ const videoData = responseData.BK9;
1204
+ const hdLink = videoData.hd || videoData.sd; // Use HD link if available, fallback to SD
1205
+ const videoTitle = videoData.title || "Facebook Video";
1206
+
1207
+ // Send the video file directly
1208
+ await bot.sendVideo(chatId, hdLink, {
1209
+ caption: `ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ`,
1210
+ parse_mode: 'Markdown',
1211
+ });
1212
+ } else {
1213
+ bot.sendMessage(chatId, "❌ Failed to fetch the video. Please check the link and try again.");
1214
+ }
1215
+ } catch (error) {
1216
+ console.error("Error in Facebook Downloader:");
1217
+ bot.sendMessage(chatId, "❌ An error occurred while processing your request. Please try again later.");
1218
+ }
1219
+ });
1220
+
1221
+
1222
+ // Temporary storage for mapping callback data to URLs
1223
+ const twitterDownloadLinks = new Map();
1224
+
1225
+ bot.onText(/\/twitter (.+)/, async (msg, match) => {
1226
+ const chatId = msg.chat.id;
1227
+ const twitterUrl = match[1]?.trim();
1228
+
1229
+ // Validate input
1230
+ if (!twitterUrl || !twitterUrl.startsWith("http")) {
1231
+ return bot.sendMessage(chatId, "❌ Please provide a valid Twitter link.\nExample: `/twitter https://x.com/elonmusk/status/1870904082564555012`");
1232
+ }
1233
+
1234
+ // Notify user of processing
1235
+ bot.sendMessage(chatId, "🔄 Fetching Twitter media... Please wait.");
1236
+
1237
+ try {
1238
+ // Fetch data from the API
1239
+ const apiUrl = `https://api.paxsenix.biz.id/dl/twitter?url=${encodeURIComponent(twitterUrl)}`;
1240
+ const response = await axios.get(apiUrl);
1241
+ const data = response.data;
1242
+
1243
+ // Check if API returned valid data
1244
+ if (!data.ok) {
1245
+ return bot.sendMessage(chatId, "❌ Failed to fetch Twitter media. Please check the link and try again.");
1246
+ }
1247
+
1248
+ // Generate unique identifiers for the buttons
1249
+ const uniqueIdHD = `HD_${Date.now()}`;
1250
+ const uniqueIdSD = `SD_${Date.now()}`;
1251
+ const uniqueIdAudio = `Audio_${Date.now()}`;
1252
+
1253
+ // Store URLs in the mapping
1254
+ if (data.HD) twitterDownloadLinks.set(uniqueIdHD, data.HD);
1255
+ if (data.SD) twitterDownloadLinks.set(uniqueIdSD, data.SD);
1256
+ if (data.audio) twitterDownloadLinks.set(uniqueIdAudio, data.audio);
1257
+
1258
+ // Inline keyboard for video quality selection
1259
+ const inlineKeyboard = [];
1260
+ if (data.HD) inlineKeyboard.push([{ text: "HD Video", callback_data: uniqueIdHD }]);
1261
+ if (data.SD) inlineKeyboard.push([{ text: "SD Video", callback_data: uniqueIdSD }]);
1262
+ if (data.audio) inlineKeyboard.push([{ text: "Audio Only", callback_data: uniqueIdAudio }]);
1263
+
1264
+ // Send preview with inline buttons
1265
+ await bot.sendPhoto(chatId, data.thumb, {
1266
+ caption: `🌟 *ATOMIC TWITTER DOWNLOADER!*\n\n🎉 *ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ*\n\nSelect the desired quality below:`,
1267
+ parse_mode: "Markdown",
1268
+ reply_markup: {
1269
+ inline_keyboard: inlineKeyboard,
1270
+ },
1271
+ });
1272
+ } catch (error) {
1273
+ console.error("Error in Twitter Downloader:");
1274
+ bot.sendMessage(chatId, "❌ An error occurred while processing your request. Please try again later.");
1275
+ }
1276
+ });
1277
+
1278
+ // Handle callback queries for Twitter downloads
1279
+ bot.on("callback_query", async (callbackQuery) => {
1280
+ const chatId = callbackQuery.message.chat.id;
1281
+ const data = callbackQuery.data;
1282
+
1283
+ // Check if the callback data exists in the mapping
1284
+ const url = twitterDownloadLinks.get(data);
1285
+ if (url) {
1286
+ // Notify user that the download is in progress
1287
+ await bot.sendMessage(chatId, "📥 Downloading your media...");
1288
+
1289
+ try {
1290
+ // Determine the type based on the callback data
1291
+ if (data.startsWith("HD") || data.startsWith("SD")) {
1292
+ await bot.sendVideo(chatId, url, { caption: `🎬ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ` });
1293
+ } else if (data.startsWith("Audio")) {
1294
+ await bot.sendAudio(chatId, url, { caption: "🎵 ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ!" });
1295
+ }
1296
+
1297
+ // Remove the mapping after successful download
1298
+ twitterDownloadLinks.delete(data);
1299
+ } catch (error) {
1300
+ console.error(`Error sending media:`);
1301
+ await bot.sendMessage(chatId, "❌ Failed to send the requested media. Please try again later.");
1302
+ }
1303
+ } else {
1304
+ bot.sendMessage(chatId, "");
1305
+ }
1306
+
1307
+ // Acknowledge the callback query to avoid timeout
1308
+ bot.answerCallbackQuery(callbackQuery.id);
1309
+ });
1310
+
1311
+ // /instagram command
1312
+ bot.onText(/\/(instagram|ig|igvideo|igimage|igdownload|instadl)(?: (.+))?/, async (msg, match) => {
1313
+ const chatId = msg.chat.id;
1314
+ const text = match[2]; // Extract the Instagram URL from the command
1315
+
1316
+ // Guide if no link is provided
1317
+ if (!text || !text.startsWith('http')) {
1318
+ return bot.sendMessage(chatId, "❌ Please provide a valid Instagram link.\nExample: `/instagram https://www.instagram.com/reel/DDgvfkAuBMI/`");
1319
+ }
1320
+
1321
+ // Notify user of processing
1322
+ bot.sendMessage(chatId, "🔄 Fetching your Instagram media... Please wait.");
1323
+
1324
+ try {
1325
+ // Fetch Instagram media data using the API
1326
+ const apiResponse = await axios.get('https://api.paxsenix.biz.id/dl/ig', {
1327
+ params: { url: text },
1328
+ });
1329
+
1330
+ const responseData = apiResponse.data;
1331
+
1332
+ // Check if the API response is valid
1333
+ if (responseData.ok && responseData.url && responseData.url.length > 0) {
1334
+ const media = responseData.url[0]; // Assume the first item is the main media
1335
+ const mediaUrl = media.url;
1336
+ const mediaType = media.type || "video"; // Default to video
1337
+
1338
+ if (mediaType === "video") {
1339
+ // Send the video
1340
+ await bot.sendVideo(chatId, mediaUrl, {
1341
+ caption: `*ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ*`,
1342
+ parse_mode: "Markdown",
1343
+ });
1344
+ } else {
1345
+ // Send the image
1346
+ await bot.sendPhoto(chatId, mediaUrl, {
1347
+ caption: `*ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ*`,
1348
+ parse_mode: "Markdown",
1349
+ });
1350
+ }
1351
+ } else {
1352
+ bot.sendMessage(chatId, "❌ Failed to fetch media. Please check the link and try again.");
1353
+ }
1354
+ } catch (error) {
1355
+ console.error("Error in Instagram Downloader:");
1356
+ bot.sendMessage(chatId, "❌ An error occurred while processing your request. Please try again later.");
1357
+ }
1358
+ });
1359
+ // Anti-link command
1360
+ // Anti-link toggle commands (Admins only)
1361
+ bot.onText(/\/antilink (on|off)/, async (msg, match) => {
1362
+ const chatId = msg.chat.id;
1363
+ const userId = msg.from.id;
1364
+ const action = match[1];
1365
+
1366
+ // Check if the user is an admin
1367
+ if (await isAdmin(chatId, userId)) {
1368
+ if (action === 'on') {
1369
+ antiLinkActive = true;
1370
+ bot.sendMessage(chatId, "Anti-link is now activated!");
1371
+ } else if (action === 'off') {
1372
+ antiLinkActive = false;
1373
+ bot.sendMessage(chatId, "Anti-link is now deactivated!");
1374
+ }
1375
+ } else {
1376
+ bot.sendMessage(chatId, "You don't have permission to use this command.");
1377
+ }
1378
+ });
1379
+
1380
+
1381
+ bot.onText(/\/xvideodownload (.+)?/, async (msg, match) => {
1382
+ const chatId = msg.chat.id;
1383
+ const input = match[1]?.trim(); // Get the user-provided URL (if any)
1384
+
1385
+ // Check for the last stored video URL or input
1386
+ const url = input || (global.db?.data?.users?.[msg.from.id]?.lastVideoUrl);
1387
+ if (!url) {
1388
+ return bot.sendMessage(chatId, "❌ *No video URL found!*\nPlease provide a valid video link or use `/videosearch` first.", {
1389
+ parse_mode: "Markdown",
1390
+ });
1391
+ }
1392
+
1393
+ try {
1394
+ // Step 1: Call the video download API
1395
+ const apiUrl = `https://api.agatz.xyz/api/xvideodown?url=${encodeURIComponent(url)}`;
1396
+ const response = await axios.get(apiUrl);
1397
+ const result = response.data;
1398
+
1399
+ // Step 2: Check if the API returned a valid response
1400
+ if (result.status === 200 && result.data?.url) {
1401
+ const videoStreamUrl = result.data.url;
1402
+
1403
+ // Step 3: Download the video content
1404
+ const videoResponse = await axios({
1405
+ url: videoStreamUrl,
1406
+ method: 'GET',
1407
+ responseType: 'stream',
1408
+ });
1409
+
1410
+ // Step 4: Send the video to the user
1411
+ const videoInfo = result.data;
1412
+ const body = `🎥 *Video Details:*\n\n` +
1413
+ `🔤 *Title:* ${videoInfo.title}\n` +
1414
+ `👀 *Views:* ${videoInfo.views}\n` +
1415
+ `👍 *Likes:* ${videoInfo.like_count}\n` +
1416
+ `👎 *Dislikes:* ${videoInfo.dislike_count}\n` +
1417
+ `⭐ *Votes:* ${videoInfo.vote}\n` +
1418
+ `🔗 *Source:* [Watch Original Video](${url})\n\n` +
1419
+ `*ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ™*`;
1420
+
1421
+ await bot.sendMessage(chatId, body, { parse_mode: "Markdown" });
1422
+
1423
+ bot.sendVideo(chatId, videoResponse.data, {
1424
+ caption: `*ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ*`,
1425
+ parse_mode: "Markdown",
1426
+ });
1427
+ } else {
1428
+ bot.sendMessage(chatId, "❌ Failed to fetch the video. Please try again later.");
1429
+ }
1430
+ } catch (error) {
1431
+ console.error("Video Download Error:");
1432
+ bot.sendMessage(chatId, "❌ An error occurred while downloading the video. Please try again.");
1433
+ }
1434
+ });
1435
+
1436
+ bot.onText(/\/videodownload (.+)?/, async (msg, match) => {
1437
+ const chatId = msg.chat.id;
1438
+ const input = match[1]?.trim(); // Get the user-provided URL (if any)
1439
+
1440
+ // Check for the last stored video URL or input
1441
+ const url = input || (global.db?.data?.users?.[msg.from.id]?.lastVideoUrl);
1442
+ if (!url) {
1443
+ return bot.sendMessage(chatId, "❌ *No video URL found!*\nPlease provide a valid video link or use `/xvideosearch` first.", {
1444
+ parse_mode: "Markdown",
1445
+ });
1446
+ }
1447
+
1448
+ try {
1449
+ // Step 1: Call the video download API
1450
+ const apiUrl = `https://api.agatz.xyz/api/xvideodown?url=${encodeURIComponent(url)}`;
1451
+ const response = await axios.get(apiUrl);
1452
+ const result = response.data;
1453
+
1454
+ // Step 2: Check if the API returned a valid response
1455
+ if (result.status === 200 && result.data?.url) {
1456
+ const videoInfo = result.data;
1457
+ const videoUrl = videoInfo.url;
1458
+
1459
+ // Step 3: Prepare the video details for the user
1460
+ const body = `🎥 *Video Details:*\n\n` +
1461
+ `🔤 *Title:* ${videoInfo.title}\n` +
1462
+ `👀 *Views:* ${videoInfo.views}\n` +
1463
+ `👍 *Likes:* ${videoInfo.like_count}\n` +
1464
+ `👎 *Dislikes:* ${videoInfo.dislike_count}\n` +
1465
+ `⭐ *Votes:* ${videoInfo.vote}\n` +
1466
+ `🔗 *URL:* [Watch Original Video](${url})\n\n` +
1467
+ `*ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ*`;
1468
+
1469
+ // Step 4: Send the video thumbnail and downloadable video to the user
1470
+ await bot.sendPhoto(chatId, videoInfo.thumb, {
1471
+ caption: body,
1472
+ parse_mode: "Markdown",
1473
+ });
1474
+
1475
+ await bot.sendVideo(chatId, videoUrl, {
1476
+ caption: `*ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ*`,
1477
+ parse_mode: "Markdown",
1478
+ });
1479
+ } else {
1480
+ bot.sendMessage(chatId, "❌ Failed to fetch the video. Please try again later.");
1481
+ }
1482
+ } catch (error) {
1483
+ console.error("Video Download Error:");
1484
+ bot.sendMessage(chatId, "❌ An error occurred while downloading the video. Please try again.");
1485
+ }
1486
+ });
1487
+
1488
+
1489
+
1490
+
1491
+
1492
+ const { randomUUID } = require("crypto");
1493
+
1494
+ // /text2speech command
1495
+ bot.onText(/\/text2speech (.+)/, async (msg, match) => {
1496
+ const chatId = msg.chat.id;
1497
+ const input = match[1].trim();
1498
+
1499
+ if (!input) {
1500
+ return bot.sendMessage(chatId, "❌ *Please provide text to convert to speech!*\nExample: `/text2speech Hello world | en`", {
1501
+ parse_mode: "Markdown",
1502
+ });
1503
+ }
1504
+
1505
+ try {
1506
+ // Split input into text and optional language code
1507
+ const [text, lang] = input.split("|").map((item) => item.trim());
1508
+ const language = lang || "en"; // Default to 'en' if no language provided
1509
+
1510
+ if (!text) {
1511
+ return bot.sendMessage(chatId, "❌ *Please provide valid text for the speech conversion.*", {
1512
+ parse_mode: "Markdown",
1513
+ });
1514
+ }
1515
+
1516
+ const encodedText = encodeURIComponent(text);
1517
+ const apiUrl = `https://bk9.fun/tools/tts?q=${encodedText}&lang=${language}`;
1518
+
1519
+ // Step 1: Fetch the audio file
1520
+ const response = await axios({
1521
+ method: "GET",
1522
+ url: apiUrl,
1523
+ responseType: "stream",
1524
+ });
1525
+
1526
+ // Generate a random filename for the audio
1527
+ const fileName = `${randomUUID()}.mp3`;
1528
+ const filePath = `./${fileName}`;
1529
+
1530
+ // Step 2: Save the audio stream to a file
1531
+ const writer = fs.createWriteStream(filePath);
1532
+ response.data.pipe(writer);
1533
+
1534
+ writer.on("finish", async () => {
1535
+ try {
1536
+ // Step 3: Send the audio file to the user
1537
+ await bot.sendAudio(chatId, filePath, {
1538
+ caption: `🎙️ *Text-to-Speech Result*\n🌐 *Language:* ${language.toUpperCase()}`,
1539
+ parse_mode: "Markdown",
1540
+ });
1541
+
1542
+ // Cleanup: Delete the temporary file
1543
+ fs.unlinkSync(filePath);
1544
+ console.log(`Temporary file ${fileName} deleted successfully.`);
1545
+ } catch (sendError) {
1546
+ console.error("Error sending TTS file:");
1547
+ bot.sendMessage(chatId, "❌ Failed to send the generated audio file.");
1548
+ if (fs.existsSync(filePath)) fs.unlinkSync(filePath); // Ensure cleanup
1549
+ }
1550
+ });
1551
+
1552
+ writer.on("error", (error) => {
1553
+ console.error("Error saving TTS file:");
1554
+ bot.sendMessage(chatId, "❌ Failed to generate or send the audio.");
1555
+ });
1556
+ } catch (error) {
1557
+ console.error("TTS Error:");
1558
+ bot.sendMessage(chatId, "❌ An error occurred while generating speech. Please try again.");
1559
+ }
1560
+ });
1561
+
1562
+
1563
+
1564
+
1565
+ // /dog command
1566
+ bot.onText(/\/dog/, async (msg) => {
1567
+ const chatId = msg.chat.id;
1568
+
1569
+ try {
1570
+ const response = await axios.get('https://dog.ceo/api/breeds/image/random');
1571
+ const dogUrl = response.data.message;
1572
+ bot.sendPhoto(chatId, dogUrl);
1573
+ } catch (error) {
1574
+ bot.sendMessage(chatId, 'Could not fetch a dog picture at the moment. Please try again later.');
1575
+ }
1576
+ });
1577
+
1578
+
1579
+
1580
+
1581
+
1582
+ // Function to get currency conversion rate from ExchangeRate-API
1583
+ async function getCurrencyConversion(amount, fromCurrency, toCurrency) {
1584
+ try {
1585
+ // Request currency conversion data from ExchangeRate-API
1586
+ const response = await axios.get(`https://v6.exchangerate-api.com/v6/${apiKey}/latest/${fromCurrency}`);
1587
+
1588
+ const rates = response.data.conversion_rates;
1589
+ const conversionRate = rates[toCurrency];
1590
+
1591
+ if (conversionRate) {
1592
+ const convertedAmount = (amount * conversionRate).toFixed(2);
1593
+ return `${amount} ${fromCurrency} = ${convertedAmount} ${toCurrency}`;
1594
+ } else {
1595
+ return `Sorry, I couldn't find the conversion rate for ${toCurrency}.`;
1596
+ }
1597
+ } catch (error) {
1598
+ console.error('Error fetching currency conversion:');
1599
+ return 'Oops! Something went wrong. Please try again later.';
1600
+ }
1601
+ }
1602
+
1603
+ // Command handler for /currency
1604
+ bot.onText(/\/currency (\d+\.?\d*) (\w+) to (\w+)/, async (msg, match) => {
1605
+ const chatId = msg.chat.id;
1606
+ const amount = parseFloat(match[1]);
1607
+ const fromCurrency = match[2].toUpperCase();
1608
+ const toCurrency = match[3].toUpperCase();
1609
+
1610
+ // Validate the amount
1611
+ if (isNaN(amount) || amount <= 0) {
1612
+ bot.sendMessage(chatId, 'Please provide a valid amount to convert. Example: /currency 100 USD to EUR');
1613
+ return;
1614
+ }
1615
+
1616
+ const conversionResult = await getCurrencyConversion(amount, fromCurrency, toCurrency);
1617
+ bot.sendMessage(chatId, conversionResult);
1618
+ });
1619
+
1620
+
1621
+
1622
+
1623
+
1624
+ // Flag to indicate when an admin has issued /setgrouppic
1625
+ let awaitingGroupPic = new Map();
1626
+
1627
+ // /setgrouppic command (admins only)
1628
+ bot.onText(/\/setgrouppic/, async (msg) => {
1629
+ const chatId = msg.chat.id;
1630
+ const userId = msg.from.id;
1631
+
1632
+ if (msg.chat.type !== 'group' && msg.chat.type !== 'supergroup') {
1633
+ bot.sendMessage(chatId, 'This command can only be used in group chats.');
1634
+ return;
1635
+ }
1636
+
1637
+ // Check if the user is an admin
1638
+ if (await isAdmin(chatId, userId)) {
1639
+ bot.sendMessage(chatId, 'Please send the new group picture as a photo.');
1640
+ awaitingGroupPic.set(chatId, userId); // Track the admin who issued the command
1641
+ } else {
1642
+ bot.sendMessage(chatId, "You don't have permission to use this command.");
1643
+ }
1644
+ });
1645
+
1646
+ // Handle photo uploads for /setgrouppic
1647
+ bot.on('photo', async (msg) => {
1648
+ const chatId = msg.chat.id;
1649
+ const userId = msg.from.id;
1650
+
1651
+ // Check if we are awaiting a photo from an admin
1652
+ if (awaitingGroupPic.get(chatId) === userId) {
1653
+ const photoId = msg.photo[msg.photo.length - 1].file_id;
1654
+
1655
+ try {
1656
+ const file = await bot.getFile(photoId);
1657
+ const downloadPath = await bot.downloadFile(photoId, './');
1658
+
1659
+ await bot.setChatPhoto(chatId, fs.createReadStream(downloadPath));
1660
+ bot.sendMessage(chatId, 'Group picture updated successfully!');
1661
+
1662
+ // Clean up
1663
+ fs.unlinkSync(downloadPath);
1664
+ awaitingGroupPic.delete(chatId); // Remove the flag after setting the picture
1665
+ } catch (error) {
1666
+ console.error('Error:');
1667
+ bot.sendMessage(chatId, 'Failed to update group picture. Make sure I have the required permissions.');
1668
+ }
1669
+ }
1670
+ });
1671
+
1672
+ // Kick command
1673
+ bot.onText(/\/kick/, async (msg) => {
1674
+ const chatId = msg.chat.id;
1675
+
1676
+ if (msg.reply_to_message) {
1677
+ const userId = msg.reply_to_message.from.id; // User to kick must be mentioned in reply
1678
+ const requesterId = msg.from.id; // ID of the person issuing the command
1679
+
1680
+ if (await isAdmin(chatId, requesterId)) {
1681
+ try {
1682
+ await bot.kickChatMember(chatId, userId);
1683
+ bot.sendMessage(chatId, "User has been kicked.");
1684
+ // Optionally, unban the user immediately to allow them to rejoin if necessary
1685
+ setTimeout(() => {
1686
+ bot.unbanChatMember(chatId, userId);
1687
+ }, 1000);
1688
+ } catch (err) {
1689
+ console.error("Failed to kick user:");
1690
+ bot.sendMessage(chatId, "Failed to kick user. Ensure I have appropriate permissions.");
1691
+ }
1692
+ } else {
1693
+ bot.sendMessage(chatId, "You don't have permission to use this command.");
1694
+ }
1695
+ } else {
1696
+ bot.sendMessage(chatId, "Please reply to a user's message to kick them.");
1697
+ }
1698
+ });
1699
+
1700
+ // Mute command
1701
+ // Mute command
1702
+ bot.onText(/\/mute/, async (msg) => {
1703
+ const chatId = msg.chat.id;
1704
+ const requesterId = msg.from.id;
1705
+
1706
+ // Check if the user issuing the command is an admin
1707
+ if (await isAdmin(chatId, requesterId)) {
1708
+ if (msg.reply_to_message) {
1709
+ const userId = msg.reply_to_message.from.id; // User to mute must be mentioned in reply
1710
+ mutedUsers.add(userId);
1711
+ bot.sendMessage(chatId, `User has been muted.`);
1712
+ } else {
1713
+ bot.sendMessage(chatId, "Please reply to a user's message to mute them.");
1714
+ }
1715
+ } else {
1716
+ bot.sendMessage(chatId, "You don't have permission to use this command.");
1717
+ }
1718
+ });
1719
+
1720
+ // Function to get anime details from Jikan API
1721
+ async function getAnimeInfo(animeName) {
1722
+ try {
1723
+ const response = await axios.get(`https://api.jikan.moe/v4/anime?q=${animeName}&limit=1`);
1724
+ const anime = response.data.data[0];
1725
+ if (anime) {
1726
+ const title = anime.title;
1727
+ const synopsis = anime.synopsis;
1728
+ const rating = anime.rating;
1729
+ const imageUrl = anime.images.jpg.image_url;
1730
+ const url = anime.url;
1731
+
1732
+ return {
1733
+ info: `*${title}*\n\n${synopsis}\n\n*Rating:* ${rating}\n\n[More Info](${url})`,
1734
+ imageUrl: imageUrl,
1735
+ };
1736
+ } else {
1737
+ return { info: 'No anime found with that name.', imageUrl: null };
1738
+ }
1739
+ } catch (error) {
1740
+ console.error('Error fetching anime info:');
1741
+ return { info: 'Oops! Something went wrong.', imageUrl: null };
1742
+ }
1743
+ }
1744
+
1745
+ // Command handler for /anime
1746
+ bot.onText(/\/anime (.+)/, async (msg, match) => {
1747
+ const chatId = msg.chat.id;
1748
+ const animeName = match[1];
1749
+
1750
+ const { info, imageUrl } = await getAnimeInfo(animeName);
1751
+
1752
+ // Send the information as a message
1753
+ bot.sendMessage(chatId, info, { parse_mode: 'Markdown' });
1754
+
1755
+ // If an image URL is available, send the image
1756
+ if (imageUrl) {
1757
+ bot.sendPhoto(chatId, imageUrl);
1758
+ }
1759
+ });
1760
+
1761
+
1762
+
1763
+ // Unmute command
1764
+ bot.onText(/\/unmute/, (msg) => {
1765
+ const chatId = msg.chat.id;
1766
+ if (msg.reply_to_message) {
1767
+ const userId = msg.reply_to_message.from.id; // User to unmute must be mentioned in reply
1768
+ mutedUsers.delete(userId);
1769
+ bot.sendMessage(chatId, `User has been unmuted.`);
1770
+ } else {
1771
+ bot.sendMessage(chatId, "Please reply to a user's message to unmute them.");
1772
+ }
1773
+ });
1774
+
1775
+ // Promote command
1776
+ bot.onText(/\/promote/, async (msg) => {
1777
+ const chatId = msg.chat.id;
1778
+ if (msg.reply_to_message) {
1779
+ const userId = msg.reply_to_message.from.id; // User to promote must be mentioned in reply
1780
+ if (await isAdmin(chatId, msg.from.id)) {
1781
+ try {
1782
+ await bot.promoteChatMember(chatId, userId, {
1783
+ can_change_info: true,
1784
+ can_post_messages: true,
1785
+ can_edit_messages: true,
1786
+ can_delete_messages: true,
1787
+ can_invite_users: true,
1788
+ can_restrict_members: true,
1789
+ can_pin_messages: true,
1790
+ can_promote_members: true
1791
+ });
1792
+ bot.sendMessage(chatId, "User has been promoted to admin.");
1793
+ } catch (err) {
1794
+ bot.sendMessage(chatId, "Failed to promote user.");
1795
+ }
1796
+ } else {
1797
+ bot.sendMessage(chatId, "You don't have permission to use this command.");
1798
+ }
1799
+ } else {
1800
+ bot.sendMessage(chatId, "Please reply to a user's message to promote them.");
1801
+ }
1802
+ });
1803
+
1804
+ // Demote command
1805
+ bot.onText(/\/demote/, async (msg) => {
1806
+ const chatId = msg.chat.id;
1807
+ if (msg.reply_to_message) {
1808
+ const userId = msg.reply_to_message.from.id; // User to demote must be mentioned in reply
1809
+ if (await isAdmin(chatId, msg.from.id)) {
1810
+ try {
1811
+ await bot.promoteChatMember(chatId, userId, {
1812
+ can_change_info: false,
1813
+ can_post_messages: false,
1814
+ can_edit_messages: false,
1815
+ can_delete_messages: false,
1816
+ can_invite_users: false,
1817
+ can_restrict_members: false,
1818
+ can_pin_messages: false,
1819
+ can_promote_members: false
1820
+ });
1821
+ bot.sendMessage(chatId, "User has been demoted.");
1822
+ } catch (err) {
1823
+ bot.sendMessage(chatId, "Failed to demote user.");
1824
+ }
1825
+ } else {
1826
+ bot.sendMessage(chatId, "You don't have permission to use this command.");
1827
+ }
1828
+ } else {
1829
+ bot.sendMessage(chatId, "Please reply to a user's message to demote them.");
1830
+ }
1831
+ });
1832
+
1833
+ // Set name command
1834
+ bot.onText(/\/setname (.+)/, async (msg, match) => {
1835
+ const chatId = msg.chat.id;
1836
+ const newName = match[1];
1837
+ if (await isAdmin(chatId, msg.from.id)) {
1838
+ try {
1839
+ await bot.setChatTitle(chatId, newName);
1840
+ bot.sendMessage(chatId, `Group name has been changed to "${newName}".`);
1841
+ } catch (err) {
1842
+ bot.sendMessage(chatId, "Failed to change group name.");
1843
+ }
1844
+ } else {
1845
+ bot.sendMessage(chatId, "You don't have permission to use this command.");
1846
+ }
1847
+ });
1848
+
1849
+ // /meme command
1850
+ bot.onText(/\/meme/, async (msg) => {
1851
+ const chatId = msg.chat.id;
1852
+
1853
+ try {
1854
+ const response = await axios.get('https://meme-api.herokuapp.com/gimme');
1855
+ const memeUrl = response.data.url;
1856
+ bot.sendPhoto(chatId, memeUrl);
1857
+ } catch (error) {
1858
+ bot.sendMessage(chatId, 'Could not retrieve a meme at the moment. Please try again later.');
1859
+ }
1860
+ });
1861
+
1862
+ // /joke command
1863
+ bot.onText(/\/joke/, async (msg) => {
1864
+ const chatId = msg.chat.id;
1865
+ try {
1866
+ const response = await axios.get('https://official-joke-api.appspot.com/random_joke');
1867
+ const joke = `${response.data.setup} - ${response.data.punchline}`;
1868
+ bot.sendMessage(chatId, joke);
1869
+ } catch (error) {
1870
+ bot.sendMessage(chatId, 'Failed to fetch a joke. Please try again later.');
1871
+ }
1872
+ });
1873
+
1874
+
1875
+
1876
+
1877
+ // /text2pdf command
1878
+ bot.onText(/\/text2pdf (.+)/, async (msg, match) => {
1879
+ const chatId = msg.chat.id;
1880
+ const inputText = match[1].trim();
1881
+
1882
+ if (!inputText) {
1883
+ return bot.sendMessage(
1884
+ chatId,
1885
+ "❌ *Please provide the text to convert into a PDF!*\nExample: `/text2pdf Hello, this is a test.`",
1886
+ { parse_mode: "Markdown" }
1887
+ );
1888
+ }
1889
+
1890
+ try {
1891
+ // Encode the text to be sent in the URL
1892
+ const encodedText = encodeURIComponent(inputText);
1893
+ const pdfUrl = `https://bk9.fun/tools/pdf?q=${encodedText}`;
1894
+
1895
+ // Step 1: Fetch the PDF file
1896
+ const response = await axios({
1897
+ method: "GET",
1898
+ url: pdfUrl,
1899
+ responseType: "stream",
1900
+ });
1901
+
1902
+ // Generate a random file name for the PDF
1903
+ const fileName = `document_${Date.now()}.pdf`;
1904
+ const filePath = `./${fileName}`;
1905
+
1906
+ // Step 2: Save the PDF stream to a file
1907
+ const writer = require("fs").createWriteStream(filePath);
1908
+ response.data.pipe(writer);
1909
+
1910
+ writer.on("finish", async () => {
1911
+ // Step 3: Send the PDF file to the user
1912
+ await bot.sendDocument(chatId, filePath, {
1913
+ caption: `✅ Your PDF file has been generated successfully!\n*ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ*`,
1914
+ parse_mode: "Markdown",
1915
+ });
1916
+
1917
+ // Cleanup: Delete the temporary file
1918
+ require("fs").unlinkSync(filePath);
1919
+ console.log(`Temporary file ${fileName} deleted successfully.`);
1920
+ });
1921
+
1922
+ writer.on("error", (error) => {
1923
+ console.error("Error saving PDF file:");
1924
+ bot.sendMessage(chatId, "❌ Failed to generate or send the PDF file.");
1925
+ });
1926
+ } catch (error) {
1927
+ console.error("PDF Generation Error:");
1928
+ bot.sendMessage(chatId, "❌ An error occurred while generating the PDF. Please try again.");
1929
+ }
1930
+ });
1931
+
1932
+
1933
+ bot.onText(/\/xvideosearch (.+)/, async (msg, match) => {
1934
+ const chatId = msg.chat.id;
1935
+ const query = match[1].trim();
1936
+
1937
+ if (!query) {
1938
+ return bot.sendMessage(chatId, "❌ *Please provide a search query!*\nExample: `/xvideosearch step sister`", {
1939
+ parse_mode: "Markdown",
1940
+ });
1941
+ }
1942
+
1943
+ try {
1944
+ // Step 1: Call the video search API
1945
+ const apiUrl = `https://api.agatz.xyz/api/xvideo?message=${encodeURIComponent(query)}`;
1946
+ const response = await axios.get(apiUrl);
1947
+ const result = response.data;
1948
+
1949
+ // Step 2: Check if results exist
1950
+ if (result.status === 200 && result.data.length > 0) {
1951
+ const videoInfo = result.data[0]; // Get the first video result
1952
+
1953
+ // Step 3: Prepare the message body
1954
+ const body = `🎥 *Video Search Result:*\n\n` +
1955
+ `🔤 *Title:* ${videoInfo.title}\n` +
1956
+ `⏱️ *Duration:* ${videoInfo.duration}\n\nᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ`;
1957
+
1958
+ // Step 4: Add an inline keyboard button with the video link
1959
+ const options = {
1960
+ parse_mode: "Markdown",
1961
+ reply_markup: {
1962
+ inline_keyboard: [
1963
+ [
1964
+ {
1965
+ text: "🔗 Watch Video",
1966
+ url: videoInfo.url,
1967
+ },
1968
+ ],
1969
+ ],
1970
+ },
1971
+ };
1972
+
1973
+ // Step 5: Send the video thumbnail and details to the user with the button
1974
+ await bot.sendPhoto(chatId, videoInfo.thumb, {
1975
+ caption: body,
1976
+ ...options,
1977
+ });
1978
+ } else {
1979
+ bot.sendMessage(chatId, "❌ No results found. Please try a different query.");
1980
+ }
1981
+ } catch (error) {
1982
+ console.error("Video Search Error:");
1983
+ bot.sendMessage(chatId, "❌ An error occurred while fetching the search results. Please try again.");
1984
+ }
1985
+ });
1986
+
1987
+ // Tag all command
1988
+ bot.onText(/\/tagall/, async (msg) => {
1989
+ const chatId = msg.chat.id;
1990
+ if (await isAdmin(chatId, msg.from.id)) {
1991
+ const members = await bot.getChatAdministrators(chatId);
1992
+ const memberMentions = members.map(member => {
1993
+ return member.user.username ? `@${member.user.username}` : member.user.first_name;
1994
+ }).join(', ');
1995
+
1996
+ bot.sendMessage(chatId, `Tagging all members:\n${memberMentions}`);
1997
+ } else {
1998
+ bot.sendMessage(chatId, "You don't have permission to use this command.");
1999
+ }
2000
+ });
2001
+
2002
+ // Define the /Aza command
2003
+ bot.onText(/\/support/, (msg) => {
2004
+ const chatId = msg.chat.id;
2005
+ const response = "9066528353 OPAY 🇳🇬\nPlease support Developer.";
2006
+
2007
+ // Send the message
2008
+ bot.sendMessage(chatId, response);
2009
+ });
2010
+
2011
+ // Define the /owner command
2012
+ bot.onText(/\/owner/, (msg) => {
2013
+ const chatId = msg.chat.id;
2014
+ const response = "@deecee_x";
2015
+
2016
+ // Send the message
2017
+ bot.sendMessage(chatId, response);
2018
+ });
2019
+
2020
+ // /setdescription command
2021
+ bot.onText(/\/setdescription (.+)/, (msg, match) => {
2022
+ const chatId = msg.chat.id;
2023
+ const description = match[1];
2024
+
2025
+ if (msg.chat.type !== 'group' && msg.chat.type !== 'supergroup') {
2026
+ bot.sendMessage(chatId, 'This command can only be used in group chats.');
2027
+ return;
2028
+ }
2029
+
2030
+ // Check if the user is an admin
2031
+ bot.getChatMember(chatId, msg.from.id).then(member => {
2032
+ if (member.status === 'administrator' || member.status === 'creator') {
2033
+ bot.setChatDescription(chatId, description)
2034
+ .then(() => {
2035
+ bot.sendMessage(chatId, 'Group description updated successfully!');
2036
+ })
2037
+ .catch((error) => {
2038
+ console.error('Error:');
2039
+ bot.sendMessage(chatId, 'Failed to update group description. Make sure I have the required permissions.');
2040
+ });
2041
+ } else {
2042
+ bot.sendMessage(chatId, 'Only group admins can use this command.');
2043
+ }
2044
+ }).catch(error => {
2045
+ console.error('Error fetching chat member:');
2046
+ bot.sendMessage(chatId, 'An error occurred while verifying your admin status.');
2047
+ });
2048
+ });
2049
+
2050
+ // Get link command
2051
+ bot.onText(/\/getlink/, async (msg) => {
2052
+ const chatId = msg.chat.id;
2053
+ if (await isAdmin(chatId, msg.from.id)) {
2054
+ try {
2055
+ const link = await bot.exportChatInviteLink(chatId);
2056
+ bot.sendMessage(chatId, `Here is your invite link: ${link}`);
2057
+ } catch (err) {
2058
+ bot.sendMessage(chatId, "Failed to get the invite link.");
2059
+ }
2060
+ } else {
2061
+ bot.sendMessage(chatId, "You don't have permission to use this command.");
2062
+ }
2063
+ });
2064
+
2065
+ // Welcome and goodbye messages
2066
+ bot.on('new_chat_members', (msg) => {
2067
+ const chatId = msg.chat.id;
2068
+ msg.new_chat_members.forEach(user => {
2069
+ bot.sendMessage(chatId, `Welcome ${user.first_name} to the group!`);
2070
+ });
2071
+ });
2072
+
2073
+ bot.on('left_chat_member', (msg) => {
2074
+ const chatId = msg.chat.id;
2075
+ const user = msg.left_chat_member;
2076
+ bot.sendMessage(chatId, `${user.first_name} has left the group.`);
2077
+ });
2078
+
2079
+ // Anti-link functionality
2080
+ bot.on('message', (msg) => {
2081
+ const chatId = msg.chat.id;
2082
+
2083
+ // Check if anti-link is active
2084
+ if (antiLinkActive && msg.entities) {
2085
+ msg.entities.forEach(entity => {
2086
+ if (entity.type === "url") {
2087
+ bot.deleteMessage(chatId, msg.message_id)
2088
+ .then(() => {
2089
+ bot.sendMessage(chatId, "Links are not allowed in this group.");
2090
+ })
2091
+ .catch(err => {
2092
+ console.error("Failed to delete message:");
2093
+ });
2094
+ }
2095
+ });
2096
+ }
2097
+
2098
+ // Mute functionality
2099
+ if (mutedUsers.has(msg.from.id)) {
2100
+ bot.deleteMessage(chatId, msg.message_id)
2101
+ .catch(err => {
2102
+ console.error("Failed to delete muted user message:");
2103
+ });
2104
+ }
2105
+ });
2106
+
2107
+
2108
+
2109
+
2110
+
2111
+
2112
+ bot.onText(/\/txt2image (.+)/, async (msg, match) => {
2113
+ const chatId = msg.chat.id;
2114
+ const prompt = match[1]; // Extract the prompt from the command
2115
+
2116
+ // Check if the user provided a prompt
2117
+ if (!prompt) {
2118
+ return bot.sendMessage(chatId, "❌ *Please provide a prompt!* \n\nUsage: `/magicstudio <prompt>`", { parse_mode: "Markdown" });
2119
+ }
2120
+
2121
+ try {
2122
+ // Inform the user the process has started
2123
+ await bot.sendMessage(chatId, "✨ *Generating image... Please wait!*", { parse_mode: "Markdown" });
2124
+
2125
+ // API URL to generate the image
2126
+ const apiUrl = `https://bk9.fun/ai/magicstudio?prompt=${encodeURIComponent(prompt)}`;
2127
+
2128
+ // Fetch the generated image from the API
2129
+ const response = await axios.get(apiUrl, { responseType: "stream" });
2130
+
2131
+ // Send the image back to the user
2132
+ await bot.sendPhoto(chatId, response.data, {
2133
+ caption: `🖼️ *Here's your generated image for:* \`${prompt}\`\n\nᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ`,
2134
+ parse_mode: "Markdown"
2135
+ });
2136
+
2137
+ } catch (error) {
2138
+ console.error("Error generating image:");
2139
+ bot.sendMessage(chatId, "❌ *Failed to generate the image. Please try again later!*", { parse_mode: "Markdown" });
2140
+ }
2141
+ });
2142
+
2143
+
2144
+
2145
+
2146
+
2147
+
2148
+ bot.onText(/\/flux(?: (.+))?/, async (msg, match) => {
2149
+ const chatId = msg.chat.id;
2150
+ const prompt = match[1]; // Extract the user's prompt from the command
2151
+
2152
+ if (!prompt) {
2153
+ // If no prompt is provided, send a usage guide
2154
+ return bot.sendMessage(chatId, "❌ Please provide a prompt to generate an image.\n\nExample: `/flux cat`", { parse_mode: "Markdown" });
2155
+ }
2156
+
2157
+ bot.sendMessage(chatId, "🔄 Generating your image... Please wait.");
2158
+
2159
+ try {
2160
+ // Call the Flux API to generate the image
2161
+ const apiUrl = `https://apis.davidcyriltech.my.id/flux?prompt=${encodeURIComponent(prompt)}`;
2162
+
2163
+ // Send the generated image to the user
2164
+ await bot.sendPhoto(chatId, apiUrl, {
2165
+ caption: `✨ *Flux Image Generated*\n\n🔹 *Prompt:* ${prompt}\n*ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ*`,
2166
+ parse_mode: "Markdown",
2167
+ });
2168
+ } catch (error) {
2169
+ console.error("Error during /flux command:");
2170
+ bot.sendMessage(chatId, "❌ An error occurred while generating the image. Please try again later.");
2171
+ }
2172
+ });
2173
+
2174
+
2175
+ const { shannzCdn } = require("./uploader"); // Import new uploader module
2176
+
2177
+ bot.on("message", async (msg) => {
2178
+ const chatId = msg.chat.id;
2179
+ const text = msg.text?.trim().toLowerCase();
2180
+
2181
+ if (text === "remini" && msg.reply_to_message?.photo) {
2182
+ try {
2183
+ await bot.sendMessage(chatId, "⏳ Processing your image...");
2184
+
2185
+ // Step 1: Download Image from Telegram
2186
+ const fileId = msg.reply_to_message.photo[msg.reply_to_message.photo.length - 1].file_id;
2187
+ const file = await bot.getFile(fileId);
2188
+ const fileUrl = `https://api.telegram.org/file/bot${process.env.BOT_TOKEN}/${file.file_path}`;
2189
+ const localFilePath = path.join(__dirname, "downloads", `${fileId}.jpg`);
2190
+
2191
+ const writer = fs.createWriteStream(localFilePath);
2192
+ const imageResponse = await axios({ url: fileUrl, method: "GET", responseType: "stream" });
2193
+ imageResponse.data.pipe(writer);
2194
+
2195
+ await new Promise((resolve, reject) => {
2196
+ writer.on("finish", resolve);
2197
+ writer.on("error", reject);
2198
+ });
2199
+
2200
+ // Step 2: Upload Image to Shannz CDN
2201
+ const uploadResponse = await shannzCdn(localFilePath);
2202
+ console.log("Shannz CDN Response:", uploadResponse);
2203
+
2204
+ if (!uploadResponse || !uploadResponse.url) {
2205
+ fs.unlinkSync(localFilePath);
2206
+ return bot.sendMessage(chatId, "❌ Failed to upload the image. Please try again.");
2207
+ }
2208
+
2209
+ const imageUrl = uploadResponse.url;
2210
+ console.log("Uploaded Image URL:", imageUrl);
2211
+
2212
+ // Step 3: Send Image to Remini API
2213
+ const enhanceUrl = `https://bk9.fun/tools/enhance?url=${encodeURIComponent(imageUrl)}`;
2214
+ console.log("Enhancement API URL:", enhanceUrl);
2215
+
2216
+ // Step 4: Send Enhanced Image to User
2217
+ await bot.sendPhoto(chatId, enhanceUrl, {
2218
+ caption: "✨ *Image Enhanced Successfully!*",
2219
+ parse_mode: "Markdown",
2220
+ });
2221
+
2222
+ fs.unlinkSync(localFilePath); // Cleanup
2223
+ } catch (error) {
2224
+ console.error("Error enhancing image:");
2225
+ bot.sendMessage(chatId, `❌ Error`);
2226
+ }
2227
+ }
2228
+ });
2229
+ // Handle /delete Command
2230
+ bot.onText(/\/delete/, async (msg) => {
2231
+ const chatId = msg.chat.id;
2232
+
2233
+ if (msg.reply_to_message) {
2234
+ try {
2235
+ await bot.deleteMessage(chatId, msg.reply_to_message.message_id);
2236
+ await bot.deleteMessage(chatId, msg.message_id);
2237
+ } catch (error) {
2238
+ bot.sendMessage(chatId, "❌ Unable to delete the message. Check my permissions.");
2239
+ }
2240
+ } else {
2241
+ bot.sendMessage(chatId, "❌ Please reply to a message to delete it.");
2242
+ }
2243
+ });
2244
+ // Delete Message Command
2245
+ bot.onText(/\/delete/, async (msg) => {
2246
+ const chatId = msg.chat.id;
2247
+
2248
+ if (msg.reply_to_message) {
2249
+ const messageId = msg.reply_to_message.message_id;
2250
+
2251
+ try {
2252
+ // Delete the replied message
2253
+ await bot.deleteMessage(chatId, messageId);
2254
+ // Optionally delete the command message
2255
+ await bot.deleteMessage(chatId, msg.message_id);
2256
+
2257
+ // Confirmation message
2258
+ await bot.sendMessage(chatId, "✅ Message deleted successfully.", { reply_to_message_id: msg.message_id });
2259
+ } catch (error) {
2260
+ console.error("Delete message error:");
2261
+ bot.sendMessage(
2262
+ chatId,
2263
+ "❌ Failed to delete the message. Ensure I have the necessary permissions.",
2264
+ { reply_to_message_id: msg.message_id }
2265
+ );
2266
+ }
2267
+ } else {
2268
+ bot.sendMessage(chatId, "❌ Please reply to the message you want to delete.", { reply_to_message_id: msg.message_id });
2269
+ }
2270
+ });
2271
+
2272
+ // Start the bot
2273
+ bot.onText(/\/help/, (msg) => {
2274
+ const chatId = msg.chat.id;
2275
+ bot.sendMessage(chatId, "Hi I Am Atomic! Use /start for available commands.");
2276
+ });
2277
+
2278
+ // Store the start time when the bot starts
2279
+ const startTime = Date.now();
2280
+
2281
+ // Command to get bot runtime
2282
+ bot.onText(/\/runtime/, (msg) => {
2283
+ const chatId = msg.chat.id;
2284
+
2285
+ // Calculate runtime
2286
+ const uptimeMs = Date.now() - startTime;
2287
+ const uptimeSeconds = Math.floor(uptimeMs / 1000);
2288
+ const hours = Math.floor(uptimeSeconds / 3600);
2289
+ const minutes = Math.floor((uptimeSeconds % 3600) / 60);
2290
+ const seconds = uptimeSeconds % 60;
2291
+
2292
+ // Send back the bot runtime
2293
+ bot.sendMessage(chatId, `The bot has been running for ${hours} hours, ${minutes} minutes, and ${seconds} seconds.`);
2294
+ });
2295
+
2296
+ // /ping command
2297
+ bot.onText(/\/ping/, (msg) => {
2298
+ const chatId = msg.chat.id;
2299
+ const start = Date.now(); // Record the start time
2300
+
2301
+ bot.sendMessage(chatId, 'Pong!').then(() => {
2302
+ const end = Date.now(); // Record the end time
2303
+ const ping = end - start; // Calculate the difference in milliseconds
2304
+ bot.sendMessage(chatId, `Response time: ${ping} ms`);
2305
+ });
2306
+ });
2307
+
2308
+ // Unified /start command
2309
+ bot.onText(/\/start/, (msg) => {
2310
+ const chatId = msg.chat.id;
2311
+
2312
+ // First page: Download Commands
2313
+ const helpMessageDownload = `
2314
+ *🔥 ATOMIC BOT MENU 🔥*
2315
+
2316
+ ⬇️ *Download Commands*:
2317
+ - 🎶 /play <song name>: Download and play music from YouTube.
2318
+ - 🎶 /song <song name>: Download and play music from Spotify.
2319
+ - 🎥 /tiktok <link>: Download TikTok videos.
2320
+ - 📸 /instagram <link>: Download Instagram media.
2321
+ - 📘 /fb <link>: Download Facebook videos.
2322
+ - 🎥 /video <song name>: Download Music Videos.
2323
+ - 🎶 /ytmp3 <link>: Download Music Videos.
2324
+ - 🎥 /ytmp4 <link>: Download and play music.
2325
+ - 📦 /mediafire <link>: Downloads MediaFire Files
2326
+ - 📦 /apk <app name>: Downloads Apk.
2327
+ - 📦 /gitclone <llnk>: Downloads files from github
2328
+ - 🎬 /movie <movie name>: Downloads movies.
2329
+ - 🎬 /twitter <link>: Downloads twitter videos.
2330
+ `;
2331
+
2332
+ bot.sendMessage(chatId, helpMessageDownload, {
2333
+ parse_mode: 'Markdown',
2334
+ reply_markup: {
2335
+ inline_keyboard: [
2336
+ [{ text: "➡️ NEXT", callback_data: "help_next_1" }]
2337
+ ]
2338
+ }
2339
+ });
2340
+ });
2341
+
2342
+ // Handle button clicks for pagination
2343
+ bot.on('callback_query', (query) => {
2344
+ const chatId = query.message.chat.id;
2345
+
2346
+ // First "NEXT" button (from Download Menu to Admin Commands)
2347
+ if (query.data === "help_next_1") {
2348
+ const helpMessageAdmin = `🤖 *AI Commands*:
2349
+ - 🤖 /chatbot <on / off>: Interact with ai models without using any prefix
2350
+ - 🤖 /gpt <query>: Get an AI-powered response.
2351
+ - 🔊 /text2speech <text>: Convert text to speech.
2352
+ - 🪄 /text2image <prompt>: Generates Any Ai Image of your choice.
2353
+ - 🪄 /flux <prompt>: Generates Any Realistic Ai Images.
2354
+ `;
2355
+
2356
+ bot.editMessageText(helpMessageAdmin, {
2357
+ chat_id: chatId,
2358
+ message_id: query.message.message_id,
2359
+ parse_mode: 'Markdown',
2360
+ reply_markup: {
2361
+ inline_keyboard: [
2362
+ [
2363
+ { text: "⬅️ BACK", callback_data: "help_back_0" },
2364
+ { text: "➡️ NEXT", callback_data: "help_next_2" }
2365
+ ]
2366
+ ]
2367
+ }
2368
+ });
2369
+ }
2370
+
2371
+ // Second "NEXT" button (from Admin Commands to AI Menu)
2372
+ if (query.data === "help_next_2") {
2373
+ const helpMessageAI = `
2374
+ 🛠️ *Admin Commands*:
2375
+ - 👮‍♂️ /kick: Kick a user (reply to their message).
2376
+ - 🤐 /mute: Mute a user (reply to their message).
2377
+ - 🔓 /unmute: Unmute a user (reply to their message).
2378
+ - 📈 /promote: Promote a user to admin (reply to their message).
2379
+ - 📉 /demote: Demote an admin (reply to their message).
2380
+ - 📝 /setname <new name>: Change the group name.
2381
+ - 🔗 /getlink: Get the group invite link.
2382
+ - 🚫 /antilink: Toggle anti-link feature.
2383
+ - 🖼️ /setgrouppic: Change the group picture.
2384
+ - ✏️ /setdescription <text>: Update group description.
2385
+ `;
2386
+
2387
+ bot.editMessageText(helpMessageAI, {
2388
+ chat_id: chatId,
2389
+ message_id: query.message.message_id,
2390
+ parse_mode: 'Markdown',
2391
+ reply_markup: {
2392
+ inline_keyboard: [
2393
+ [
2394
+ { text: "⬅️ BACK", callback_data: "help_back_1" },
2395
+ { text: "➡️ NEXT", callback_data: "help_next_3" }
2396
+ ]
2397
+ ]
2398
+ }
2399
+ });
2400
+ }
2401
+
2402
+ // Third "NEXT" button (from AI Menu to Tools Menu)
2403
+ if (query.data === "help_next_3") {
2404
+ const helpMessageTools = `
2405
+ 🔧 *Special Menu*:
2406
+ - 🥵 /xvideosearch: <query> searches for adult videos
2407
+ - 👙 /xvideodownload: <link> downloads adult videos
2408
+ `;
2409
+
2410
+ bot.editMessageText(helpMessageTools, {
2411
+ chat_id: chatId,
2412
+ message_id: query.message.message_id,
2413
+ parse_mode: 'Markdown',
2414
+ reply_markup: {
2415
+ inline_keyboard: [
2416
+ [
2417
+ { text: "⬅️ BACK", callback_data: "help_back_2" },
2418
+ { text: "➡️ NEXT", callback_data: "help_next_4" }
2419
+ ]
2420
+ ]
2421
+ }
2422
+ });
2423
+ }
2424
+
2425
+ // Third "NEXT" button (from AI Menu to Tools Menu)
2426
+ if (query.data === "help_next_4") {
2427
+ const helpMessageTools = `
2428
+ 🔧 *Tools Menu*:
2429
+ - 📄 /txt2pdf: Convert text to PDF. (coming soon)
2430
+ - 🖇️ /url: Coverts Video, Photo, any file to url
2431
+ - 📸 /ss: screenshots a website
2432
+ - 😍 /remini: Enhances any low quality image
2433
+ - 🥰 /couplepp: sends couples pics
2434
+ - 🖼️ /image: searchs for images on the internet
2435
+ - 🎙️ /shazam: identifies any music on a video or audio file
2436
+ `;
2437
+
2438
+ bot.editMessageText(helpMessageTools, {
2439
+ chat_id: chatId,
2440
+ message_id: query.message.message_id,
2441
+ parse_mode: 'Markdown',
2442
+ reply_markup: {
2443
+ inline_keyboard: [
2444
+ [
2445
+ { text: "⬅️ BACK", callback_data: "help_back_3" },
2446
+ { text: "➡️ NEXT", callback_data: "help_next_5" }
2447
+ ]
2448
+ ]
2449
+ }
2450
+ });
2451
+ }
2452
+
2453
+ // Fourth "NEXT" button (from Tools Menu to Utility Commands)
2454
+ if (query.data === "help_next_5") {
2455
+ const helpMessageUtility = `
2456
+ 📊 *Utility Commands*:
2457
+ - ⏳ /runtime: Check the bot's uptime.
2458
+ - 🏓 /ping: Check bot's response time.
2459
+ - 💸 /currency <amount> <from> to <to>: Convert currencies (e.g., /currency 100 USD to EUR).
2460
+ - 🗑️ /delete: Delete a specific message (reply to it).
2461
+ `;
2462
+
2463
+ bot.editMessageText(helpMessageUtility, {
2464
+ chat_id: chatId,
2465
+ message_id: query.message.message_id,
2466
+ parse_mode: 'Markdown',
2467
+ reply_markup: {
2468
+ inline_keyboard: [
2469
+ [
2470
+ { text: "⬅️ BACK", callback_data: "help_back_4" },
2471
+ { text: "➡️ NEXT", callback_data: "help_next_6" }
2472
+ ]
2473
+ ]
2474
+ }
2475
+ });
2476
+ }
2477
+
2478
+ // Fifth "NEXT" button (from Utility Commands to Other Commands)
2479
+ if (query.data === "help_next_6") {
2480
+ const helpMessageOther = `
2481
+ 🙋‍♂️ *Other Commands*:
2482
+ - 👑 /owner: Show the owner details.
2483
+ - 🤝 /support: Support the developer.
2484
+ - 📢 /tagall: Tag all group members.
2485
+ - 🚀 /start: Welcome message and introduction.
2486
+ - ❓ /help: Show this help menu.
2487
+
2488
+ *ᴘᴏᴡᴇʀᴇᴅ ʙʏ ᴅᴀᴠɪᴅ ᴄʏʀɪʟ ᴛᴇᴄʜ*
2489
+ `;
2490
+
2491
+ bot.editMessageText(helpMessageOther, {
2492
+ chat_id: chatId,
2493
+ message_id: query.message.message_id,
2494
+ parse_mode: 'Markdown',
2495
+ reply_markup: {
2496
+ inline_keyboard: [
2497
+ [
2498
+ { text: "⬅️ BACK", callback_data: "help_back_5" }
2499
+ ]
2500
+ ]
2501
+ }
2502
+ });
2503
+ }
2504
+
2505
+ // Handle "BACK" buttons
2506
+ if (query.data === "help_back_0") {
2507
+ bot.editMessageText(helpMessageDownload, {
2508
+ chat_id: chatId,
2509
+ message_id: query.message.message_id,
2510
+ parse_mode: 'Markdown',
2511
+ reply_markup: {
2512
+ inline_keyboard: [
2513
+ [{ text: "➡️ NEXT", callback_data: "help_next_1" }]
2514
+ ]
2515
+ }
2516
+ });
2517
+ }
2518
+
2519
+ if (query.data === "help_back_1") {
2520
+ const helpMessageAdmin = `
2521
+ 🛠️ *Admin Commands*:
2522
+ - 👮‍♂️ /kick: Kick a user (reply to their message).
2523
+ - 🤐 /mute: Mute a user (reply to their message).
2524
+ - 🔓 /unmute: Unmute a user (reply to their message).
2525
+ - 📈 /promote: Promote a user to admin (reply to their message).
2526
+ - 📉 /demote: Demote an admin (reply to their message).
2527
+ - 📝 /setname <new name>: Change the group name.
2528
+ - 🔗 /getlink: Get the group invite link.
2529
+ - 🚫 /antilink: Toggle anti-link feature.
2530
+ - 🖼️ /setgrouppic: Change the group picture.
2531
+ - ✏️ /setdescription <text>: Update group description.
2532
+ `;
2533
+
2534
+ bot.editMessageText(helpMessageAdmin, {
2535
+ chat_id: chatId,
2536
+ message_id: query.message.message_id,
2537
+ parse_mode: 'Markdown',
2538
+ reply_markup: {
2539
+ inline_keyboard: [
2540
+ [
2541
+ { text: "⬅️ BACK", callback_data: "help_back_0" },
2542
+ { text: "➡️ NEXT", callback_data: "help_next_2" }
2543
+ ]
2544
+ ]
2545
+ }
2546
+ });
2547
+ }
2548
+
2549
+ if (query.data === "help_back_2") {
2550
+ const helpMessageAI = `
2551
+ 🤖 *AI Commands*:
2552
+ - 🤖 /gpt <query>: Answers any question.
2553
+ - 🔊 /text2speech <text>: Convert text to speech. (coming soon)
2554
+ - 🔊 /text2speech <text>: Convert text to speech.
2555
+ - 🪄 /text2image <prompt>: Generates Any Ai Image of your choice.
2556
+ - 🪄 /flux <prompt>: Generates Any Realistic Ai Images.
2557
+ `;
2558
+
2559
+ bot.editMessageText(helpMessageAI, {
2560
+ chat_id: chatId,
2561
+ message_id: query.message.message_id,
2562
+ parse_mode: 'Markdown',
2563
+ reply_markup: {
2564
+ inline_keyboard: [
2565
+ [
2566
+ { text: "⬅️ BACK", callback_data: "help_back_1" },
2567
+ { text: "➡️ NEXT", callback_data: "help_next_3" }
2568
+ ]
2569
+ ]
2570
+ }
2571
+ });
2572
+ }
2573
+
2574
+ if (query.data === "help_back_3") {
2575
+ const helpMessageTools = `
2576
+ 🔧 *Special Menu*:
2577
+ - 🥵 /xvideosearch: <query> searches for adult videos
2578
+ - 👙 /xvideodownload: <link> downloads adult videos
2579
+ `;
2580
+
2581
+ bot.editMessageText(helpMessageTools, {
2582
+ chat_id: chatId,
2583
+ message_id: query.message.message_id,
2584
+ parse_mode: 'Markdown',
2585
+ reply_markup: {
2586
+ inline_keyboard: [
2587
+ [
2588
+ { text: "⬅️ BACK", callback_data: "help_back_2" },
2589
+ { text: "➡️ NEXT", callback_data: "help_next_4" }
2590
+ ]
2591
+ ]
2592
+ }
2593
+ });
2594
+ }
2595
+
2596
+
2597
+ if (query.data === "help_back_3") {
2598
+ const helpMessageTools = `
2599
+ 🔧 *Tools Menu*:
2600
+ - 📄 /txt2pdf: Convert text to PDF.
2601
+ - 🖇️ /url: Coverts Video, Photo, any file to url
2602
+ - 😍 /remini: Enhances any low quality image
2603
+ - 🖼️ /image: searchs for images on the internet
2604
+ - 🎙️ /shazam: identifies any music on a video or audio file
2605
+ `;
2606
+
2607
+ bot.editMessageText(helpMessageTools, {
2608
+ chat_id: chatId,
2609
+ message_id: query.message.message_id,
2610
+ parse_mode: 'Markdown',
2611
+ reply_markup: {
2612
+ inline_keyboard: [
2613
+ [
2614
+ { text: "⬅️ BACK", callback_data: "help_back_2" },
2615
+ { text: "➡️ NEXT", callback_data: "help_next_4" }
2616
+ ]
2617
+ ]
2618
+ }
2619
+ });
2620
+ }
2621
+
2622
+ if (query.data === "help_back_4") {
2623
+ const helpMessageUtility = `
2624
+ 📊 *Utility Commands*:
2625
+ - ⏳ /runtime: Check the bot's uptime.
2626
+ - 🏓 /ping: Check bot's response time.
2627
+ - 💸 /currency <amount> <from> to <to>: Convert currencies (e.g., /currency 100 USD to EUR).
2628
+ - 🗑️ /delete: Delete a specific message (reply to it).
2629
+ `;
2630
+
2631
+ bot.editMessageText(helpMessageUtility, {
2632
+ chat_id: chatId,
2633
+ message_id: query.message.message_id,
2634
+ parse_mode: 'Markdown',
2635
+ reply_markup: {
2636
+ inline_keyboard: [
2637
+ [
2638
+ { text: "⬅️ BACK", callback_data: "help_back_3" },
2639
+ { text: "➡️ NEXT", callback_data: "help_next_5" }
2640
+ ]
2641
+ ]
2642
+ }
2643
+ });
2644
+ }
2645
+ });
package.json CHANGED
@@ -1,95 +1,27 @@
1
  {
2
- "name": "Anita-V4",
3
  "version": "1.0.0",
4
- "description": "Queen Anita V4 - A WhatsApp and Telegram Bot",
5
  "main": "index.js",
6
- "type": "common.js",
7
  "scripts": {
8
- "start": "pm2 start index.js --name Queen_Anita-V4 --deep-monitoring --attach",
9
- "stop": "pm2 stop Queen_Anita-V4",
10
- "restart": "pm2 restart Queen_Anita-V4"
11
  },
12
- "keywords": [
13
- "whatsapp-bot",
14
- "telegram-bot",
15
- "baileys",
16
- "multi-device"
17
- ],
18
- "author": "David Cyril",
19
- "license": "MIT",
20
  "dependencies": {
21
- "@adiwajshing/baileys": "npm:@whiskeysockets/baileys@^6.7.9",
22
- "@hapi/boom": "^10.0.1",
23
- "node-telegram-bot-api": "^0.61.0",
24
- "node-cache": "^5.1.2",
25
- "pino": "^8.17.2",
26
- "axios": "^1.6.7",
27
- "aptoide-scraper": "^1.0.1",
28
- "cfonts": "^3.2.0",
29
- "chalk": "^4.1.2",
30
- "check-disk-space": "^3.3.1",
31
- "cheerio": "^1.0.0-rc.12",
32
- "child_process": "^1.0.2",
33
- "colors": "^1.4.0",
34
- "cookie": "^0.6.0",
35
- "crypto": "^1.0.1",
36
- "d-scrape": "^1.2.0",
37
- "dhn-api": "^1.1.3",
38
- "dotenv": "^16.3.1",
39
- "emoji-regex": "^10.3.0",
40
- "express": "^4.19.2",
41
- "file-type": "^16.5.3",
42
- "fluent-ffmpeg": "^2.1.2",
43
- "@ffmpeg-installer/ffmpeg": "^1.1.0",
44
- "fs-extra": "^10.0.0",
45
- "g-i-s": "^2.1.7",
46
- "g4f": "^1.4.3",
47
- "@vitalets/google-translate-api": "^8.0.0",
48
- "greetify": "^2.0.1",
49
- "https-proxy-agent": "^7.0.4",
50
- "human-readable": "^0.2.1",
51
- "jimp": "^0.16.1",
52
- "jsdom": "^25.0.0",
53
- "lodash": "latest",
54
- "lolcatjs": "^2.4.1",
55
- "lowdb": "^7.0.1",
56
- "moment-timezone": "^0.5.34",
57
- "mal-scraper": "^2.11.4",
58
- "mongoose": "^7.1.1",
59
- "node-cron": "^3.0.3",
60
- "node-fetch": "^2.6.7",
61
- "node-id3": "^0.2.6",
62
- "node-os-utils": "^1.3.6",
63
- "node-webpmux": "^3.1.0",
64
- "node-youtube-music": "^0.10.3",
65
- "object-query-string": "^1.2.0",
66
- "ocr-space-api-wrapper": "^2.2.0",
67
- "os": "^0.1.2",
68
- "path": "^0.12.7",
69
- "perf_hooks": "0.0.1",
70
- "performance-now": "*",
71
- "pm2": "^5.2.0",
72
- "qrcode": "^1.5.3",
73
- "qrcode-reader": "^1.0.4",
74
- "razzaq-suppress": "^1.0.1",
75
- "remove.bg": "^1.3.0",
76
- "removebg-id": "^2.0.1",
77
- "rimraf": "^5.0.5",
78
- "scrape-primbon": "^1.1.0",
79
- "scrape-it": "^6.1.3",
80
- "similarity": "^1.2.1",
81
- "string-similarity": "^4.0.4",
82
- "util": "^0.12.5",
83
- "wa-sticker-formatter": "^4.4.4",
84
- "socks-proxy-agent": "^8.0.3",
85
- "steno": "^1.0.0",
86
- "syntax-error": "^1.4.0",
87
- "yargs": "^17.7.2",
88
- "youtube-yts": "^2.0.0",
89
- "youtubedl-core": "^4.11.7",
90
  "yt-search": "^2.12.1"
91
- },
 
92
  "engines": {
93
- "node": ">=14.0.0"
94
  }
95
  }
 
1
  {
2
+ "name": "Ebar-",
3
  "version": "1.0.0",
 
4
  "main": "index.js",
 
5
  "scripts": {
6
+ "start": "node bot.js",
7
+ "test": "echo \"Error: no test specified\" && exit 1"
 
8
  },
9
+ "keywords": [],
10
+ "author": "",
11
+ "license": "ISC",
12
+ "description": "",
 
 
 
 
13
  "dependencies": {
14
+ "axios": "^1.7.7",
15
+ "crypto": "^1.0.1",
16
+ "express": "^4.21.1",
17
+ "form-data": "^4.0.0",
18
+ "mrnima-moviedl": "1.0.0",
19
+ "node-telegram-bot-api": "^0.66.0",
20
+ "webtorrent": "^2.5.10",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  "yt-search": "^2.12.1"
22
+ },
23
+ "keywords": ["Atomic", "bot", "Telegram", "multi-device"],
24
  "engines": {
25
+ "node": "22.x"
26
  }
27
  }