Spaces:
Runtime error
Runtime error
Update bot.js
Browse files
bot.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
-
require('dotenv').config();
|
| 2 |
const { Telegraf } = require('telegraf');
|
| 3 |
const admin = require('firebase-admin');
|
| 4 |
|
|
@@ -10,44 +9,39 @@ admin.initializeApp({
|
|
| 10 |
});
|
| 11 |
|
| 12 |
const db = admin.database();
|
| 13 |
-
const bot = new Telegraf(process.env.BOT_TOKEN);
|
| 14 |
-
const GROUP_ID = process.env.GROUP_ID;
|
| 15 |
|
| 16 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
db.ref('withdrawals').on('child_changed', (snapshot) => {
|
| 18 |
const data = snapshot.val();
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
bot.telegram.sendMessage(GROUP_ID, `π *New Payout Approved!*\n\nπ€ User: ${data.name}\nπ° Amount: ${data.amount} Coins\nπ³ Gateway: ${data.gateway}\nβ
Status: Money Sent!`, { parse_mode: 'Markdown' });
|
| 22 |
}
|
| 23 |
});
|
| 24 |
|
| 25 |
-
//
|
| 26 |
-
const names = ["Arbab", "Ali", "Sara", "Zain", "Fatima", "Hassan", "Bilal", "Ayesha"];
|
| 27 |
-
const gateways = ["JazzCash", "EasyPaisa", "Bank"];
|
| 28 |
-
|
| 29 |
-
setInterval(() => {
|
| 30 |
-
const name = names[Math.floor(Math.random() * names.length)];
|
| 31 |
-
const amt = Math.floor(Math.random() * 3000) + 200;
|
| 32 |
-
const gate = gateways[Math.floor(Math.random() * gateways.length)];
|
| 33 |
-
|
| 34 |
-
bot.telegram.sendMessage(GROUP_ID, `π ${name} ne ${amt} Coins ka withdraw liya via ${gate}! #PaymentReceived`);
|
| 35 |
-
}, 1200000); // 20 minutes in ms
|
| 36 |
-
|
| 37 |
-
// Manual Announcement Command
|
| 38 |
bot.command('announce', (ctx) => {
|
| 39 |
const msg = ctx.message.text.split('/announce ')[1];
|
| 40 |
if(msg) {
|
| 41 |
-
bot.telegram.sendMessage(GROUP_ID, `π’ *Update:* ${msg}`, { parse_mode: 'Markdown' });
|
| 42 |
-
} else {
|
| 43 |
-
ctx.reply('Please provide message: /announce [Your Message]');
|
| 44 |
}
|
| 45 |
});
|
| 46 |
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
|
|
|
| 50 |
|
| 51 |
-
//
|
| 52 |
process.once('SIGINT', () => bot.stop('SIGINT'));
|
| 53 |
process.once('SIGTERM', () => bot.stop('SIGTERM'));
|
|
|
|
|
|
|
| 1 |
const { Telegraf } = require('telegraf');
|
| 2 |
const admin = require('firebase-admin');
|
| 3 |
|
|
|
|
| 9 |
});
|
| 10 |
|
| 11 |
const db = admin.database();
|
|
|
|
|
|
|
| 12 |
|
| 13 |
+
// Token hardcode kiya hai taake Hugging Face Secrets ka masla na ho
|
| 14 |
+
const BOT_TOKEN = '8860661202:AAE_hly4Oe8iiPYqt-JthOUrV6Y3NMCP1MQ';
|
| 15 |
+
const GROUP_ID = '-1003982899668';
|
| 16 |
+
|
| 17 |
+
const bot = new Telegraf(BOT_TOKEN, {
|
| 18 |
+
telegram: {
|
| 19 |
+
agent: null, // Connection reset se bachne ke liye
|
| 20 |
+
apiRoot: 'https://api.telegram.org'
|
| 21 |
+
}
|
| 22 |
+
});
|
| 23 |
+
|
| 24 |
+
// Firebase Listener
|
| 25 |
db.ref('withdrawals').on('child_changed', (snapshot) => {
|
| 26 |
const data = snapshot.val();
|
| 27 |
+
if (data && data.status === 'completed') {
|
| 28 |
+
bot.telegram.sendMessage(GROUP_ID, `π *New Payout Approved!*\n\nπ€ User: ${data.name}\nπ° Amount: ${data.amount} Coins\nβ
Status: Money Sent!`, { parse_mode: 'Markdown' }).catch(console.error);
|
|
|
|
| 29 |
}
|
| 30 |
});
|
| 31 |
|
| 32 |
+
// Announce Command
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
bot.command('announce', (ctx) => {
|
| 34 |
const msg = ctx.message.text.split('/announce ')[1];
|
| 35 |
if(msg) {
|
| 36 |
+
bot.telegram.sendMessage(GROUP_ID, `π’ *Update:* ${msg}`, { parse_mode: 'Markdown' }).catch(console.error);
|
|
|
|
|
|
|
| 37 |
}
|
| 38 |
});
|
| 39 |
|
| 40 |
+
// Bot Launch
|
| 41 |
+
bot.launch()
|
| 42 |
+
.then(() => console.log("Bot running perfectly!"))
|
| 43 |
+
.catch((err) => console.error("Bot Launch Error:", err));
|
| 44 |
|
| 45 |
+
// Graceful stop
|
| 46 |
process.once('SIGINT', () => bot.stop('SIGINT'));
|
| 47 |
process.once('SIGTERM', () => bot.stop('SIGTERM'));
|