forked from Lovely-Development-Team/TLDBotto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
__main__.py
53 lines (41 loc) · 1.77 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
import os
import json
import logging.config
from apscheduler.schedulers.asyncio import AsyncIOScheduler
from botto.reactions import Reactions
from botto.reminder_manager import ReminderManager
from botto.storage import AirtableMealStorage, ReminderStorage, TimezoneStorage
from botto.storage.enablement_storage import EnablementStorage
from botto.tld_botto import TLDBotto
from botto.config import parse
from botto.slash_commands import setup_slash
log = logging.getLogger("TLDBotto")
try:
config_path = os.getenv("MOTTOBOTTO_CONFIG", "config.json")
log.debug(f"Config path: %s", config_path)
config_to_parse = {}
if os.path.isfile(config_path):
config_to_parse = json.load(open(config_path))
config = parse(config_to_parse)
except (IOError, OSError, ValueError) as err:
log.error(f"Config file invalid: {err}")
exit(1)
log.info(f"Triggers: {config['triggers']}")
scheduler = AsyncIOScheduler()
storage = AirtableMealStorage(
config["authentication"]["airtable_base"], config["authentication"]["airtable_key"]
)
reminder_storage = ReminderStorage(
config["authentication"]["airtable_base"], config["authentication"]["airtable_key"]
)
timezone_storage = TimezoneStorage(
config["authentication"]["airtable_base"], config["authentication"]["airtable_key"]
)
enablement_storage = EnablementStorage(
config["authentication"]["airtable_base"], config["authentication"]["airtable_key"]
)
reactions = Reactions(config)
reminder_manager = ReminderManager(config, scheduler, reminder_storage, reactions, timezone_storage)
client = TLDBotto(config, reactions, scheduler, storage, timezone_storage, reminder_manager, enablement_storage)
slash = setup_slash(client, config, reminder_manager, timezone_storage)
client.run(config["authentication"]["discord"])