Skip to content

Commit 777e87c

Browse files
committed
🤷‍♀️Move tuesday problems to Dota component
1 parent 310bbea commit 777e87c

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

src/modules/public/dota_rp_flow/component.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,7 @@ async def component_load(self) -> None:
610610
self.fill_completed_matches_from_gc_match_history.start()
611611
self.remove_way_too_old_matches.start()
612612
self.debug_announce_gc_ready.start()
613+
self.tuesday_problems.start()
613614

614615
@override
615616
async def component_teardown(self) -> None:
@@ -618,6 +619,7 @@ async def component_teardown(self) -> None:
618619
self.fill_completed_matches_from_gc_match_history.cancel()
619620
self.remove_way_too_old_matches.cancel()
620621
self.debug_announce_gc_ready.cancel()
622+
self.tuesday_problems.cancel()
621623

622624
#################################
623625
# EVENTS #
@@ -1562,3 +1564,19 @@ async def debug_announce_activity_change(self, friend: Friend) -> None:
15621564
"""Announce in Irene's twitch chat that their activity data has changed."""
15631565
if friend.steam_user.id == config["STEAM"]["IRENE_ID32"]:
15641566
await self.debug_deliver(f"Activity changed to: {friend.activity}")
1567+
1568+
@ireloop(count=1)
1569+
async def tuesday_problems(self) -> None:
1570+
"""A crutch to try to solve infamous Tuesday problems.
1571+
1572+
When steam crashes - it always is a big problem for the bot;
1573+
It doesn't ever properly reconnect on its own.
1574+
1575+
Let's put a crutch to simply restart the bot if that happens.
1576+
"""
1577+
try:
1578+
async with asyncio.timeout(11 * 60): # 11 minutes
1579+
await self.bot.dota.wait_until_gc_ready()
1580+
except TimeoutError:
1581+
log.warning("🔴 Failed to wait for Dota 2 Game Coordinator to get ready - restarting the bot. 🔴")
1582+
await asyncio.create_subprocess_shell("sudo systemctl restart irebot")

src/utils/dota/dota2client.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from __future__ import annotations
22

3-
import asyncio
43
import logging
54
from typing import TYPE_CHECKING, NamedTuple, override
65

@@ -71,13 +70,8 @@ async def close(self) -> None:
7170
@override
7271
async def on_ready(self) -> None:
7372
log.info("Dota 2 Client: Ready %s, now waiting till Game Coordinator is ready;", self.user.name)
74-
try:
75-
async with asyncio.timeout(11 * 60): # 11 minutes
76-
await self.wait_until_gc_ready()
77-
log.info("Dota 2 Game Coordinator: Ready")
78-
except TimeoutError:
79-
log.warning("🔴 Failed to wait for Dota 2 Game Coordinator to get ready - restarting the bot. 🔴")
80-
await asyncio.create_subprocess_shell("sudo systemctl restart irebot")
73+
await self.wait_until_gc_ready()
74+
log.info("Dota 2 Game Coordinator: Ready")
8175

8276
@override
8377
async def on_user_update(self, before: User, after: User) -> None:

0 commit comments

Comments
 (0)