yangtb24 commited on
Commit
ddfafd1
·
verified ·
1 Parent(s): 6b35815

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -12
app.py CHANGED
@@ -83,8 +83,7 @@ UNBAN_PHRASE = "close username"
83
  def make_telegram_request(method, data=None):
84
  url = f"https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/{method}"
85
  if PHP_PROXY_URL:
86
- method_name = url.split('/')[-1]
87
- url = f"{PHP_PROXY_URL}{method_name}"
88
  headers = {'Content-Type': 'application/json'}
89
  if data:
90
  data = json.dumps(data)
@@ -103,10 +102,8 @@ async def setBotCommands():
103
  delete_url = f"https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/deleteMyCommands"
104
  set_url = f"https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/setMyCommands"
105
  if PHP_PROXY_URL:
106
- delete_method_name = delete_url.split('/')[-1]
107
- set_method_name = set_url.split('/')[-1]
108
- delete_url = f"{PHP_PROXY_URL}{delete_method_name}"
109
- set_url = f"{PHP_PROXY_URL}{set_method_name}"
110
 
111
  try:
112
  delete_response = make_telegram_request('deleteMyCommands')
@@ -368,8 +365,7 @@ async def handleCallbackQuery(callbackQuery):
368
  async def sendTelegramMessage(chatId, text, options={}):
369
  url = f"https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/sendMessage"
370
  if PHP_PROXY_URL:
371
- method_name = url.split('/')[-1]
372
- url = f"{PHP_PROXY_URL}{method_name}"
373
 
374
  data = {
375
  'chat_id': chatId,
@@ -388,8 +384,7 @@ async def sendTelegramMessage(chatId, text, options={}):
388
  async def editTelegramMessage(chatId, message_id, text, options={}):
389
  url = f"https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/editMessageText"
390
  if PHP_PROXY_URL:
391
- method_name = url.split('/')[-1]
392
- url = f"{PHP_PROXY_URL}{method_name}"
393
  data = {
394
  'chat_id': chatId,
395
  'message_id': message_id,
@@ -457,8 +452,7 @@ def health_check():
457
  async def getChatInfo(chatId):
458
  url = f"https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/getChat"
459
  if PHP_PROXY_URL:
460
- method_name = url.split('/')[-1]
461
- url = f"{PHP_PROXY_URL}{method_name}"
462
  data = {
463
  'chat_id': chatId,
464
  }
 
83
  def make_telegram_request(method, data=None):
84
  url = f"https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/{method}"
85
  if PHP_PROXY_URL:
86
+ url = f"{PHP_PROXY_URL}{method}" # 直接使用方法名拼接
 
87
  headers = {'Content-Type': 'application/json'}
88
  if data:
89
  data = json.dumps(data)
 
102
  delete_url = f"https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/deleteMyCommands"
103
  set_url = f"https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/setMyCommands"
104
  if PHP_PROXY_URL:
105
+ delete_url = f"{PHP_PROXY_URL}deleteMyCommands"
106
+ set_url = f"{PHP_PROXY_URL}setMyCommands"
 
 
107
 
108
  try:
109
  delete_response = make_telegram_request('deleteMyCommands')
 
365
  async def sendTelegramMessage(chatId, text, options={}):
366
  url = f"https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/sendMessage"
367
  if PHP_PROXY_URL:
368
+ url = f"{PHP_PROXY_URL}sendMessage"
 
369
 
370
  data = {
371
  'chat_id': chatId,
 
384
  async def editTelegramMessage(chatId, message_id, text, options={}):
385
  url = f"https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/editMessageText"
386
  if PHP_PROXY_URL:
387
+ url = f"{PHP_PROXY_URL}editMessageText"
 
388
  data = {
389
  'chat_id': chatId,
390
  'message_id': message_id,
 
452
  async def getChatInfo(chatId):
453
  url = f"https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/getChat"
454
  if PHP_PROXY_URL:
455
+ url = f"{PHP_PROXY_URL}getChat"
 
456
  data = {
457
  'chat_id': chatId,
458
  }