Files
twitch-bot-template/src/bot.py
2025-08-01 00:05:48 +10:00

43 lines
884 B
Python

import asyncio
import logging
import websockets
from twitchio.web import AiohttpAdapter
from meta import CrocBot, conf, setup_main_logger, args
from data import Database
from modules import twitch_setup
logger = logging.getLogger(__name__)
async def main():
db = Database(conf.data['args'])
async with db.open():
adapter = AiohttpAdapter(
host=conf.bot.get('wshost', None),
port=conf.bot.getint('wsport', None),
domain=conf.bot.get('wsdomain', None),
eventsub_secret=conf.bot.get('eventsub_secret', None)
)
bot = CrocBot(
config=conf,
dbconn=db,
adapter=adapter,
setup=twitch_setup,
)
try:
await bot.start()
finally:
await bot.close()
def _main():
setup_main_logger()
asyncio.run(main())