From e26da50d7d7d7ebe88608ff3f13eabcb52850fb7 Mon Sep 17 00:00:00 2001 From: gottagofaster236 Date: Thu, 26 Nov 2020 18:42:02 +0300 Subject: [PATCH] Tweak the prints --- pubsub.py | 9 ++++++--- twitch_data.py | 6 +----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/pubsub.py b/pubsub.py index 216c411..dce44e6 100644 --- a/pubsub.py +++ b/pubsub.py @@ -71,11 +71,10 @@ def on_message(ws, message): if message["type"] == "points-earned": channel_id = message_data["channel_id"] if channel_id in get_streamer_ids(): - reason_name = get_reason_name(message_data["point_gain"]["reason_code"]) - total_points = message_data["point_gain"]["total_points"] new_balance = message_data["balance"]["balance"] channel_login = get_login_by_channel_id(channel_id) - print(f"Earned {total_points} {reason_name} points for {channel_login}, balance is {new_balance}!") + reason_name = get_reason_name(message_data["point_gain"]["reason_code"]) + print(f"{new_balance} channel points for {channel_login}! Reason: {reason_name}.") elif message["type"] == "claim-available": channel_id = message_data["claim"]["channel_id"] if channel_id in get_streamer_ids(): @@ -105,6 +104,10 @@ def on_message(ws, message): reconnect(ws) +def get_reason_name(code): + return code.replace("_", " ").replace("CLAIM", "bonus claimed").lower() + + def listen_for_topic(ws, topic): data = {"topics": [str(topic)]} if topic.is_user_topic: diff --git a/twitch_data.py b/twitch_data.py index 8fc2537..0d02531 100644 --- a/twitch_data.py +++ b/twitch_data.py @@ -118,8 +118,4 @@ def get_auth_token(): def get_client_id(): - return TWITCH_CLIENT_ID - - -def get_reason_name(code): - return code.replace("_", " ").replace("CLAIM", "bonus").lower() \ No newline at end of file + return TWITCH_CLIENT_ID \ No newline at end of file