yangtb24 commited on
Commit
51add1d
·
verified ·
1 Parent(s): 4a033a7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -235,7 +235,7 @@ async def processAiMessage(chatId, userMessage, fromUserId, message_id):
235
  *history
236
  ]
237
 
238
- thinking_message = await sendTelegramMessage(chatId, "正在思考,请等待...", reply_to_message_id=message_id)
239
  thinking_message_id = thinking_message.get('result', {}).get('message_id')
240
 
241
  try:
@@ -260,7 +260,6 @@ async def processAiMessage(chatId, userMessage, fromUserId, message_id):
260
  print(f'处理消息时发生错误: {error}')
261
  await editTelegramMessage(chatId, thinking_message_id, '处理消息时发生错误,请稍后再试')
262
 
263
-
264
  async def handleAiResponse(ai_data, chatId, history):
265
  if ai_data and ai_data.get('choices') and len(ai_data['choices']) > 0:
266
  choice = ai_data['choices'][0]
@@ -285,13 +284,15 @@ async def handleCallbackQuery(callbackQuery):
285
  async def sendTelegramMessage(chatId, text, options={}):
286
  url = f"https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/sendMessage"
287
  if PHP_PROXY_URL:
288
- method_name = url.split('/')[-1]
289
- url = f"{PHP_PROXY_URL}{method_name}"
 
290
  data = {
291
  'chat_id': chatId,
292
  'text': text,
293
  **options
294
  }
 
295
  try:
296
  response = requests.post(url, headers={'Content-Type': 'application/json'}, json=data)
297
  response.raise_for_status()
 
235
  *history
236
  ]
237
 
238
+ thinking_message = await sendTelegramMessage(chatId, "正在思考,请等待...", options={'reply_to_message_id': message_id})
239
  thinking_message_id = thinking_message.get('result', {}).get('message_id')
240
 
241
  try:
 
260
  print(f'处理消息时发生错误: {error}')
261
  await editTelegramMessage(chatId, thinking_message_id, '处理消息时发生错误,请稍后再试')
262
 
 
263
  async def handleAiResponse(ai_data, chatId, history):
264
  if ai_data and ai_data.get('choices') and len(ai_data['choices']) > 0:
265
  choice = ai_data['choices'][0]
 
284
  async def sendTelegramMessage(chatId, text, options={}):
285
  url = f"https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/sendMessage"
286
  if PHP_PROXY_URL:
287
+ method_name = url.split('/')[-1]
288
+ url = f"{PHP_PROXY_URL}{method_name}"
289
+
290
  data = {
291
  'chat_id': chatId,
292
  'text': text,
293
  **options
294
  }
295
+
296
  try:
297
  response = requests.post(url, headers={'Content-Type': 'application/json'}, json=data)
298
  response.raise_for_status()