randydev commited on
Commit
8c6eae7
1 Parent(s): 365d344

Update chatbot/plugins/chat.py

Browse files
Files changed (1) hide show
  1. chatbot/plugins/chat.py +27 -1
chatbot/plugins/chat.py CHANGED
@@ -48,6 +48,28 @@ async def geni_files_delete(name: str):
48
  return None
49
  return response.text
50
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  @Client.on_message(
52
  filters.incoming
53
  & (
@@ -58,7 +80,8 @@ async def geni_files_delete(name: str):
58
  | filters.voice
59
  | filters.regex(r"\b(Randy|Rendi)\b(.*)", flags=re.IGNORECASE)
60
  )
61
- & filters.private
 
62
  & ~filters.bot
63
  & ~filters.via_bot
64
  & ~filters.forwarded,
@@ -66,6 +89,9 @@ async def geni_files_delete(name: str):
66
  )
67
  async def chatbot_talk(client: Client, message: Message):
68
  genai.configure(api_key=GOOGLE_API_KEY)
 
 
 
69
  if message.photo:
70
  await client.send_chat_action(message.chat.id, enums.ChatAction.UPLOAD_PHOTO)
71
  await asyncio.sleep(1.5)
 
48
  return None
49
  return response.text
50
 
51
+
52
+ @Client.on_message(
53
+ ~filters.scheduled
54
+ & command(["onchat"])
55
+ & filters.me
56
+ & ~filters.forwarded
57
+ )
58
+ async def addchatbot_user(client: Client, message: Message):
59
+ await db.add_chatbot(message.chat.id, client.me.id)
60
+ await message.reply_text("Added chatbot user")
61
+
62
+
63
+ @Client.on_message(
64
+ ~filters.scheduled
65
+ & command(["offchat"])
66
+ & filters.me
67
+ & ~filters.forwarded
68
+ )
69
+ async def rmchatbot_user(client: Client, message: Message):
70
+ await db.remove_chatbot(message.chat.id)
71
+ await message.reply_text("ok stopped gemini")
72
+
73
  @Client.on_message(
74
  filters.incoming
75
  & (
 
80
  | filters.voice
81
  | filters.regex(r"\b(Randy|Rendi)\b(.*)", flags=re.IGNORECASE)
82
  )
83
+ & (filters.private | filters.group)
84
+ & filters.reply
85
  & ~filters.bot
86
  & ~filters.via_bot
87
  & ~filters.forwarded,
 
89
  )
90
  async def chatbot_talk(client: Client, message: Message):
91
  genai.configure(api_key=GOOGLE_API_KEY)
92
+ chat_user = await db.get_chatbot(message.chat.id)
93
+ if not chat_user:
94
+ return
95
  if message.photo:
96
  await client.send_chat_action(message.chat.id, enums.ChatAction.UPLOAD_PHOTO)
97
  await asyncio.sleep(1.5)