Skip to content

Commit

Permalink
Little bit of refactory 😄 - Each 25% progress print the drop status i…
Browse files Browse the repository at this point in the history
…n logger

Signed-off-by: Alessandro Maggio <[email protected]>
  • Loading branch information
Tkd-Alex committed Jan 29, 2021
1 parent 4185766 commit 9800e46
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 10 deletions.
2 changes: 1 addition & 1 deletion TwitchChannelPointsMiner/TwitchChannelPointsMiner.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def __print_report(self):
self.streamers[streamer_index].set_less_printing(False)
logger.info(
f"{self.streamers[streamer_index]}, Total Points Gained (after farming - before farming): {self.streamers[streamer_index].channel_points - self.original_streamers[streamer_index].channel_points}",
extra={"emoji": ":microphone:"},
extra={"emoji": ":robot:"},
)
if self.streamers[streamer_index].history != {}:
logger.info(
Expand Down
8 changes: 6 additions & 2 deletions TwitchChannelPointsMiner/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# -*- coding: utf-8 -*-
__version__ = "2.3.5"
from .TwitchChannelPointsMiner import TwitchChannelPointsMiner # noqa: F401
__version__ = "2.4.1"
from .TwitchChannelPointsMiner import TwitchChannelPointsMiner

__all__ = [
"TwitchChannelPointsMiner",
]
15 changes: 11 additions & 4 deletions TwitchChannelPointsMiner/classes/WebSocketsPool.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,9 @@ def on_message(ws, message):

elif message.topic == "user-drop-events":
if message.type == "drop-progress":
if (
message.data["current_progress_min"]
>= message.data["required_progress_min"]
):
current = message.data["current_progress_min"]
required = message.data["required_progress_min"]
if current >= required:
try:
drop = ws.twitch.search_drop_in_inventory(
ws.streamers[streamer_index],
Expand All @@ -303,6 +302,14 @@ def on_message(ws, message):
logger.error(
f"Unable to find {message.data['drop_id']} in your inventory"
)
else:
# Skip 0% and 100% ...
percentage_state = int((current / required) * 100)
if percentage_state != 0 and percentage_state % 25 == 0:
logger.info(
f"Drop event {percentage_state}% for {ws.streamers[streamer_index]}!",
extra={"emoji": ":package:"},
)

except Exception:
logger.error(
Expand Down
12 changes: 9 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
import os
from os import path

import setuptools
import re


def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname), encoding='utf-8').read()
return open(path.join(path.dirname(__file__), fname), encoding='utf-8').read()


metadata = dict(
re.findall(r"""__([a-z]+)__ = "([^"]+)""", read("TwitchChannelPointsMiner/__init__.py"))
)

setuptools.setup(
name="Twitch-Channel-Points-Miner-v2",
version="2.3.5",
version=metadata["version"],
author="Tkd-Alex (Alessandro Maggio)",
author_email="[email protected]",
description="A simple script that will watch a stream for you and earn the channel points.",
Expand Down

0 comments on commit 9800e46

Please sign in to comment.