diff --git a/README.md b/README.md index 4ba7c93..1fcec52 100644 --- a/README.md +++ b/README.md @@ -216,12 +216,13 @@ twitch_miner = TwitchChannelPointsMiner( percentage=5, # Place the x% of your channel points percentage_gap=20, # Gap difference between outcomesA and outcomesB (for SMART stragegy) max_points=50000, # If the x percentage of your channel points is gt bet_max_points set this value - stealth_mode=True, # If the calculated amount of channel points is GT the highest bet, place the highest value minus 1-2 points #33 - delay_mode=DelayMode.FROM_END, # When placing a bet, we will wait until `delay` seconds before the end of the timer - delay=6, - filter_condition=FilterCondition( - by=OutcomeKeys.TOTAL_USERS, # Where apply the filter. Allowed [PERCENTAGE_USERS, ODDS_PERCENTAGE, ODDS, TOP_POINTS, TOTAL_USERS, TOTAL_POINTS] - where=Condition.LTE, # 'by' must be [GT, LT, GTE, LTE] than value + stealth_mode=True, # If the calculated amount of channel points is GT the highest bet, place the highest value minus 1-2 points Issue #33 + delay_mode=DelayMode.FROM_END, # When placing a bet, we will wait until `delay` seconds before the end of the timer + delay=6, + minimum_points=2000, # Place the bet only if we have at least 20k points. Issue #113 + filter_condition=FilterCondition( + by=OutcomeKeys.TOTAL_USERS, # Where apply the filter. Allowed [PERCENTAGE_USERS, ODDS_PERCENTAGE, ODDS, TOP_POINTS, TOTAL_USERS, TOTAL_POINTS] + where=Condition.LTE, # 'by' must be [GT, LT, GTE, LTE] than value value=800 ) ) diff --git a/TwitchChannelPointsMiner/classes/WebSocketsPool.py b/TwitchChannelPointsMiner/classes/WebSocketsPool.py index 7047991..71fa0fb 100644 --- a/TwitchChannelPointsMiner/classes/WebSocketsPool.py +++ b/TwitchChannelPointsMiner/classes/WebSocketsPool.py @@ -263,24 +263,41 @@ class WebSocketsPool: ws.streamers[streamer_index].is_online and event.closing_bet_after(current_tmsp) > 0 ): - ws.events_predictions[event_id] = event - start_after = event.closing_bet_after(current_tmsp) + streamer = ws.streamers[streamer_index] + bet_settings = streamer.settings.bet + if ( + bet_settings.minimum_points is None + or streamer.channel_points + > bet_settings.minimum_points + ): + ws.events_predictions[event_id] = event + start_after = event.closing_bet_after( + current_tmsp + ) - place_bet_thread = Timer( - start_after, - ws.twitch.make_predictions, - (ws.events_predictions[event_id],), - ) - place_bet_thread.daemon = True - place_bet_thread.start() + place_bet_thread = Timer( + start_after, + ws.twitch.make_predictions, + (ws.events_predictions[event_id],), + ) + place_bet_thread.daemon = True + place_bet_thread.start() - logger.info( - f"Place the bet after: {start_after}s for: {ws.events_predictions[event_id]}", - extra={ - "emoji": ":alarm_clock:", - "color": Settings.logger.color_palette.BET_START, - }, - ) + logger.info( + f"Place the bet after: {start_after}s for: {ws.events_predictions[event_id]}", + extra={ + "emoji": ":alarm_clock:", + "color": Settings.logger.color_palette.BET_START, + }, + ) + else: + logger.info( + f"{streamer} have only {streamer.channel_points} channel points and the minimum for bet is: {bet_settings.minimum_points}", + extra={ + "emoji": ":pushpin:", + "color": Settings.logger.color_palette.BET_FILTERS, + }, + ) elif ( message.type == "event-updated" diff --git a/TwitchChannelPointsMiner/classes/entities/Bet.py b/TwitchChannelPointsMiner/classes/entities/Bet.py index a1dc0c9..9b70aeb 100644 --- a/TwitchChannelPointsMiner/classes/entities/Bet.py +++ b/TwitchChannelPointsMiner/classes/entities/Bet.py @@ -72,6 +72,7 @@ class BetSettings(object): "percentage", "percentage_gap", "max_points", + "minimum_points", "stealth_mode", "filter_condition", "delay", @@ -84,6 +85,7 @@ class BetSettings(object): percentage: int = None, percentage_gap: int = None, max_points: int = None, + minimum_points: int = None, stealth_mode: bool = None, filter_condition: FilterCondition = None, delay: float = None, @@ -93,6 +95,7 @@ class BetSettings(object): self.percentage = percentage self.percentage_gap = percentage_gap self.max_points = max_points + self.minimum_points = minimum_points self.stealth_mode = stealth_mode self.filter_condition = filter_condition self.delay = delay @@ -103,12 +106,13 @@ class BetSettings(object): self.percentage = self.percentage if not None else 5 self.percentage_gap = self.percentage_gap if not None else 20 self.max_points = self.max_points if not None else 50000 + self.minimum_points = self.minimum_points if not None else 0 self.stealth_mode = self.stealth_mode if not None else False self.delay = self.delay if not None else 6 self.delay_mode = self.delay_mode if not None else DelayMode.FROM_END def __repr__(self): - return f"BetSettings(strategy={self.strategy}, percentage={self.percentage}, percentage_gap={self.percentage_gap}, max_points={self.max_points}, stealth_mode={self.stealth_mode})" + return f"BetSettings(strategy={self.strategy}, percentage={self.percentage}, percentage_gap={self.percentage_gap}, max_points={self.max_points}, minimum_points={self.minimum_points}, stealth_mode={self.stealth_mode})" class Bet(object): diff --git a/example.py b/example.py index a8eb20f..5395516 100644 --- a/example.py +++ b/example.py @@ -5,7 +5,7 @@ from colorama import Fore from TwitchChannelPointsMiner import TwitchChannelPointsMiner from TwitchChannelPointsMiner.logger import LoggerSettings, ColorPalette from TwitchChannelPointsMiner.classes.Settings import Priority -from TwitchChannelPointsMiner.classes.entities.Bet import Strategy, BetSettings, Condition, OutcomeKeys, FilterCondition +from TwitchChannelPointsMiner.classes.entities.Bet import Strategy, BetSettings, Condition, OutcomeKeys, FilterCondition, DelayMode from TwitchChannelPointsMiner.classes.entities.Streamer import Streamer, StreamerSettings twitch_miner = TwitchChannelPointsMiner( @@ -41,10 +41,13 @@ twitch_miner = TwitchChannelPointsMiner( percentage=5, # Place the x% of your channel points percentage_gap=20, # Gap difference between outcomesA and outcomesB (for SMART stragegy) max_points=50000, # If the x percentage of your channel points is gt bet_max_points set this value - stealth_mode=True, # If the calculated amount of channel points is GT the highest bet, place the highest value minus 1-2 points #33 + stealth_mode=True, # If the calculated amount of channel points is GT the highest bet, place the highest value minus 1-2 points Issue #33 + delay_mode=DelayMode.FROM_END, # When placing a bet, we will wait until `delay` seconds before the end of the timer + delay=6, + minimum_points=2000, # Place the bet only if we have at least 20k points. Issue #113 filter_condition=FilterCondition( - by=OutcomeKeys.TOTAL_USERS, # Where apply the filter. Allowed [PERCENTAGE_USERS, ODDS_PERCENTAGE, ODDS, TOP_POINTS, TOTAL_USERS, TOTAL_POINTS] - where=Condition.LTE, # 'by' must be [GT, LT, GTE, LTE] than value + by=OutcomeKeys.TOTAL_USERS, # Where apply the filter. Allowed [PERCENTAGE_USERS, ODDS_PERCENTAGE, ODDS, TOP_POINTS, TOTAL_USERS, TOTAL_POINTS] + where=Condition.LTE, # 'by' must be [GT, LT, GTE, LTE] than value value=800 ) )