45 lines
1.3 KiB
Python
45 lines
1.3 KiB
Python
import asyncio
|
|
import logging
|
|
from telegram import Update
|
|
from telegram.ext import ApplicationBuilder, CommandHandler, ContextTypes
|
|
|
|
logging.basicConfig(level=logging.INFO)
|
|
|
|
BOT_TOKEN = "7864875699:AAEWf6ff1DYNzPvW6Dbn7D2W5aavg9KPhgY"
|
|
|
|
async def start(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
|
await update.message.reply_text("✅ Simple test works!")
|
|
|
|
async def main():
|
|
print("🧪 Testing Telegram connection...")
|
|
try:
|
|
app = ApplicationBuilder()\
|
|
.token(BOT_TOKEN)\
|
|
.read_timeout(30)\
|
|
.write_timeout(30)\
|
|
.connect_timeout(30)\
|
|
.pool_timeout(30)\
|
|
.build()
|
|
|
|
app.add_handler(CommandHandler("start", start))
|
|
|
|
print("🤖 Starting bot...")
|
|
await app.initialize()
|
|
await app.start()
|
|
print("✅ Bot started! Type /start in Telegram to test.")
|
|
print("⏳ Running for 15 seconds...")
|
|
|
|
# Run for 15 seconds
|
|
await asyncio.sleep(15)
|
|
|
|
await app.stop()
|
|
await app.shutdown()
|
|
print("✅ Test complete - no network errors!")
|
|
|
|
except Exception as e:
|
|
print(f"❌ Error: {e}")
|
|
print("\n💡 Try: pip install python-telegram-bot==13.15")
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(main())
|