-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.py
56 lines (43 loc) · 1.22 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
56
from datetime import datetime
from dotenv import load_dotenv
import os
import pytz
import requests
# environment variables
load_dotenv()
TOKEN = os.getenv('TOKEN')
API_URL = os.getenv('API_URL')
API_KEY = os.getenv('API_KEY')
BOT_PERM = int(os.getenv('BOT_PERM'))
C4T_DPY_ALPHA = int(os.getenv('C4T_DPY_ALPHA'))
C4T_DPY_BETA = int(os.getenv('C4T_DPY_BETA'))
C4T_DPY_DEC2021 = int(os.getenv('C4T_DPY_DEC2021'))
C4T_DPY_TEST = int(os.getenv('C4T_DPY_TEST'))
C4W_DPY_FEB2022 = int(os.getenv('C4W_DPY_FEB2022'))
C4T_DPY_MAR2022 = int(os.getenv('C4T_DPY_MAR2022'))
# console colours
reset = '\u001b[0m'
red = '\u001b[31m'
green = '\u001b[32m'
# localisation
tz = pytz.timezone('Asia/Kuala_Lumpur')
# requests session
s = requests.Session()
s.headers.update({'api-key': API_KEY})
# helper functions
def now():
return datetime.now(tz)
def get_active_cohort():
url = f'{API_URL}/cohorts/active'
r = s.get(url, timeout=10)
if r.status_code != requests.codes.ok:
r.raise_for_status()
return r.json()
# global variables
guild_id = None
active_cohort = get_active_cohort()
c4t_dpy = [
C4T_DPY_ALPHA, C4T_DPY_BETA, C4T_DPY_DEC2021, C4T_DPY_MAR2022, C4T_DPY_TEST
]
c4w_dpy = [C4W_DPY_FEB2022]
dpy = c4t_dpy + c4w_dpy