Implement idle argument

This commit is contained in:
DevilXD committed 2022-01-31 11:23:11 +01:00
1 parent 88d7ffa520
commit 2c6ee2939e
2 files changed
+9 -3

No files matched your search

+2
View File
@@ -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())
+7 -3
View File
@@ -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()