File size: 1,090 Bytes
f45efbd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
from Database.mongodb.db import dbname
matadb = dbname["sangmata"]
# Get Data User
async def cek_userdata(user_id: int) -> bool:
user = await matadb.find_one({"user_id": user_id})
return bool(user)
async def get_userdata(user_id: int) -> bool:
user = await matadb.find_one({"user_id": user_id})
return user["username"], user["first_name"], user["last_name"]
async def add_userdata(user_id: int, username, first_name, last_name):
await matadb.update_one(
{"user_id": user_id},
{
"$set": {
"username": username,
"first_name": first_name,
"last_name": last_name,
}
},
upsert=True,
)
# Enable Mata MissKaty in Selected Chat
async def is_sangmata_on(chat_id: int) -> bool:
chat = await matadb.find_one({"chat_id_toggle": chat_id})
return bool(chat)
async def sangmata_on(chat_id: int) -> bool:
await matadb.insert_one({"chat_id_toggle": chat_id})
async def sangmata_off(chat_id: int):
await matadb.delete_one({"chat_id_toggle": chat_id})
|