Reduce string size with: event.bet.get_outcome and millify
This commit is contained in:
@@ -98,7 +98,7 @@ class TwitchChannelPointsMiner:
|
||||
streamers += [fw for fw in followers_array if fw not in streamers]
|
||||
|
||||
logger.info(
|
||||
f"Loading data for {len(streamers)} streamers. This operation can take a while. Please wait ...",
|
||||
f"Loading data for {len(streamers)} streamers. This operation can take a while ...",
|
||||
extra={"emoji": ":nerd_face:"},
|
||||
)
|
||||
for streamer_username in streamers:
|
||||
@@ -130,8 +130,7 @@ class TwitchChannelPointsMiner:
|
||||
self.twitch_browser = TwitchBrowser(
|
||||
self.twitch.twitch_login.get_auth_token(),
|
||||
self.session_id,
|
||||
settings=self.browser_settings,
|
||||
less_printing=self.logger_settings.less,
|
||||
settings=self.browser_settings
|
||||
)
|
||||
self.twitch_browser.init()
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import logging
|
||||
import copy
|
||||
|
||||
from enum import Enum, auto
|
||||
from millify import millify
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -77,6 +78,10 @@ class Bet:
|
||||
def __repr__(self):
|
||||
return f"Bet(TotalUsers={self.total_users}, TotalPoints={self.total_points}), Decision={self.decision})\n\t\tOutcome0({self.outcomes[0]})\n\t\tOutcome1({self.outcomes[1]})"
|
||||
|
||||
def get_outcome(self, index):
|
||||
outcome = self.outcomes[index]
|
||||
return f"{outcome['title']} ({outcome['color']}), Points: {millify(outcome['total_points'])}, Users: {millify(outcome['total_users'])} ({outcome['percentage_users']}%), Odds: {outcome['odds']} ({outcome['odds_percentage']}%)"
|
||||
|
||||
def __clear_outcomes(self):
|
||||
for index in range(0, len(self.outcomes)):
|
||||
keys = copy.deepcopy(list(self.outcomes[index].keys()))
|
||||
|
||||
@@ -55,7 +55,7 @@ def configure_loggers(username, settings):
|
||||
fmt=(
|
||||
"%(asctime)s - %(levelname)s - [%(funcName)s]: %(message)s"
|
||||
if settings.less is False
|
||||
else "%(asctime)s : %(message)s"
|
||||
else "%(asctime)s - %(message)s"
|
||||
),
|
||||
datefmt=("%d/%m/%y %H:%M:%S" if settings.less is False else "%d/%m %H:%M:%S"),
|
||||
print_emoji=settings.emoji,
|
||||
|
||||
@@ -419,14 +419,11 @@ class TwitchBrowser:
|
||||
decision = event.bet.calculate(event.streamer.channel_points)
|
||||
if decision["choice"]:
|
||||
selector_index = 1 if decision["choice"] == "A" else 2
|
||||
decision_outcome = (
|
||||
event.bet.outcomes[0]
|
||||
if decision["choice"] == "A"
|
||||
else event.bet.outcomes[1]
|
||||
)
|
||||
decision_outcome = event.bet.get_outcome(selector_index - 1)
|
||||
|
||||
try:
|
||||
logger.info(
|
||||
f"Going to write: {decision['amount']} on input {decision['choice']}\n\t\t{decision_outcome}",
|
||||
f"Going to write: {decision['amount']} on input {decision['choice']}: {decision_outcome}",
|
||||
extra={"emoji": ":wrench:"},
|
||||
)
|
||||
if (
|
||||
|
||||
@@ -4,4 +4,5 @@ browser_cookie3
|
||||
pillow
|
||||
selenium
|
||||
python-dateutil
|
||||
emoji
|
||||
emoji
|
||||
millify
|
||||
Reference in New Issue
Block a user