randydev commited on
Commit
f0eba1a
1 Parent(s): ec71eb2
Files changed (1) hide show
  1. main.py → chatbot/plugins/chat.py +4 -23
main.py → chatbot/plugins/chat.py RENAMED
@@ -2,27 +2,17 @@ import asyncio
2
  import logging
3
  import os
4
 
5
- from pyrogram import Client, filters, idle
6
  from pyrogram.types import Message
7
 
8
- # Your other imports
9
- from dotenv import load_dotenv
10
  from database import db
11
  from logger import LOGS
12
- from RyuzakiLib import GeminiLatest # and other imports as needed
13
  import google.generativeai as genai
14
  from google.api_core.exceptions import InvalidArgument
15
 
16
- # Initialize Pyrogram Client
17
- client = Client(
18
- "chatbotai",
19
- api_id=API_ID,
20
- api_hash=API_HASH,
21
- bot_token=BOT_TOKEN
22
- )
23
 
24
- # Define your handler
25
- @client.on_message(
26
  filters.incoming
27
  & (
28
  filters.text
@@ -229,13 +219,4 @@ async def chatbot_talk(client: Client, message: Message):
229
  backup_chat.append({"role": "model", "parts": [{"text": output}]})
230
  await db._update_chatbot_chat_in_db(message.from_user.id, backup_chat)
231
  except Exception as e:
232
- await message.reply_text(str(e))
233
-
234
-
235
- if __name__ == "__main__":
236
- try:
237
- client.run()
238
- except (KeyboardInterrupt, SystemExit):
239
- LOGS.info("Bot has been terminated by the user.")
240
- except Exception as e:
241
- LOGS.error(f"Unexpected error: {e}")
 
2
  import logging
3
  import os
4
 
5
+ from pyrogram import Client, filters
6
  from pyrogram.types import Message
7
 
 
 
8
  from database import db
9
  from logger import LOGS
10
+ from RyuzakiLib import GeminiLatest
11
  import google.generativeai as genai
12
  from google.api_core.exceptions import InvalidArgument
13
 
 
 
 
 
 
 
 
14
 
15
+ @Client.on_message(
 
16
  filters.incoming
17
  & (
18
  filters.text
 
219
  backup_chat.append({"role": "model", "parts": [{"text": output}]})
220
  await db._update_chatbot_chat_in_db(message.from_user.id, backup_chat)
221
  except Exception as e:
222
+ await message.reply_text(str(e))