yangtb24 commited on
Commit
25af302
·
verified ·
1 Parent(s): 1042122

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -7,6 +7,7 @@ from datetime import datetime
7
 
8
  import aiohttp
9
  from telegram import Bot, Update
 
10
  from telegram.ext import (
11
  Application,
12
  CommandHandler,
@@ -569,7 +570,8 @@ async def main():
569
  return
570
 
571
  # 修改这里
572
- application = Application.builder().token(TELEGRAM_BOT_TOKEN).request(httpx.AsyncClient(trust_env=True)).build()
 
573
 
574
  # Set bot commands
575
  try:
@@ -599,7 +601,7 @@ async def main():
599
  application.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, handle_telegram_update))
600
 
601
  # Initialize the bot
602
- await initialize_with_retry(application)
603
  # Start the bot
604
  await application.start()
605
  # Start polling updates from Telegram
 
7
 
8
  import aiohttp
9
  from telegram import Bot, Update
10
+ from telegram.request import HTTPXRequest
11
  from telegram.ext import (
12
  Application,
13
  CommandHandler,
 
570
  return
571
 
572
  # 修改这里
573
+ request = HTTPXRequest(http_client=httpx.AsyncClient(trust_env=True))
574
+ application = Application.builder().token(TELEGRAM_BOT_TOKEN).request(request).build()
575
 
576
  # Set bot commands
577
  try:
 
601
  application.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, handle_telegram_update))
602
 
603
  # Initialize the bot
604
+ await application.initialize()
605
  # Start the bot
606
  await application.start()
607
  # Start polling updates from Telegram