From 66e010c890f538cd5777337421ff2425237b51eb Mon Sep 17 00:00:00 2001 From: NotSoToothless <67082114+FURRO404@users.noreply.github.com> Date: Mon, 25 May 2026 22:48:57 -0700 Subject: [PATCH] meow (#1270) --- start_bot.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/start_bot.py b/start_bot.py index 184fe34..41d6014 100644 --- a/start_bot.py +++ b/start_bot.py @@ -18,8 +18,9 @@ from dotenv import load_dotenv load_dotenv(dotenv_path=_HERE / ".env") -# Imported after load_dotenv so STORAGE_VOL_PATH is read from .env. +# Imported after load_dotenv so env vars are available. from BOT.storage import init_tss_dbs # noqa: E402 +from tss_ws import listen, _handle_game # noqa: E402 logging.basicConfig( level=logging.INFO, @@ -43,6 +44,16 @@ intents.messages = True bot = commands.Bot(command_prefix="!", intents=intents) +async def _ws_task_loop() -> None: + """Run the TSS WS listener forever, restarting on any error.""" + while True: + try: + await listen(_handle_game) + except Exception as exc: + log.error(f"TSS WS listener crashed: {exc} — restarting in 10s") + await asyncio.sleep(10) + + @bot.event async def on_ready(): log.info(f"logged in as {bot.user} (id={bot.user.id if bot.user else '?'})") @@ -50,6 +61,7 @@ async def on_ready(): await bot.change_presence( activity=discord.CustomActivity(name="Soon...") ) + asyncio.create_task(_ws_task_loop()) if __name__ == "__main__":