Spaces:
Runtime error
Runtime error
File size: 1,634 Bytes
25f46a6 26ba6d0 25f46a6 26ba6d0 25f46a6 26ba6d0 25f46a6 26ba6d0 25f46a6 26ba6d0 25f46a6 26ba6d0 25f46a6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | 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')); |