-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmr-poopybutthole.py
68 lines (53 loc) · 1.69 KB
/
mr-poopybutthole.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
import argparse
import logging
import os
import sys
from discord.ext import commands
from dotenv import load_dotenv
from mr_poopybutthole.oohwee import Oohwee
from mr_poopybutthole.command import Command
from mr_poopybutthole.listener import Listener
from mr_poopybutthole.snowflake import Snowflake
from mr_poopybutthole.api import EagleworldApi
def get_logger():
"""
Create the logger for the Mr-Poopybutthole Discord bot.
"""
log = logging.getLogger()
stdout_handler = logging.StreamHandler(sys.stdout)
stdout_handler.setFormatter(logging.Formatter("%(message)s"))
stdout_handler.setLevel(logging.INFO)
log.addHandler(stdout_handler)
log.setLevel(logging.INFO)
def get_args():
"""
Gets command-line arguments for the Mr-Poopybutthole Discord bot.
"""
parser = argparse.ArgumentParser()
parser.add_argument("--dev", action="store_true", help="Enable development mode.")
return parser.parse_args()
def oohwee():
"""
Main routine. Creates a logger, instanciates the bot, and
adds/enables all cogs that makes up Mr. PoopyButthole.
"""
get_logger()
load_dotenv()
args = get_args()
if args.dev:
os.environ["DEV_MODE"] = "True"
token = os.getenv("DEV_DISCORD_TOKEN")
else:
os.environ["DEV_MODE"] = "False"
token = os.getenv("DISCORD_TOKEN")
bot = commands.Bot(command_prefix="!")
bot.remove_command("help")
bot.add_cog(Oohwee(bot))
bot.add_cog(Command(bot))
bot.add_cog(Listener(bot))
bot.add_cog(Snowflake(bot))
bot.add_cog(EagleworldApi(bot))
bot.run(token)
# TODO: toggle load_dotenv() only for running outside of k8s
if __name__ == "__main__":
oohwee()