-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
72 lines (58 loc) · 1.79 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import os
import sys
import yaml
import atexit
import discord
import logging
import platform
import logging.config
from cogs.bot import Algalon
from cogs.config import LiveConfig as cfg
from cogs.config import DebugConfig as dbg
from cogs.utils import get_timestamp, log_start
if platform.machine() != "armv7l":
from dotenv import load_dotenv
load_dotenv()
if not dbg.debug_enabled:
sys.exit(0)
DIR = os.path.dirname(os.path.realpath(__file__))
LOG_DIR = os.path.join(DIR, "logs")
LOG_FILE = os.path.join(LOG_DIR, f"bot_{get_timestamp()}.log")
if not os.path.exists(LOG_DIR):
os.makedirs(LOG_DIR)
log_cfg_path = os.path.join(DIR, "log_config.yaml")
with open(log_cfg_path) as f:
log_cfg = yaml.safe_load(f)
logging.config.dictConfig(log_cfg)
queue_handler = logging.getHandlerByName("queue_handler")
if queue_handler is not None:
queue_handler.listener.start()
atexit.register(queue_handler.listener.stop)
logger = logging.getLogger("discord")
logger.info(
f"Using Python version {sys.version}",
)
logger.info(f"Using PyCord version {discord.__version__}")
log_start()
if __name__ == "__main__":
activity = discord.Activity(
type=discord.ActivityType.watching,
name="Blizzard's CDN",
)
if dbg.debug_enabled: # is debug mode
token = os.getenv("DEBUG_DISCORD_TOKEN")
debug_guilds = None
else: # is NOT debug mode
token = os.getenv("DISCORD_TOKEN")
debug_guilds = None
bot = Algalon(
command_prefix="!",
description="Algalon 2.0",
intents=discord.Intents.default(),
owner_id=cfg.get_cfg_value("discord", "owner_id"),
status=discord.Status.online,
activity=activity,
auto_sync_commands=True,
debug_guilds=debug_guilds,
)
bot.run(token)