From 954575c9f455e931f0f5df78986552f4c2fea9c2 Mon Sep 17 00:00:00 2001 From: Roman Davydov <15850461+rdavydov@users.noreply.github.com> Date: Tue, 7 Mar 2023 17:15:23 +0300 Subject: [PATCH] listen to topic and claim moments --- TwitchChannelPointsMiner/TwitchChannelPointsMiner.py | 6 ++++++ TwitchChannelPointsMiner/classes/WebSocketsPool.py | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/TwitchChannelPointsMiner/TwitchChannelPointsMiner.py b/TwitchChannelPointsMiner/TwitchChannelPointsMiner.py index a991084..08e9d58 100644 --- a/TwitchChannelPointsMiner/TwitchChannelPointsMiner.py +++ b/TwitchChannelPointsMiner/TwitchChannelPointsMiner.py @@ -350,6 +350,12 @@ class TwitchChannelPointsMiner: streamer=streamer) ) + if streamer.settings.claim_moments is True: + self.ws_pool.submit( + PubsubTopic("community-moments-channel-v1", + streamer=streamer) + ) + refresh_context = time.time() while self.running: time.sleep(random.uniform(20, 60)) diff --git a/TwitchChannelPointsMiner/classes/WebSocketsPool.py b/TwitchChannelPointsMiner/classes/WebSocketsPool.py index 5b87232..a19923f 100644 --- a/TwitchChannelPointsMiner/classes/WebSocketsPool.py +++ b/TwitchChannelPointsMiner/classes/WebSocketsPool.py @@ -242,6 +242,13 @@ class WebSocketsPool: ws.twitch.update_raid( ws.streamers[streamer_index], raid) + elif message.topic == "community-moments-channel-v1": + if message.type == "active": + ws.twitch.claim_moment( + ws.streamers[streamer_index], + message.data["moment_id"] + ) + elif message.topic == "predictions-channel-v1": event_dict = message.data["event"]