|
import os |
|
from telegram import Update |
|
from telegram.ext import Application, CommandHandler, ContextTypes |
|
import logging |
|
import threading |
|
|
|
|
|
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO) |
|
logger = logging.getLogger(__name__) |
|
|
|
|
|
BOT_TOKEN = "6655373829:AAGduLdLyNx7zUtxH73Sp3Z1vHKS35tV9WU" |
|
if not BOT_TOKEN: |
|
raise ValueError("Bot token is not set in environment variables") |
|
|
|
|
|
application = Application.builder().token(BOT_TOKEN).build() |
|
|
|
|
|
def start(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: |
|
"""Sends a welcome message when the user starts the bot.""" |
|
update.message.reply_text("Hello! This bot is running in synchronous mode π") |
|
|
|
|
|
application.add_handler(CommandHandler("start", start)) |
|
|
|
|
|
def start_polling(): |
|
|
|
application.run_polling() |
|
|
|
|
|
thread = threading.Thread(target=start_polling) |
|
thread.start() |
|
|
|
|
|
print("Bot is actively running and polling Telegram.") |
|
|