Spaces:
Sleeping
Sleeping
Fix errors
Browse files- app.py +13 -8
- requirements.txt +3 -2
app.py
CHANGED
|
@@ -68,15 +68,20 @@ async def handle_photo(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
|
| 68 |
|
| 69 |
# --- RUNNER ---
|
| 70 |
if __name__ == '__main__':
|
| 71 |
-
# 1. Jalankan
|
| 72 |
Thread(target=run_web_server).start()
|
| 73 |
|
| 74 |
-
# 2.
|
| 75 |
token = os.getenv("TELEGRAM_BOT_TOKEN")
|
| 76 |
-
app = ApplicationBuilder().token(token).build()
|
| 77 |
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
|
| 69 |
# --- RUNNER ---
|
| 70 |
if __name__ == '__main__':
|
| 71 |
+
# 1. Jalankan server Flask
|
| 72 |
Thread(target=run_web_server).start()
|
| 73 |
|
| 74 |
+
# 2. Ambil token
|
| 75 |
token = os.getenv("TELEGRAM_BOT_TOKEN")
|
|
|
|
| 76 |
|
| 77 |
+
if not token:
|
| 78 |
+
print("ERROR: TELEGRAM_BOT_TOKEN tidak ditemukan di Secrets!")
|
| 79 |
+
else:
|
| 80 |
+
# Inisialisasi bot dengan timeout lebih lama agar tidak gampang NetworkError
|
| 81 |
+
app = ApplicationBuilder().token(token).read_timeout(30).connect_timeout(30).build()
|
| 82 |
+
|
| 83 |
+
app.add_handler(CommandHandler("start", start))
|
| 84 |
+
app.add_handler(MessageHandler(filters.PHOTO, handle_photo))
|
| 85 |
+
|
| 86 |
+
print("Bot sedang berjalan...")
|
| 87 |
+
app.run_polling()
|
requirements.txt
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
-
python-telegram-bot
|
| 2 |
google-generativeai
|
| 3 |
supabase
|
|
|
|
| 4 |
python-dotenv
|
| 5 |
-
|
|
|
|
| 1 |
+
python-telegram-bot==21.1
|
| 2 |
google-generativeai
|
| 3 |
supabase
|
| 4 |
+
flask
|
| 5 |
python-dotenv
|
| 6 |
+
httpx[http2]
|