forked from VJBots/VJ-Token-Verification
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.py
55 lines (49 loc) · 1.58 KB
/
utils.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
53
54
55
import pytz, random, string
from datetime import date
from info import API, URL
from shortzy import Shortzy
TOKENS = {}
VERIFIED = {}
async def get_verify_shorted_link(link):
shortzy = Shortzy(api_key=API, base_site=URL)
link = await shortzy.convert(link)
return link
async def check_token(bot, userid, token):
user = await bot.get_users(userid)
if user.id in TOKENS.keys():
TKN = TOKENS[user.id]
if token in TKN.keys():
is_used = TKN[token]
if is_used == True:
return False
else:
return True
else:
return False
async def get_token(bot, userid, link):
user = await bot.get_users(userid)
token = ''.join(random.choices(string.ascii_letters + string.digits, k=7))
TOKENS[user.id] = {token: False}
link = f"{link}verify-{user.id}-{token}"
shortened_verify_url = await get_verify_shorted_link(link)
return str(shortened_verify_url)
async def verify_user(bot, userid, token):
user = await bot.get_users(userid)
TOKENS[user.id] = {token: True}
tz = pytz.timezone('Asia/Kolkata')
today = date.today()
VERIFIED[user.id] = str(today)
async def check_verification(bot, userid):
user = await bot.get_users(userid)
tz = pytz.timezone('Asia/Kolkata')
today = date.today()
if user.id in VERIFIED.keys():
EXP = VERIFIED[user.id]
years, month, day = EXP.split('-')
comp = date(int(years), int(month), int(day))
if comp<today:
return False
else:
return True
else:
return False