-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
43 lines (32 loc) · 1.09 KB
/
main.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
import logging
from telegram import Update
from telegram.ext import ApplicationBuilder, ContextTypes, CommandHandler, Defaults
from dotenv import load_dotenv
import commands
import pytz
import os
from utils.Cronjobs import jobManager
from utils.Alarmjobs import alarmJobManager
load_dotenv()
logging.basicConfig(
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
level=logging.INFO
)
if __name__ == '__main__':
import logging.config
# logging.config.fileConfig('logging.conf')
defaults = Defaults(tzinfo=pytz.timezone(
os.getenv("TZ", "Asia/Hong_Kong")))
if not os.getenv("BOTTOKEN"):
logging.error("Bot token not defined!")
exit(1)
application = ApplicationBuilder().token(
os.getenv("BOTTOKEN")).defaults(defaults).build()
for command in commands.__all__:
if command.enabled:
command.load()
for handler in command.handlers:
application.add_handler(handler)
jobManager.init(application.job_queue)
alarmJobManager.init(application.job_queue)
application.run_polling()