Spaces:
Runtime error
Runtime error
Update bot.py
Browse files39 unmodified lines404142434445464748495051525354555657585939 unmodified linesawait update.message.reply_text(ai_reply)# Start the bot directly with modern background runner compatibilityif not TELEGRAM_TOKEN or not NVIDIA_API_KEY:print("β Error: Missing Environment Variables!")else:app = ApplicationBuilder().token(TELEGRAM_TOKEN).build()app.add_handler(CommandHandler("start", start))app.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, chat))print("π Nemotron 3 Super Bot is running...")try:loop = asyncio.get_event_loop()if loop.is_running():asyncio.ensure_future(app.run_polling())else:app.run_polling()except Exception:app.run_polling()39 unmodified lines4041424344454647484950515253545556575859606162636465666768697039 unmodified linesawait update.message.reply_text(ai_reply)async def main():if not TELEGRAM_TOKEN or not NVIDIA_API_KEY:print("β Error: Missing Environment Variables!")return# Build application with network timeout safeguardsapp = ApplicationBuilder().token(TELEGRAM_TOKEN).build()app.add_handler(CommandHandler("start", start))app.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, chat))print("π Nemotron 3 Super Bot is starting...")# Initialize and start polling cleanly within an explicit async cycleasync with app:await app.initialize()await app.start()print("π Nemotron 3 Super Bot is running live!")await app.updater.start_polling()# Keep the background process alive infinitelywhile True:await asyncio.sleep(3600)if _name_ == "_main_":try:asyncio.run(main())except KeyboardInterrupt:print("Bot stopped manually."
bot.py+23-12