@@ -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" )
0 commit comments