Fix an issue with the miner not switching to a channel in a particular case;

The case involves an ONLINE channel, that stays ONLINE, but had it's tags and status updated from non-watchable to watchable
This commit is contained in:
DevilXD committed 2024-12-15 12:03:12 +01:00
1 parent 6b64b94b34
commit 651d73a342
1 file changed
+23 -20
+23 -20
View File
@@ -1102,10 +1102,8 @@ class Twitch:
if stream_before is None: if stream_before is None:
if stream_after is not None: if stream_after is not None:
# Channel going ONLINE # Channel going ONLINE
if ( if self.can_watch(channel) and self.should_switch(channel):
self.can_watch(channel) # we can watch the channel # we can watch the channel, and we should
and self.should_switch(channel) # and we should!
):
self.print(_("status", "goes_online").format(channel=channel.name)) self.print(_("status", "goes_online").format(channel=channel.name))
self.watch(channel) self.watch(channel)
else: else:
@@ -1115,33 +1113,38 @@ class Twitch:
logger.log(CALL, f"{channel.name} stays OFFLINE") logger.log(CALL, f"{channel.name} stays OFFLINE")
else: else:
watching_channel = self.watching_channel.get_with_default(None) watching_channel = self.watching_channel.get_with_default(None)
if ( # check if the watching channel was the one updated
watching_channel is not None if watching_channel is not None and watching_channel == channel:
and watching_channel == channel # the watching channel was the one updated
and not self.can_watch(channel) # we can't watch it anymore
):
# NOTE: In these cases, channel was the watching channel # NOTE: In these cases, channel was the watching channel
if stream_after is None: if not self.can_watch(channel):
# Channel going OFFLINE # we can't watch it anymore
self.print(_("status", "goes_offline").format(channel=channel.name)) 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: else:
# Channel stays ONLINE, but we can't watch it anymore # Channel stays ONLINE, and we can still watch it - no change
logger.info( pass
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)
# NOTE: In these cases, it wasn't the watching channel # NOTE: In these cases, it wasn't the watching channel
elif stream_after is None: elif stream_after is None:
logger.info(f"{channel.name} goes OFFLINE") logger.info(f"{channel.name} goes OFFLINE")
else: else:
# Channel is and stays ONLINE, but has been updated # Channel stays ONLINE, but has been updated
logger.info( logger.info(
f"{channel.name} status has been updated " f"{channel.name} status has been updated "
f"(🎁: {stream_before.drops_enabled and '✔' or '❌'} -> " f"(🎁: {stream_before.drops_enabled and '✔' or '❌'} -> "
f"{stream_after.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() channel.display()
@task_wrapper @task_wrapper