randydev commited on
Commit
190e25c
·
verified ·
1 Parent(s): b66e1d7

Update chatbot/plugins/chat.py

Browse files
Files changed (1) hide show
  1. chatbot/plugins/chat.py +12 -10
chatbot/plugins/chat.py CHANGED
@@ -268,17 +268,13 @@ async def askcmd(client: Client, message: Message):
268
  except Exception as e:
269
  return await pro.edit_text(f"Error: {e}")
270
 
271
- @Client.on_message(filters.text & filters.business)
272
- async def bussines_bot(client: Client, message: Message):
273
- LOGS.info(f"Update: {message}")
274
-
275
  @Client.on_message(
276
  filters.incoming
277
  & (
278
  filters.text
279
  | filters.regex(r"\b(Randy|Rendi)\b(.*)", flags=re.IGNORECASE)
280
  )
281
- & (filters.private | filters.group)
282
  & filters.reply
283
  & ~filters.command(DISABLE_COMMAND)
284
  & ~filters.bot
@@ -290,12 +286,11 @@ async def bussines_bot(client: Client, message: Message):
290
  @akeno_log.log_performance
291
  async def chatbot_talk(client: Client, message: Message):
292
  chat_user = await db.get_chatbot(message.chat.id)
293
- pro = await message.reply("Processing your request...", quote=True)
294
  user_id = message.from_user.id
295
  user = await users_collection.find_one({"user_id": user_id})
296
  lang = user.get("language") if user else LANGUAGES_DEFAULT
297
  if not chat_user:
298
- await pro.edit_text("Ok disable")
299
  return
300
  if message.reply_to_message and message.reply_to_message.from_user:
301
  if message.reply_to_message.from_user.id != client.me.id:
@@ -329,12 +324,16 @@ async def chatbot_talk(client: Client, message: Message):
329
  out_file.write(output)
330
  await message.reply_document(
331
  document="chat.txt",
 
332
  disable_notification=True
333
  )
334
- await pro.delete()
335
  os.remove("chat.txt")
336
  else:
337
- await pro.edit_text(output, disable_web_page_preview=True)
 
 
 
 
338
  backup_chat.append({"role": "assistant", "content": output})
339
  user_detail = (
340
  f"**Akeno GPT Bot**\n"
@@ -351,4 +350,7 @@ async def chatbot_talk(client: Client, message: Message):
351
  await client.send_chat_action(message.chat.id, enums.ChatAction.CANCEL)
352
  return
353
  except Exception as e:
354
- return await pro.edit_text(f"Error: {e}")
 
 
 
 
268
  except Exception as e:
269
  return await pro.edit_text(f"Error: {e}")
270
 
 
 
 
 
271
  @Client.on_message(
272
  filters.incoming
273
  & (
274
  filters.text
275
  | filters.regex(r"\b(Randy|Rendi)\b(.*)", flags=re.IGNORECASE)
276
  )
277
+ & (filters.private | filters.group | filters.business)
278
  & filters.reply
279
  & ~filters.command(DISABLE_COMMAND)
280
  & ~filters.bot
 
286
  @akeno_log.log_performance
287
  async def chatbot_talk(client: Client, message: Message):
288
  chat_user = await db.get_chatbot(message.chat.id)
 
289
  user_id = message.from_user.id
290
  user = await users_collection.find_one({"user_id": user_id})
291
  lang = user.get("language") if user else LANGUAGES_DEFAULT
292
  if not chat_user:
293
+ await message.reply_text("Ok disable")
294
  return
295
  if message.reply_to_message and message.reply_to_message.from_user:
296
  if message.reply_to_message.from_user.id != client.me.id:
 
324
  out_file.write(output)
325
  await message.reply_document(
326
  document="chat.txt",
327
+ business_connection_id=message.business_connection_id if message else None,
328
  disable_notification=True
329
  )
 
330
  os.remove("chat.txt")
331
  else:
332
+ await message.reply_text(
333
+ output,
334
+ business_connection_id=message.business_connection_id if message else None,
335
+ disable_web_page_preview=True
336
+ )
337
  backup_chat.append({"role": "assistant", "content": output})
338
  user_detail = (
339
  f"**Akeno GPT Bot**\n"
 
350
  await client.send_chat_action(message.chat.id, enums.ChatAction.CANCEL)
351
  return
352
  except Exception as e:
353
+ return await message.reply_text(
354
+ f"Error: {e}",
355
+ business_connection_id=message.business_connection_id if message else None
356
+ )