11import os
2-
32import httpx
43from motor .motor_asyncio import AsyncIOMotorClient
54from pyrogram import enums , filters
65from pyrogram .types import Message
76
87from MeowChat import app
98from MeowChat .utils .admins import admin_check
9+ from config import API_URL , MONGO_URL
10+
11+ # ================== DATABASE ==================
1012
11- API_URL = os .getenv ("API_URL" )
12- MONGO_URL = os .getenv ("MONGO_URL" )
1313mongo = AsyncIOMotorClient (MONGO_URL )
1414db = mongo ["chatbot" ]
1515col = db ["status" ]
@@ -50,7 +50,7 @@ async def toggle_chatbot(client, message: Message):
5050 ]:
5151 return await message .reply_text ("❌ This works only in groups" )
5252
53- # 🔥 ADMIN CHECK
53+ # Admin check
5454 if not await admin_check (message ):
5555 return await message .reply_text ("❌ You are not admin" )
5656
@@ -74,6 +74,7 @@ async def toggle_chatbot(client, message: Message):
7474async def chatbot_reply (client , message : Message ):
7575 chat_id = message .chat .id
7676
77+ # Only reply if enabled in group
7778 if message .chat .type in [
7879 enums .ChatType .GROUP ,
7980 enums .ChatType .SUPERGROUP ,
@@ -85,7 +86,6 @@ async def chatbot_reply(client, message: Message):
8586 return
8687
8788 final_text = f"{ PROMPT } \n User: { message .text } "
88-
8989 payload = {"message" : final_text }
9090
9191 try :
@@ -106,5 +106,5 @@ async def chatbot_reply(client, message: Message):
106106 await message .reply_text (reply )
107107
108108 except Exception as e :
109- print ("Error:" , e )
109+ print ("Chatbot Error:" , e )
110110 await message .reply_text ("⚠️ Something went wrong" )
0 commit comments