Update chatbot/plugins/chat.py
Browse files- chatbot/plugins/chat.py +6 -0
chatbot/plugins/chat.py
CHANGED
@@ -234,6 +234,11 @@ async def closeed(client, callback):
|
|
234 |
@Client.on_callback_query(filters.regex("^memory_(\d+)$"))
|
235 |
async def memory_updated(client, callback):
|
236 |
user_id = int(callback.matches[0].group(1))
|
|
|
|
|
|
|
|
|
|
|
237 |
backup_chat = await db._get_chatbot_chat_from_db(user_id)
|
238 |
try:
|
239 |
if user_id == 0:
|
@@ -246,6 +251,7 @@ async def memory_updated(client, callback):
|
|
246 |
return await callback.answer("Server busy try again later", True)
|
247 |
backup_chat.append({"role": "model", "parts": [{"text": get_response}]})
|
248 |
await db._update_chatbot_chat_in_db(user_id, backup_chat)
|
|
|
249 |
await callback.answer("Memory Updated!", False)
|
250 |
except Exception as e:
|
251 |
LOGS.error(f"Exception translate: {str(e)}")
|
|
|
234 |
@Client.on_callback_query(filters.regex("^memory_(\d+)$"))
|
235 |
async def memory_updated(client, callback):
|
236 |
user_id = int(callback.matches[0].group(1))
|
237 |
+
check_memory = {}
|
238 |
+
if callback.message.id not in check_memory:
|
239 |
+
check_memory = {}
|
240 |
+
if check_memory[callback.message.id]:
|
241 |
+
return await callback.answer("Memory is Already Updated!", False)
|
242 |
backup_chat = await db._get_chatbot_chat_from_db(user_id)
|
243 |
try:
|
244 |
if user_id == 0:
|
|
|
251 |
return await callback.answer("Server busy try again later", True)
|
252 |
backup_chat.append({"role": "model", "parts": [{"text": get_response}]})
|
253 |
await db._update_chatbot_chat_in_db(user_id, backup_chat)
|
254 |
+
check_memory[callback.message.id] = True
|
255 |
await callback.answer("Memory Updated!", False)
|
256 |
except Exception as e:
|
257 |
LOGS.error(f"Exception translate: {str(e)}")
|