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
21 lines (17 loc) · 686 Bytes
/
bot_users.py
File metadata and controls
21 lines (17 loc) · 686 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from pyrogram.types import Message
from pyrogram import Client, filters
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 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):
users = await num_users()
await msg.reply(f"Total Users : {users}", quote=True)