Spaces:
Runtime error
Runtime error
Download bot.js from arbab786000/IndoTaskTelegrambot: direct link, hf CLI and curl.
- Browser
- Download file 1.63 kB
-
https://huggingface.co/spaces/arbab786000/IndoTaskTelegrambot/resolve/main/bot.js
- Command line
-
hf download hf://spaces/arbab786000/IndoTaskTelegrambot/bot.js
-
curl -L -o bot.js https://huggingface.co/spaces/arbab786000/IndoTaskTelegrambot/resolve/main/bot.js
1.63 kB
| const { Telegraf } = require('telegraf'); | |
| const admin = require('firebase-admin'); | |
| // Firebase Setup | |
| const serviceAccount = require('./serviceAccountKey.json'); | |
| admin.initializeApp({ | |
| credential: admin.credential.cert(serviceAccount), | |
| databaseURL: "https://indoneshia-project-default-rtdb.firebaseio.com" | |
| }); | |
| const db = admin.database(); | |
| // Token hardcode kiya hai taake Hugging Face Secrets ka masla na ho | |
| const BOT_TOKEN = '8860661202:AAE_hly4Oe8iiPYqt-JthOUrV6Y3NMCP1MQ'; | |
| const GROUP_ID = '-1003982899668'; | |
| const bot = new Telegraf(BOT_TOKEN, { | |
| telegram: { | |
| agent: null, // Connection reset se bachne ke liye | |
| apiRoot: 'https://api.telegram.org' | |
| } | |
| }); | |
| // Firebase Listener | |
| db.ref('withdrawals').on('child_changed', (snapshot) => { | |
| const data = snapshot.val(); | |
| if (data && data.status === 'completed') { | |
| 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); | |
| } | |
| }); | |
| // Announce Command | |
| bot.command('announce', (ctx) => { | |
| const msg = ctx.message.text.split('/announce ')[1]; | |
| if(msg) { | |
| bot.telegram.sendMessage(GROUP_ID, `📢 *Update:* ${msg}`, { parse_mode: 'Markdown' }).catch(console.error); | |
| } | |
| }); | |
| // Bot Launch | |
| bot.launch() | |
| .then(() => console.log("Bot running perfectly!")) | |
| .catch((err) => console.error("Bot Launch Error:", err)); | |
| // Graceful stop | |
| process.once('SIGINT', () => bot.stop('SIGINT')); | |
| process.once('SIGTERM', () => bot.stop('SIGTERM')); |