arbab786000 commited on
Commit
26ba6d0
Β·
verified Β·
1 Parent(s): 87915b8

Update bot.js

Browse files
Files changed (1) hide show
  1. bot.js +21 -27
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
- // Real-time Withdrawal Notification
 
 
 
 
 
 
 
 
 
 
 
17
  db.ref('withdrawals').on('child_changed', (snapshot) => {
18
  const data = snapshot.val();
19
- // Jab status "completed" ho, sirf tab message bheje
20
- if (data.status === 'completed') {
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
- // Fake Notifications (Har 20 minute baad)
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
- bot.launch().then(() => {
48
- console.log("Bot running perfectly!");
49
- });
 
50
 
51
- // Enable graceful stop
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'));