-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.py
54 lines (41 loc) · 1.36 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
44
45
46
47
48
49
50
51
52
53
54
import sys
import io
import pomodorobot.config as config
import pomodorobot.lib as lib
from pomodorobot.dbmanager import db_manager
from pomodorobot.bot import PomodoroBot
USAGE = sys.argv[0] + " <token>"
DESCRIPTION = '''A marinara timer bot that can be configured to your needs.'''
bot = PomodoroBot(
command_prefix='!',
description=DESCRIPTION,
timer_step=2,
response_lifespan=15,
pm_help=True
)
if __name__ == '__main__':
TOKEN = ""
if len(sys.argv) < 2:
print("Not enough arguments received!\nUsage: " + sys.argv[0] +
" <token>")
exit(-1)
elif len(sys.argv) == 2:
TOKEN = sys.argv[1]
else:
exit(-2)
# Config
config.load('bot.yml')
# Logging
sys.stdout = sys.__stdout__ = io.TextIOWrapper(sys.stdout.detach(),
encoding='utf8',
errors='backslashreplace',
line_buffering=True)
lib.init_logger()
# Bot init
bot.reload_config(config.get_config())
bot.load_extension('pomodorobot.ext.timercommands')
bot.load_extension('pomodorobot.ext.events')
bot.load_extension('pomodorobot.ext.other')
bot.load_extension('pomodorobot.ext.admin')
bot.load_extension('pomodorobot.ext.registry')
bot.run(TOKEN)