Update chatbot/plugins/chat.py
Browse files- chatbot/plugins/chat.py +6 -2
chatbot/plugins/chat.py
CHANGED
@@ -40,6 +40,7 @@ import datetime
|
|
40 |
from chatbot import send_log
|
41 |
from openai import AsyncOpenAI as openai
|
42 |
import akenoai.openai as akeno
|
|
|
43 |
|
44 |
@Client.on_message(
|
45 |
~filters.scheduled
|
@@ -77,6 +78,7 @@ async def rmchatbot_user(client: Client, message: Message):
|
|
77 |
& ~filters.forwarded,
|
78 |
group=2,
|
79 |
)
|
|
|
80 |
async def chatbot_talk(client: Client, message: Message):
|
81 |
chat_user = await db.get_chatbot(message.chat.id)
|
82 |
if not chat_user:
|
@@ -85,6 +87,7 @@ async def chatbot_talk(client: Client, message: Message):
|
|
85 |
if message.reply_to_message.from_user.id != client.me.id:
|
86 |
return
|
87 |
if message.text:
|
|
|
88 |
await client.send_chat_action(message.chat.id, enums.ChatAction.TYPING)
|
89 |
await asyncio.sleep(1.5)
|
90 |
query = message.text.strip()
|
@@ -115,9 +118,10 @@ async def chatbot_talk(client: Client, message: Message):
|
|
115 |
document="chat.txt",
|
116 |
disable_notification=True
|
117 |
)
|
|
|
118 |
os.remove("chat.txt")
|
119 |
else:
|
120 |
-
await
|
121 |
backup_chat.append({"role": "assistant", "content": output})
|
122 |
user_detail = (
|
123 |
f"**Akeno GPT Bot**\n"
|
@@ -134,4 +138,4 @@ async def chatbot_talk(client: Client, message: Message):
|
|
134 |
await client.send_chat_action(message.chat.id, enums.ChatAction.CANCEL)
|
135 |
return
|
136 |
except Exception as e:
|
137 |
-
return await
|
|
|
40 |
from chatbot import send_log
|
41 |
from openai import AsyncOpenAI as openai
|
42 |
import akenoai.openai as akeno
|
43 |
+
import akenoai.logger as akeno_log
|
44 |
|
45 |
@Client.on_message(
|
46 |
~filters.scheduled
|
|
|
78 |
& ~filters.forwarded,
|
79 |
group=2,
|
80 |
)
|
81 |
+
@akeno_log.log_perfomance
|
82 |
async def chatbot_talk(client: Client, message: Message):
|
83 |
chat_user = await db.get_chatbot(message.chat.id)
|
84 |
if not chat_user:
|
|
|
87 |
if message.reply_to_message.from_user.id != client.me.id:
|
88 |
return
|
89 |
if message.text:
|
90 |
+
pro = await message.reply("Processing your request...", quote=True)
|
91 |
await client.send_chat_action(message.chat.id, enums.ChatAction.TYPING)
|
92 |
await asyncio.sleep(1.5)
|
93 |
query = message.text.strip()
|
|
|
118 |
document="chat.txt",
|
119 |
disable_notification=True
|
120 |
)
|
121 |
+
await pro.delete()
|
122 |
os.remove("chat.txt")
|
123 |
else:
|
124 |
+
await pro.edit_text(output)
|
125 |
backup_chat.append({"role": "assistant", "content": output})
|
126 |
user_detail = (
|
127 |
f"**Akeno GPT Bot**\n"
|
|
|
138 |
await client.send_chat_action(message.chat.id, enums.ChatAction.CANCEL)
|
139 |
return
|
140 |
except Exception as e:
|
141 |
+
return await pro.edit_text(f"Error: {e}")
|