Upload database.py
Browse files- Akeno/utils/database.py +18 -1
Akeno/utils/database.py
CHANGED
@@ -4,8 +4,9 @@ import time
|
|
4 |
from motor import motor_asyncio
|
5 |
from motor.core import AgnosticClient
|
6 |
|
7 |
-
from config import MONGO_URL
|
8 |
from Akeno.utils.logger import LOGS
|
|
|
|
|
9 |
|
10 |
class Database:
|
11 |
def __init__(self, uri: str) -> None:
|
@@ -22,6 +23,7 @@ class Database:
|
|
22 |
self.forcesub = self.db["forcesub"]
|
23 |
self.gachabots = self.db["gachabots"]
|
24 |
self.cohere = self.db["cohere"]
|
|
|
25 |
self.antiarabic = self.db["antiarabic"]
|
26 |
self.gban = self.db["gban"]
|
27 |
self.gmute = self.db["gmute"]
|
@@ -618,4 +620,19 @@ class Database:
|
|
618 |
return user_data.get("arabic", False)
|
619 |
return False
|
620 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
621 |
db = Database(MONGO_URL)
|
|
|
4 |
from motor import motor_asyncio
|
5 |
from motor.core import AgnosticClient
|
6 |
|
|
|
7 |
from Akeno.utils.logger import LOGS
|
8 |
+
from config import MONGO_URL
|
9 |
+
|
10 |
|
11 |
class Database:
|
12 |
def __init__(self, uri: str) -> None:
|
|
|
23 |
self.forcesub = self.db["forcesub"]
|
24 |
self.gachabots = self.db["gachabots"]
|
25 |
self.cohere = self.db["cohere"]
|
26 |
+
self.chatbot = self.db["chatbot"]
|
27 |
self.antiarabic = self.db["antiarabic"]
|
28 |
self.gban = self.db["gban"]
|
29 |
self.gmute = self.db["gmute"]
|
|
|
620 |
return user_data.get("arabic", False)
|
621 |
return False
|
622 |
|
623 |
+
async def add_chatbot(self, chat_id, user_id):
|
624 |
+
await self.chatbot.update_one(
|
625 |
+
{"chat_id": chat_id},
|
626 |
+
{"$set": {"user_id": user_id}},
|
627 |
+
upsert=True
|
628 |
+
)
|
629 |
+
|
630 |
+
async def get_chatbot(self, chat_id):
|
631 |
+
user_data = await self.chatbot.find_one({"chat_id": chat_id})
|
632 |
+
return user_data.get("user_id") if user_data else None
|
633 |
+
|
634 |
+
async def remove_chatbot(self, chat_id):
|
635 |
+
unset_data = {"user_id": None}
|
636 |
+
return await self.chatbot.update_one({"chat_id": chat_id}, {"$unset": unset_data})
|
637 |
+
|
638 |
db = Database(MONGO_URL)
|