From 2c6ee2939eb2cce57ea771723e0503d19279af84 Mon Sep 17 00:00:00 2001 From: DevilXD Date: Mon, 31 Jan 2022 11:23:11 +0100 Subject: [PATCH] Implement idle argument --- main.py | 2 ++ twitch.py | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index 361e6a6..b7cc015 100644 --- a/main.py +++ b/main.py @@ -20,6 +20,7 @@ class ParsedArgs(argparse.Namespace): _debug_ws: bool _debug_gql: bool log: bool + idle: bool tray: bool debug: bool game: Optional[str] @@ -66,6 +67,7 @@ parser.add_argument("--debug", dest="debug", action="store_true") parser.add_argument("--debug-ws", dest="_debug_ws", action="store_true") parser.add_argument("--debug-gql", dest="_debug_gql", action="store_true") parser.add_argument("-g", "--game", default=None) +parser.add_argument("--idle", action="store_true") parser.add_argument("--tray", action="store_true") parser.add_argument("-l", "--log", action="store_true") options: ParsedArgs = parser.parse_args(namespace=ParsedArgs()) diff --git a/twitch.py b/twitch.py index 23e050f..e7e7545 100644 --- a/twitch.py +++ b/twitch.py @@ -51,7 +51,7 @@ class Twitch: def __init__(self, options: ParsedArgs): self.options = options # State management - self._state: State = State.INVENTORY_FETCH + self._state: State = State.IDLE self._state_change = asyncio.Event() self.game: Optional[Game] = None self.inventory: Dict[Game, List[DropsCampaign]] = {} @@ -192,8 +192,6 @@ class Twitch: add_game = True if add_game: games.append(game) - self.change_state(State.GAME_SELECT) - elif self._state is State.GAME_SELECT: # 'games' has all games we can mine drops for # if it's empty, there's no point in continuing if not games: @@ -202,6 +200,12 @@ class Twitch: # only start the websocket after we confirm there are drops to mine await self.websocket.start() self.gui.games.set_games(games) + if self.options.idle: + self.options.idle = False + self.change_state(State.IDLE) + else: + self.change_state(State.GAME_SELECT) + elif self._state is State.GAME_SELECT: self.game = self.gui.games.get_selection() # pre-display the active drop without a countdown active_drop = self.get_active_drop()