meow (#1270)
This commit is contained in:
+13
-1
@@ -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__":
|
||||
|
||||
Reference in New Issue
Block a user