See the README for usages and details. A breaking changes here too: * run.py is gone, we now handle that kind of thing with docker * The token is out of the config and is now an ENVAR (ideally using a .env) * `.json` files are now in a .matchy/ subdirectory, as this makes it a lot easier for the container to safely read Bonus: * fix a score_factors.setdefault call causing issues * Reformat some of the readme
40 lines
1,007 B
Python
Executable file
40 lines
1,007 B
Python
Executable file
"""
|
|
matchy.py - Discord bot that matches people into groups
|
|
"""
|
|
import logging
|
|
import discord
|
|
from discord.ext import commands
|
|
import os
|
|
from state import load_from_file
|
|
from cogs.matchy_cog import MatchyCog
|
|
from cogs.owner_cog import OwnerCog
|
|
|
|
_STATE_FILE = ".matchy/state.json"
|
|
state = load_from_file(_STATE_FILE)
|
|
|
|
logger = logging.getLogger("matchy")
|
|
logger.setLevel(logging.INFO)
|
|
|
|
intents = discord.Intents.default()
|
|
intents.message_content = True
|
|
intents.members = True
|
|
bot = commands.Bot(command_prefix='$',
|
|
description="Matchy matches matchees", intents=intents)
|
|
|
|
|
|
@bot.event
|
|
async def setup_hook():
|
|
await bot.add_cog(MatchyCog(bot, state))
|
|
await bot.add_cog(OwnerCog(bot, state))
|
|
|
|
|
|
@bot.event
|
|
async def on_ready():
|
|
logger.info("Logged in as %s", bot.user.name)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
handler = logging.StreamHandler()
|
|
token = os.environ.get("TOKEN", None)
|
|
assert token, "$TOKEN required"
|
|
bot.run(token, log_handler=handler, root_logger=True)
|