rdavydov / Twitch-Channel-Points-Miner-v2

A simple script that will watch a stream for you and earn the channel points.
GNU General Public License v3.0
1.13k stars 334 forks source link

Duplicate/quadruple notifications on Discord #304

Closed swissKunai closed 1 year ago

swissKunai commented 1 year ago

Describe the bug

When I start she script I only get one notification as wanted:

🚀  +10 → Streamer(username=dhalucard, channel_id=16064695, channel_points=254.98k) - Reason: WATCH.
🚀  +50 → Streamer(username=dhalucard, channel_id=16064695, channel_points=255.03k) - Reason: CLAIM.
🚀  +10 → Streamer(username=deadlyslob, channel_id=12731745, channel_points=21.5k) - Reason: WATCH.
🥳  Streamer(username=kotton, channel_id=81463115, channel_points=11.54k) is Online!
🥳  Streamer(username=insym, channel_id=75738685, channel_points=11.76k) is Online!
🚀  +10 → Streamer(username=deadlyslob, channel_id=12731745, channel_points=21.51k) - Reason: WATCH.

after ~1.5 hours I get every notification twice

🚀  +10 → Streamer(username=ohnepixel, channel_id=43683025, channel_points=111.71k) - Reason: WATCH.
🚀  +10 → Streamer(username=ohnepixel, channel_id=43683025, channel_points=111.71k) - Reason: WATCH.
🚀  +10 → Streamer(username=dhalucard, channel_id=16064695, channel_points=255.14k) - Reason: WATCH.
🚀  +10 → Streamer(username=dhalucard, channel_id=16064695, channel_points=255.14k) - Reason: WATCH.
🚀  +50 → Streamer(username=dhalucard, channel_id=16064695, channel_points=255.19k) - Reason: CLAIM.
🚀  +50 → Streamer(username=dhalucard, channel_id=16064695, channel_points=255.19k) - Reason: CLAIM.
🚀  +10 → Streamer(username=ohnepixel, channel_id=43683025, channel_points=111.72k) - Reason: WATCH.
🚀  +10 → Streamer(username=ohnepixel, channel_id=43683025, channel_points=111.72k) - Reason: WATCH.
🚀  +50 → Streamer(username=ohnepixel, channel_id=43683025, channel_points=111.77k) - Reason: CLAIM.
🚀  +50 → Streamer(username=ohnepixel, channel_id=43683025, channel_points=111.77k) - Reason: CLAIM.

Some time later I get quadruple notifications (not included in logs since it would be huge)

🚀  +10 → Streamer(username=sequisha, channel_id=25458544, channel_points=61.68k) - Reason: WATCH.
🚀  +10 → Streamer(username=sequisha, channel_id=25458544, channel_points=61.68k) - Reason: WATCH.
🚀  +10 → Streamer(username=sequisha, channel_id=25458544, channel_points=61.68k) - Reason: WATCH.
🚀  +10 → Streamer(username=sequisha, channel_id=25458544, channel_points=61.68k) - Reason: WATCH.
🚀  +10 → Streamer(username=anastasia_rose_official, channel_id=503630305, channel_points=68.18k) - Reason: WATCH.
🎁  Claiming the bonus for Streamer(username=anastasia_rose_official, channel_id=503630305, channel_points=68.18k)!
🚀  +10 → Streamer(username=anastasia_rose_official, channel_id=503630305, channel_points=68.18k) - Reason: WATCH.
🎁  Claiming the bonus for Streamer(username=anastasia_rose_official, channel_id=503630305, channel_points=68.18k)!
🚀  +10 → Streamer(username=anastasia_rose_official, channel_id=503630305, channel_points=68.18k) - Reason: WATCH.
🎁  Claiming the bonus for Streamer(username=anastasia_rose_official, channel_id=503630305, channel_points=68.18k)!
🚀  +10 → Streamer(username=anastasia_rose_official, channel_id=503630305, channel_points=68.18k) - Reason: WATCH.
🎁  Claiming the bonus for Streamer(username=anastasia_rose_official, channel_id=503630305, channel_points=68.18k)!

Steps to reproduce

I just run my script with Discord notifications enabled

Expected behavior

Only get one notification

Operating system

Ubuntu 20.04.6 LTS

Python version

3.8.10

Miner version

1.8.3

Other relevant software versions

No response

Logs

deleted link

Additional context

session is run with tmux, so it doesnt stop (idk if this helps)

rdavydov commented 1 year ago

Could you please also include your run.py file (with your credentials and sensitive info redacted). Need to check some things there.

swissKunai commented 1 year ago

I had the problem multiple times and after creating the issue I rebooted my VM and now it works... (I should have known better :D)

# -*- coding: utf-8 -*-

import logging
from colorama import Fore
from TwitchChannelPointsMiner import TwitchChannelPointsMiner
from TwitchChannelPointsMiner.logger import LoggerSettings, ColorPalette
from TwitchChannelPointsMiner.classes.Chat import ChatPresence
from TwitchChannelPointsMiner.classes.Discord import Discord
from TwitchChannelPointsMiner.classes.Matrix import Matrix
from TwitchChannelPointsMiner.classes.Telegram import Telegram
from TwitchChannelPointsMiner.classes.Settings import Priority, Events, FollowersOrder
from TwitchChannelPointsMiner.classes.entities.Bet import Strategy, BetSettings, Condition, OutcomeKeys, FilterCondition, DelayMode
from TwitchChannelPointsMiner.classes.entities.Streamer import Streamer, StreamerSettings

twitch_miner = TwitchChannelPointsMiner(
    username="",
    password="",           # If no password will be provided, the script will ask interactively
    claim_drops_startup=False,                  # If you want to auto claim all drops from Twitch inventory on the startup
    priority=[                                  # Custom priority in this case for example:
        Priority.DROPS,                         # - We want first of all to catch all watch streak from all streamers
        Priority.STREAK,                        # - When we don't have anymore watch streak to catch, wait until all drops are collected over the streamers
        Priority.POINTS_DESCEDING               # - When we have all of the drops claimed and no watch-streak available, use the order priority (POINTS_ASCENDING, POINTS_DESCEDING)
    ],
    enable_analytics=False,                     # Disables Analytics if False. Disabling it significantly reduces memory consumption
    disable_ssl_cert_verification=False,        # Set to True at your own risk and only to fix SSL: CERTIFICATE_VERIFY_FAILED error
    disable_at_in_nickname=True,                # Set to True if you want to check for your nickname mentions in the chat even without @ sign
    logger_settings=LoggerSettings(
        save=True,                              # If you want to save logs in a file (suggested)
        console_level=logging.INFO,             # Level of logs - use logging.DEBUG for more info
        console_username=False,                 # Adds a username to every console log line if True. Useful when you have many open consoles with different accounts
        auto_clear=True,                        # Create a file rotation handler with interval = 1D and backupCount = 7 if True (default)
        time_zone="CET",                           # Set a specific time zone for console and file loggers. Use tz database names. Example: "America/Denver"
        file_level=logging.DEBUG,               # Level of logs - If you think the log file it's too big, use logging.INFO
        emoji=True,                             # On Windows, we have a problem printing emoji. Set to false if you have a problem
        less=False,                             # If you think that the logs are too verbose, set this to True
        colored=True,                           # If you want to print colored text
        color_palette=ColorPalette(             # You can also create a custom palette color (for the common message).
            STREAMER_ONLINE = Fore.GREEN,       # Don't worry about lower/upper case. The script will parse all the values.
            STREAMER_OFFLINE = Fore.RED,        # Read more in README.md
            BET_WIN = Fore.GREEN,               # Color allowed are: [BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, RESET].            
            GAIN_FOR_RAID = Fore.YELLOW,
            GAIN_FOR_CLAIM = Fore.YELLOW,
            GAIN_FOR_WATCH = Fore.YELLOW,
            GAIN_FOR_WATCH_STREAK = Fore.YELLOW,
            BET_LOSE = Fore.RED,
            BET_REFUND = Fore.RESET,
            BET_FILTERS = Fore.MAGENTA,
            BET_GENERAL = Fore.BLUE,
            BET_FAILED = Fore.RED,
        ),
        discord=Discord(
            webhook_api="",  # Discord Webhook URL
            events=[Events.STREAMER_ONLINE, Events.STREAMER_OFFLINE,
                    Events.CHAT_MENTION, Events.DROP_CLAIM,
                    Events.GAIN_FOR_CLAIM, Events.GAIN_FOR_WATCH,
                    Events.MOMENT_CLAIM, Events.DROP_STATUS,
                    Events.GAIN_FOR_RAID],                                  # Only these events will be sent to the chat
        ),
        matrix=Matrix(
            username="twitch_miner",                                                   # Matrix username (without homeserver)
            password="...",                                                            # Matrix password
            homeserver="matrix.org",                                                   # Matrix homeserver
            room_id="...",                                                             # Room ID
            events=[Events.STREAMER_ONLINE, Events.STREAMER_OFFLINE, Events.BET_LOSE], # Only these events will be sent to the chat
        )
    ),
    streamer_settings=StreamerSettings(
        make_predictions=False,                 # If you want to Bet / Make prediction
        follow_raid=True,                       # Follow raid to obtain more points
        claim_drops=True,                       # We can't filter rewards base on stream. Set to False for skip viewing counter increase and you will never obtain a drop reward from this script. Issue #21
        claim_moments=True,                     # If set to True, https://help.twitch.tv/s/article/moments will be claimed when available
        watch_streak=True,                      # If a streamer go online change the priority of streamers array and catch the watch screak. Issue #11
        chat=ChatPresence.ONLINE,               # Join irc chat to increase watch-time [ALWAYS, NEVER, ONLINE, OFFLINE]
        bet=BetSettings(
            strategy=Strategy.SMART,            # Choose you strategy!
            percentage=5,                       # Place the x% of your channel points
            percentage_gap=20,                  # Gap difference between outcomesA and outcomesB (for SMART strategy)
            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 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=20000,               # 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
            )
        )
    )
)

# You can customize the settings for each streamer. If not settings were provided, the script would use the streamer_settings from TwitchChannelPointsMiner.
# If no streamer_settings are provided in TwitchChannelPointsMiner the script will use default settings.
# The streamers array can be a String -> username or Streamer instance.

# The settings priority are: settings in mine function, settings in TwitchChannelPointsMiner instance, default settings.
# For example, if in the mine function you don't provide any value for 'make_prediction' but you have set it on TwitchChannelPointsMiner instance, the script will take the value from here.
# If you haven't set any value even in the instance the default one will be used

#twitch_miner.analytics(host="127.0.0.1", port=5000, refresh=5, days_ago=7)   # Start the Analytics web-server

twitch_miner.mine(
    followers=True, blacklist=["julesaufyoutube"]                     # Automatic download the list of your followers
)