Update chatbot/plugins/chat.py
Browse files- chatbot/plugins/chat.py +6 -1
chatbot/plugins/chat.py
CHANGED
@@ -88,6 +88,7 @@ I am ready to be a gemini bot developer
|
|
88 |
|
89 |
- Command: /onchat (pm or group)
|
90 |
- Command: /offchat (pm or group)
|
|
|
91 |
"""
|
92 |
|
93 |
class TaskManager:
|
@@ -503,9 +504,11 @@ async def chatbot_talk(client: Client, message: Message):
|
|
503 |
if message.video:
|
504 |
await handle_video(client, message, model_)
|
505 |
if message.text:
|
|
|
506 |
await client.send_chat_action(message.chat.id, enums.ChatAction.TYPING)
|
507 |
await asyncio.sleep(1.5)
|
508 |
query = message.text.strip()
|
|
|
509 |
match = re.search(r"\b(Randy|Rendi)\b(.*)", query, flags=re.IGNORECASE)
|
510 |
if match:
|
511 |
rest_of_sentence = match.group(2).strip()
|
@@ -531,13 +534,15 @@ async def chatbot_talk(client: Client, message: Message):
|
|
531 |
document="chat.txt",
|
532 |
disable_notification=True
|
533 |
)
|
|
|
534 |
os.remove("chat.txt")
|
535 |
else:
|
|
|
536 |
await message.reply_text(output, disable_web_page_preview=True)
|
537 |
backup_chat.append({"role": "model", "parts": [{"text": output}]})
|
538 |
await db._update_chatbot_chat_in_db(message.from_user.id, backup_chat)
|
539 |
await client.send_chat_action(message.chat.id, enums.ChatAction.CANCEL)
|
540 |
return
|
541 |
except Exception as e:
|
|
|
542 |
return await message.reply_text(f"Error: {e}")
|
543 |
-
|
|
|
88 |
|
89 |
- Command: /onchat (pm or group)
|
90 |
- Command: /offchat (pm or group)
|
91 |
+
- Command: /setmodel to change model
|
92 |
"""
|
93 |
|
94 |
class TaskManager:
|
|
|
504 |
if message.video:
|
505 |
await handle_video(client, message, model_)
|
506 |
if message.text:
|
507 |
+
think_typing = "Think...."
|
508 |
await client.send_chat_action(message.chat.id, enums.ChatAction.TYPING)
|
509 |
await asyncio.sleep(1.5)
|
510 |
query = message.text.strip()
|
511 |
+
close_typ = await message.reply_text(think_typing)
|
512 |
match = re.search(r"\b(Randy|Rendi)\b(.*)", query, flags=re.IGNORECASE)
|
513 |
if match:
|
514 |
rest_of_sentence = match.group(2).strip()
|
|
|
534 |
document="chat.txt",
|
535 |
disable_notification=True
|
536 |
)
|
537 |
+
await close_typ.delete()
|
538 |
os.remove("chat.txt")
|
539 |
else:
|
540 |
+
await close_typ.delete()
|
541 |
await message.reply_text(output, disable_web_page_preview=True)
|
542 |
backup_chat.append({"role": "model", "parts": [{"text": output}]})
|
543 |
await db._update_chatbot_chat_in_db(message.from_user.id, backup_chat)
|
544 |
await client.send_chat_action(message.chat.id, enums.ChatAction.CANCEL)
|
545 |
return
|
546 |
except Exception as e:
|
547 |
+
await close_typ.delete()
|
548 |
return await message.reply_text(f"Error: {e}")
|
|