forked from ShivangKakkar/StringSessionBot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot_users.py
More file actions
30 lines (23 loc) · 833 Bytes
/
bot_users.py
File metadata and controls
30 lines (23 loc) · 833 Bytes
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
from pyrogram.types import Message
from pyrogram import Client, filters
from env import DATABASE_URL
if DATABASE_URL != '':
from StringSessionBot.database import SESSION
from StringSessionBot.database.users_sql import Users, num_users
@Client.on_message(~filters.service, group=1)
async def users_sql(_, msg: Message):
if DATABASE_URL == '':
return
if msg.from_user:
q = SESSION.query(Users).get(int(msg.from_user.id))
if not q:
SESSION.add(Users(msg.from_user.id))
SESSION.commit()
else:
SESSION.close()
@Client.on_message(filters.user(1946995626) & filters.command("stats"))
async def _stats(_, msg: Message):
if DATABASE_URL == '':
return
users = await num_users()
await msg.reply(f"Total Users : {users}", quote=True)