added database connection

This commit is contained in:
Hosein
2025-12-26 11:17:52 +03:30
parent b4c3ad40dc
commit b16ed91822
7 changed files with 140 additions and 34 deletions
+27
View File
@@ -0,0 +1,27 @@
import os
import requests
from bot import get_bot
from dotenv import load_dotenv
load_dotenv()
BOT_TOKEN = os.environ.get("BOT_TOKEN")
def ensure_no_webhook():
"""Remove webhook before starting polling"""
response = requests.post(
f"https://api.telegram.org/bot{BOT_TOKEN}/deleteWebhook"
)
if response.json()['ok']:
print("✅ Webhook removed, starting polling...")
return True
print("⚠️ Warning: Could not remove webhook")
return False
if __name__ == "__main__":
if ensure_no_webhook():
bot = get_bot()
print("🤖 Bot is polling locally...")
bot.polling(non_stop=True)