Skip to content

Commit

Permalink
Fix an issue with the miner not switching to a channel in a particula…
Browse files Browse the repository at this point in the history
…r case;

The case involves an ONLINE channel, that stays ONLINE, but had it's tags and status updated from non-watchable to watchable
  • Loading branch information
DevilXD committed Dec 15, 2024
1 parent 6b64b94 commit 651d73a
Showing 1 changed file with 23 additions and 20 deletions.
43 changes: 23 additions & 20 deletions twitch.py
Original file line number Diff line number Diff line change
Expand Up @@ -1102,10 +1102,8 @@ def on_channel_update(
if stream_before is None:
if stream_after is not None:
# Channel going ONLINE
if (
self.can_watch(channel) # we can watch the channel
and self.should_switch(channel) # and we should!
):
if self.can_watch(channel) and self.should_switch(channel):
# we can watch the channel, and we should
self.print(_("status", "goes_online").format(channel=channel.name))
self.watch(channel)
else:
Expand All @@ -1115,33 +1113,38 @@ def on_channel_update(
logger.log(CALL, f"{channel.name} stays OFFLINE")
else:
watching_channel = self.watching_channel.get_with_default(None)
if (
watching_channel is not None
and watching_channel == channel # the watching channel was the one updated
and not self.can_watch(channel) # we can't watch it anymore
):
# check if the watching channel was the one updated
if watching_channel is not None and watching_channel == channel:
# NOTE: In these cases, channel was the watching channel
if stream_after is None:
# Channel going OFFLINE
self.print(_("status", "goes_offline").format(channel=channel.name))
if not self.can_watch(channel):
# we can't watch it anymore
if stream_after is None:
# Channel going OFFLINE
self.print(_("status", "goes_offline").format(channel=channel.name))
else:
# Channel stays ONLINE, but we can't watch it anymore
logger.info(
f"{channel.name} status has been updated, switching... "
f"(🎁: {stream_before.drops_enabled and '✔' or '❌'} -> "
f"{stream_after.drops_enabled and '✔' or '❌'})"
)
self.change_state(State.CHANNEL_SWITCH)
else:
# Channel stays ONLINE, but we can't watch it anymore
logger.info(
f"{channel.name} status has been updated, switching... "
f"(🎁: {stream_before.drops_enabled and '✔' or '❌'} -> "
f"{stream_after.drops_enabled and '✔' or '❌'})"
)
self.change_state(State.CHANNEL_SWITCH)
# Channel stays ONLINE, and we can still watch it - no change
pass
# NOTE: In these cases, it wasn't the watching channel
elif stream_after is None:
logger.info(f"{channel.name} goes OFFLINE")
else:
# Channel is and stays ONLINE, but has been updated
# Channel stays ONLINE, but has been updated
logger.info(
f"{channel.name} status has been updated "
f"(🎁: {stream_before.drops_enabled and '✔' or '❌'} -> "
f"{stream_after.drops_enabled and '✔' or '❌'})"
)
if self.can_watch(channel) and self.should_switch(channel):
# ... and we can and should watch it
self.watch(channel)
channel.display()

@task_wrapper
Expand Down

0 comments on commit 651d73a

Please sign in to comment.