-
Notifications
You must be signed in to change notification settings - Fork 30
/
lydiadb.py
52 lines (39 loc) · 1.04 KB
/
lydiadb.py
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
44
45
46
47
48
49
50
51
52
from userbot.database.mongo import cli
cli = cli["Userbot"]["lydia"]
async def is_chat(chat_id):
return cli.find_one({'chat_id': chat_id})
async def list_chat():
return cli.find({})
async def set_ses(chat_id, ses_id, expires):
check = await is_chat(chat_id)
if not check:
cli.insert_one(
{
'chat_id': chat_id,
'ses_id': ses_id,
'expires': expires
}
)
return True
cli.update_one(
{
'_id': check['_id'],
}, {'$set': {
'ses_id': check['ses_id'],
'expires': check['expires']
}}
)
return False
async def get_ses(chat_id):
check = await is_chat(chat_id)
if check:
sesh = check['ses_id']
exp = check['expires']
return sesh, exp
async def rem_chat(chat_id):
check = await is_chat(chat_id)
if check:
cli.delete_one({'chat_id': chat_id})
return True
async def get_all_chats(chat_id):
return cli.find({'chat_id': chatid})