Sync with current master branch

This commit is contained in:
Alessandro Maggio
2021-02-01 21:50:24 +01:00
8 changed files with 50 additions and 25 deletions

View File

@@ -1,5 +1,27 @@
# Twitch Channel Points Miner - v2
![Banner](./assets/banner.png)
<p align="center">
<a href="https://github.com/Tkd-Alex/Twitch-Channel-Points-Miner-v2/blob/master/LICENSE">
<img alt="License" src="https://img.shields.io/github/license/Tkd-Alex/Twitch-Channel-Points-Miner-v2" />
</a>
<a href="https://www.python.org/download/releases/3.0/">
<img alt="Python3" src="https://img.shields.io/badge/built%20with-Python3-red.svg?style=flat" />
</a>
<a href="https://github.com/Tkd-Alex/Twitch-Channel-Points-Miner-v2/pulls">
<img alt="PRsWelcome" src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat" />
</a>
<a href="https://github.com/Tkd-Alex/Twitch-Channel-Points-Miner-v2/stargazers">
<img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/Tkd-Alex/Twitch-Channel-Points-Miner-v2" />
</a>
<a href="https://github.com/Tkd-Alex/Twitch-Channel-Points-Miner-v2/issues?q=is%3Aissue+is%3Aclosed">
<img alt="GitHub closed issues" src="https://img.shields.io/github/issues-closed/Tkd-Alex/Twitch-Channel-Points-Miner-v2">
</a>
<a href="https://github.com/Tkd-Alex/Twitch-Channel-Points-Miner-v2">
<img alt="GitHub last commit" src="https://img.shields.io/github/last-commit/Tkd-Alex/Twitch-Channel-Points-Miner-v2" />
</a>
</p>
**Credits**
- Main idea: https://github.com/gottagofaster236/Twitch-Channel-Points-Miner
- Bet system (Selenium): https://github.com/ClementRoyer/TwitchAutoCollect-AutoBet
@@ -112,19 +134,19 @@ For the bet system the script use Selenium. Could be usefull understand how to M
Outcome1(NO (PINK) Points: 2M, Users: 146 (56.15%), Odds: 1.31 (76.34%))
Result: {'type': 'LOSE', 'won': 0}
%d/%m/%y %H:%M:%S - 🤖 Streamer(username=streamer-username, channel_id=0000000, channel_points=67247), Gained (end-start): -7838
%d/%m/%y %H:%M:%S - 🤖 Streamer(username=streamer-username, channel_id=0000000, channel_points=67247), Total points gained (after farming - before farming): -7838
%d/%m/%y %H:%M:%S - 💰 WATCH(35 times, 350 gained), CLAIM(11 times, 550 gained), PREDICTION(1 times, 6531 gained)
%d/%m/%y %H:%M:%S - 🤖 Streamer(username=streamer-username1, channel_id=0000000, channel_points=4240), Gained (end-start): 0
%d/%m/%y %H:%M:%S - 🤖 Streamer(username=streamer-username2, channel_id=0000000, channel_points=61365), Gained (end-start): 977
%d/%m/%y %H:%M:%S - 🤖 Streamer(username=streamer-username1, channel_id=0000000, channel_points=4240), Total points gained (after farming - before farming): 0
%d/%m/%y %H:%M:%S - 🤖 Streamer(username=streamer-username2, channel_id=0000000, channel_points=61365), Total points gained (after farming - before farming): 977
%d/%m/%y %H:%M:%S - 💰 WATCH(11 times, 132 gained), REFUND(1 times, 605 gained), CLAIM(4 times, 240 gained)
%d/%m/%y %H:%M:%S - 🤖 Streamer(username=streamer-username3, channel_id=0000000, channel_points=6815), Gained (end-start): 0
%d/%m/%y %H:%M:%S - 🤖 Streamer(username=streamer-username4, channel_id=0000000, channel_points=16386), Gained (end-start): 0
%d/%m/%y %H:%M:%S - 🤖 Streamer(username=streamer-username5, channel_id=0000000, channel_points=25960), Gained (end-start): 1680
%d/%m/%y %H:%M:%S - 🤖 Streamer(username=streamer-username3, channel_id=0000000, channel_points=6815), Total points gained (after farming - before farming): 0
%d/%m/%y %H:%M:%S - 🤖 Streamer(username=streamer-username4, channel_id=0000000, channel_points=16386), Total points gained (after farming - before farming): 0
%d/%m/%y %H:%M:%S - 🤖 Streamer(username=streamer-username5, channel_id=0000000, channel_points=25960), Total points gained (after farming - before farming): 1680
%d/%m/%y %H:%M:%S - 💰 WATCH(53 times, 530 gained), CLAIM(17 times, 850 gained)
%d/%m/%y %H:%M:%S - 🤖 Streamer(username=streamer-username6, channel_id=0000000, channel_points=9430), Gained (end-start): 1120
%d/%m/%y %H:%M:%S - 🤖 Streamer(username=streamer-username6, channel_id=0000000, channel_points=9430), Total points gained (after farming - before farming): 1120
%d/%m/%y %H:%M:%S - 💰 WATCH(42 times, 420 gained), WATCH_STREAK(1 times, 450 gained), CLAIM(14 times, 700 gained)
%d/%m/%y %H:%M:%S - 🤖 Streamer(username=streamer-username7, channel_id=0000000, channel_points=2380), Gained (end-start): 0
%d/%m/%y %H:%M:%S - 🤖 Streamer(username=streamer-username8, channel_id=0000000, channel_points=10230), Gained (end-start): 0
%d/%m/%y %H:%M:%S - 🤖 Streamer(username=streamer-username7, channel_id=0000000, channel_points=2380), Total points gained (after farming - before farming): 0
%d/%m/%y %H:%M:%S - 🤖 Streamer(username=streamer-username8, channel_id=0000000, channel_points=10230), Total points gained (after farming - before farming): 0
```
## How to use:

View File

@@ -26,6 +26,7 @@ from TwitchChannelPointsMiner.classes.TwitchBrowser import (
from TwitchChannelPointsMiner.classes.WebSocketsPool import WebSocketsPool
from TwitchChannelPointsMiner.logger import LoggerSettings, configure_loggers
from TwitchChannelPointsMiner.utils import (
_millify,
at_least_one_value_in_settings_is,
get_user_agent,
set_default_settings,
@@ -295,7 +296,7 @@ class TwitchChannelPointsMiner:
for streamer_index in range(0, len(self.streamers)):
logger.info(
f"{repr(self.streamers[streamer_index])}, Total Points Gained (after farming - before farming): {self.streamers[streamer_index].channel_points - self.original_streamers[streamer_index].channel_points}",
f"{repr(self.streamers[streamer_index])}, Total Points Gained (after farming - before farming): {_millify(self.streamers[streamer_index].channel_points - self.original_streamers[streamer_index].channel_points)}",
extra={"emoji": ":robot:"},
)
if self.streamers[streamer_index].history != {}:

View File

@@ -6,7 +6,6 @@ import time
from enum import Enum, auto
from pathlib import Path
from millify import prettify
from selenium import webdriver
from selenium.common.exceptions import JavascriptException, TimeoutException
from selenium.webdriver.common.action_chains import ActionChains
@@ -17,7 +16,7 @@ from selenium.webdriver.support.ui import WebDriverWait
from TwitchChannelPointsMiner.classes.entities.EventPrediction import EventPrediction
from TwitchChannelPointsMiner.constants.browser import Javascript, Selectors
from TwitchChannelPointsMiner.constants.twitch import URL
from TwitchChannelPointsMiner.utils import bet_condition, get_user_agent
from TwitchChannelPointsMiner.utils import _millify, bet_condition, get_user_agent
logger = logging.getLogger(__name__)
@@ -339,7 +338,7 @@ class TwitchBrowser:
try:
logger.info(
f"Going to write: {prettify(decision['amount'], '.')} channel points on input {decision['choice']}",
f"Going to write: {_millify(decision['amount'])} channel points on input {decision['choice']}",
extra={"emoji": ":wrench:"},
)
if (

View File

@@ -5,7 +5,6 @@ import threading
import time
from dateutil import parser
from millify import millify
from TwitchChannelPointsMiner.classes.entities.EventPrediction import EventPrediction
from TwitchChannelPointsMiner.classes.entities.Message import Message
@@ -14,6 +13,7 @@ from TwitchChannelPointsMiner.classes.Exceptions import TimeBasedDropNotFound
from TwitchChannelPointsMiner.classes.TwitchWebSocket import TwitchWebSocket
from TwitchChannelPointsMiner.constants.twitch import WEBSOCKET
from TwitchChannelPointsMiner.utils import (
_millify,
bet_condition,
calculate_start_after,
get_streamer_index,
@@ -254,7 +254,7 @@ class WebSocketsPool:
if message.type == "prediction-result":
event_result = message.data["prediction"]["result"]
logger.info(
f"{ws.events_predictions[event_id]} - Result: {event_result['type']}, Points won: {millify(event_result['points_won']) if event_result['points_won'] else 0}",
f"{ws.events_predictions[event_id]} - Result: {event_result['type']}, Points won: {_millify(event_result['points_won']) if event_result['points_won'] else 0}",
extra={"emoji": ":bar_chart:"},
)
points_won = (

View File

@@ -2,9 +2,7 @@ import copy
import logging
from enum import Enum, auto
from millify import millify
from TwitchChannelPointsMiner.utils import float_round
from TwitchChannelPointsMiner.utils import _millify, float_round
logger = logging.getLogger(__name__)
@@ -80,11 +78,11 @@ class Bet:
self.__clear_outcomes()
def __repr__(self):
return f"Bet(TotalUsers={millify(self.total_users)}, TotalPoints={millify(self.total_points)}), Decision={self.decision})\n\t\tOutcome0({self.get_outcome(0)})\n\t\tOutcome1({self.get_outcome(1)})"
return f"Bet(TotalUsers={_millify(self.total_users)}, TotalPoints={_millify(self.total_points)}), Decision={self.decision})\n\t\tOutcome0({self.get_outcome(0)})\n\t\tOutcome1({self.get_outcome(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']}%)"
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)):

View File

@@ -1,12 +1,11 @@
import logging
import time
from millify import prettify
from TwitchChannelPointsMiner.classes.entities.Bet import BetSettings
from TwitchChannelPointsMiner.classes.entities.Stream import Stream
from TwitchChannelPointsMiner.classes.Settings import Settings
from TwitchChannelPointsMiner.constants.twitch import URL
from TwitchChannelPointsMiner.utils import _millify
logger = logging.getLogger(__name__)
@@ -56,11 +55,11 @@ class Streamer(object):
self.chat_url = f"{URL}/popout/{self.username}/chat?popout="
def __repr__(self):
return f"Streamer(username={self.username}, channel_id={self.channel_id}, channel_points={prettify(self.channel_points, '.')})"
return f"Streamer(username={self.username}, channel_id={self.channel_id}, channel_points={_millify(self.channel_points)})"
def __str__(self):
return (
f"{self.username} ({prettify(self.channel_points, '.')} points)"
f"{self.username} ({_millify(self.channel_points)} points)"
if Settings.logger.less
else self.__repr__()
)
@@ -83,7 +82,7 @@ class Streamer(object):
def print_history(self):
return ", ".join(
[
f"{key}({self.history[key]['counter']} times, {prettify(self.history[key]['amount'], '.')} gained)"
f"{key}({self.history[key]['counter']} times, {_millify(self.history[key]['amount'])} gained)"
for key in self.history
]
)

View File

@@ -4,9 +4,15 @@ import time
from datetime import datetime, timezone
from random import randrange
from millify import millify
from TwitchChannelPointsMiner.constants.browser import USER_AGENTS
def _millify(input, precision=2):
return millify(input, precision)
def get_streamer_index(streamers: list, channel_id) -> int:
try:
return next(

BIN
assets/banner.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB