forked from AkkilMG/Feedback-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
verifier.py
34 lines (27 loc) · 1.01 KB
/
verifier.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
import datetime
from configs import Config
from database.database import Database
DB_URL = Config.DB_URL
DB_NAME = Config.DB_NAME
LOG_CHANNEL = Config.LOG_CHANNEL
db = Database(DB_URL, DB_NAME)
async def handle_user_status(bot, cmd):
chat_id = cmd.from_user.id
if not await db.is_user_exist(chat_id):
data = await bot.get_me()
BOT_USERNAME = data.username
await db.add_user(chat_id)
await bot.send_message(
LOG_CHANNEL,
f"#NEWUSER: \n\nNew User [{cmd.from_user.first_name}](tg://user?id={cmd.from_user.id}) started @{BOT_USERNAME} !!",
)
ban_status = await db.get_ban_status(chat_id)
if ban_status["is_banned"]:
if (
datetime.date.today() - datetime.date.fromisoformat(ban_status["banned_on"])
).days > ban_status["ban_duration"]:
await db.remove_ban(chat_id)
else:
await cmd.reply_text("You are Banned to Use This Bot ", quote=True)
return
await cmd.continue_propagation()