diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index ea12473..4aef640 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -10,7 +10,7 @@ Please delete options that are not relevant. - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) -- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) +- [ ] Breaking change (fix or feature that would cause existing functionality not to work as expected) # How Has This Been Tested? @@ -19,7 +19,7 @@ Please describe the tests that you ran to verify your changes. Provide instructi # Checklist: - [ ] My code follows the style guidelines of this project -- [ ] I have performed a self-review of my own code +- [ ] I have performed a self-review of my code - [ ] I have commented on my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation (README.md) - [ ] My changes generate no new warnings diff --git a/.github/stale.yml b/.github/stale.yml index 8a3287d..073f80c 100644 --- a/.github/stale.yml +++ b/.github/stale.yml @@ -1,5 +1,5 @@ # Number of days of inactivity before an issue becomes stale -daysUntilStale: 60 +daysUntilStale: 150 # Number of days of inactivity before a stale issue is closed daysUntilClose: 7 diff --git a/.gitignore b/.gitignore index 0d8276a..c1445f5 100644 --- a/.gitignore +++ b/.gitignore @@ -148,4 +148,5 @@ chromedriver* cookies/* logs/* screenshots/* -htmls/* \ No newline at end of file +htmls/* +analytics/* \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 19a7f0e..561e067 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,7 +4,7 @@ Before you begin: - Have you read the [code of conduct](CODE_OF_CONDUCT.md)? -- Check out the [existing issues](https://github.com/Tkd-Alex/Twitch-Channel-Points-Miner-v2/issues) & see if there is already an opened issued +- Check out the [existing issues](https://github.com/Tkd-Alex/Twitch-Channel-Points-Miner-v2/issues) & see if there is already an opened issue. ### Ready to make a change? Fork the repo @@ -72,14 +72,14 @@ Labels can help you find an issue you'd like to help with. - The `documentation` label is used when you suggest improvements or additions to documentation (README.md update) - The `duplicate` label is used when this issue or pull request already exists - The `enhancement` label is used when you ask for / or propose a new feature or request -- The `help wanted` is used when labeling when you need help with something +- The `help wanted` is used when you need help with something - The `improvements` label is used when you would suggest improvements on already existing features - The `invalid` label is used for a non-valid issue -- The `question` label, is used for further information is requested +- The `question` label is used for further information is requested - The `wontfix` label is used if we will not work on it ## Opening a pull request -You can use the GitHub user interface :pencil2: for some small changes, like fixing a typo or updating a readme. You can also fork the repo and then clone it locally to view changes and run your tests on your machine. +You can use the GitHub user interface :pencil2: for minor changes, like fixing a typo or updating a readme. You can also fork the repo and then clone it locally to view changes and run your tests on your machine. ### Self review You should always review your own PR first. diff --git a/README.md b/README.md index 4c012ff..e19c318 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ - +
@@ -18,6 +18,14 @@
Read more about channels point [here](https://help.twitch.tv/s/article/channel-points-guide)
+## π’ Help wanted
+Currently, we have a lot of PRs requests opened, but the time to test and improve It's less and less. If you want to help the community and the project, please test the following PRs and give us feedback:
+- [Features/improvements to analytics #131](https://github.com/Tkd-Alex/Twitch-Channel-Points-Miner-v2/pull/131)
+- [Add SMART_HIGH_ODDS strategy #172](https://github.com/Tkd-Alex/Twitch-Channel-Points-Miner-v2/pull/172)
+- [Replace join_chat boolean with chat: ChatPresence #253](https://github.com/Tkd-Alex/Twitch-Channel-Points-Miner-v2/pull/253)
+- [Receive updates to Telegram #254](https://github.com/Tkd-Alex/Twitch-Channel-Points-Miner-v2/pull/254)
+- [Add stats #318](https://github.com/Tkd-Alex/Twitch-Channel-Points-Miner-v2/pull/318)
+
# README Contents
1. π€ [Community](#community)
2. π [Main differences from the original repository](#main-differences-from-the-original-repository)
@@ -27,6 +35,7 @@ Read more about channels point [here](https://help.twitch.tv/s/article/channel-p
- [Final report](#final-report)
4. π§ [How to use](#how-to-use)
- [Cloning](#by-cloning-the-repository)
+ - [pip](#pip)
- [Docker](#docker)
- [Limits](#limits)
5. π§ [Settings](#settings)
@@ -36,21 +45,23 @@ Read more about channels point [here](https://help.twitch.tv/s/article/channel-p
- [Bet strategy](#bet-strategy)
- [FilterCondition](#filtercondition)
- [Example](#example)
-6. πͺ [Migrating from old repository (the original one)](#migrating-from-old-repository-the-original-one)
-7. πͺ [Windows](#windows)
-8. β οΈ [Disclaimer](#disclaimer)
+6. π [Analytics](#analytics)
+7. πͺ [Migrating from an old repository (the original one)](#migrating-from-an-old-repository-the-original-one)
+8. πͺ [Windows](#windows)
+9. π± [Termux](#termux)
+10. β οΈ [Disclaimer](#disclaimer)
## Community
-If you have any type of issue, you need help, or you just want to suggest a new feature, please open a GitHub Issue. Don't write me on [Instagram](https://www.instagram.com/tkd_alex/), [Telegram](https://t.me/TkdAlex), [Discord](https://discordapp.com/users/641397388132483121), [Twitter](https://twitter.com/TkdAxel) (but you can follow me π) or somewhere else. If you don't have an account on this platform, you can create it. It's free. I do not want to be rude, but if you have a problem, maybe another user can also have the same problem, and your issue can help the community. Same for the new feature, your idea can help other users, and It's beautiful to discuss between us.
+If you have any type of issue, need help, or want to suggest a new feature, please open a GitHub Issue. Don't write me on [Instagram](https://www.instagram.com/tkd_alex/), [Telegram](https://t.me/TkdAlex), [Discord](https://discordapp.com/users/641397388132483121), [Twitter](https://twitter.com/TkdAxel) (but you can follow me π) or somewhere else. If you don't have an account on this platform, you can create it. It's free. I do not want to be rude, but if you have a problem, maybe another user can also have the same problem, and your issue can help the community. Same for the new feature, your idea can help other users, and It's beautiful to discuss between us.
If you want to help on this project, please leave a star π and share it with your friends! π
-A coffee is always a gesture of LOVE β€οΈ
+If you want to offer me a coffee, I would be grateful β€οΈ
-If you have any issues or you want to contribute, you are welcome! But please before read the [CONTRIBUTING.md](/CONTRIBUTING.md)
+If you have any issues or you want to contribute, you are welcome! But please before read the [CONTRIBUTING.md](https://github.com/Tkd-Alex/Twitch-Channel-Points-Miner-v2/blob/master/CONTRIBUTING.md) file.
## Main differences from the original repository:
@@ -62,6 +73,8 @@ If you have any issues or you want to contribute, you are welcome! But please be
- Auto claim game drops from Twitch inventory [#21](https://github.com/Tkd-Alex/Twitch-Channel-Points-Miner-v2/issues/21) Read more about game drops [here](https://help.twitch.tv/s/article/mission-based-drops)
- Place the bet / make a prediction and win or lose (π) your channel points!
No browser needed. [#41](https://github.com/Tkd-Alex/Twitch-Channel-Points-Miner-v2/issues/41) ([@lay295](https://github.com/lay295))
+- Analytics chart that show the progress of your points with various annotations [#96](https://github.com/Tkd-Alex/Twitch-Channel-Points-Miner-v2/issues/96)
+- Join IRC Chat for increase watch-time and get StreamElements points [#47](https://github.com/Tkd-Alex/Twitch-Channel-Points-Miner-v2/issues/47)
## Logs feature
### Full logs
@@ -161,18 +174,7 @@ No browser needed. [#41](https://github.com/Tkd-Alex/Twitch-Channel-Points-Miner
```
## How to use:
-
-### By cloning the repository
-
-1. Clone this repository `git clone https://github.com/Tkd-Alex/Twitch-Channel-Points-Miner-v2`
-2. Install all the requirements `pip install -r requirements.txt` . If you have problems with requirements make sure to have at least Python3.6. You could also try to create a virtualenv and then install all the requirements
-```sh
-pip install virtualenv
-virtualenv -p python3 venv
-source venv/bin/activate
-pip install -r requirements.txt
-```
-3. Create your `run.py` file start from [example.py](/example.py)
+First of all please create a run.py file. You can just copy [example.py](https://github.com/Tkd-Alex/Twitch-Channel-Points-Miner-v2/blob/master/example.py) and modify it according to your needs.
```python
# -*- coding: utf-8 -*-
@@ -181,17 +183,17 @@ 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(
username="your-twitch-username",
- password="write-your-secure-psw", # 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 startup
+ password="write-your-secure-psw", # 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.STREAK, # - we want first of all to catch all watch streak from all streamers
- Priority.DROPS, # - when we don't have anymore watch streak to catch wait until all drops are collected over the streamers
- Priority.ORDER # - when we have all of drops claimed and no watch-streak avaialable use the order priority (POINTS_ASCENDING, POINTS_DESCEDING)
+ Priority.STREAK, # - We want first of all to catch all watch streak from all streamers
+ Priority.DROPS, # - When we don't have anymore watch streak to catch, wait until all drops are collected over the streamers
+ Priority.ORDER # - When we have all of the drops claimed and no watch-streak available, use the order priority (POINTS_ASCENDING, POINTS_DESCEDING)
],
logger_settings=LoggerSettings(
save=True, # If you want to save logs in a file (suggested)
@@ -201,7 +203,7 @@ twitch_miner = TwitchChannelPointsMiner(
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="GREEN", # Don't worry about lower/upper case the script will be parse all the values.
+ STREAMER_online="GREEN", # Don't worry about lower/upper case. The script will parse all the values.
streamer_offline="red", # Read more in README.md
BET_wiN=Fore.MAGENTA # Color allowed are: [BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, RESET].
)
@@ -211,15 +213,19 @@ twitch_miner = TwitchChannelPointsMiner(
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
watch_streak=True, # If a streamer go online change the priotiry of streamers array and catch the watch screak. Issue #11
+ join_chat=True, # Join irc chat to increase watch-time
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 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
)
)
@@ -259,13 +265,29 @@ twitch_miner.mine(["streamer1", "streamer2"]) # Array of strea
twitch_miner.mine(followers=True) # Automatic use the followers list OR
twitch_miner.mine(["streamer1", "streamer2"], followers=True) # Mixed
```
-If you follow so many streamers on Twitch, but you don't want to mine points for all of them, you can blacklist the users with `blacklist` keyword. [#94](https://github.com/Tkd-Alex/Twitch-Channel-Points-Miner-v2/issues/94)
+If you follow so many streamers on Twitch, but you don't want to mine points for all of them, you can blacklist the users with the `blacklist` keyword. [#94](https://github.com/Tkd-Alex/Twitch-Channel-Points-Miner-v2/issues/94)
```python
from TwitchChannelPointsMiner import TwitchChannelPointsMiner
twitch_miner = TwitchChannelPointsMiner("your-twitch-username")
-twitch_miner.mine(followers=True, blacklist=["user1", "user2"]) # Automatic use the followers list OR
+twitch_miner.mine(followers=True, blacklist=["user1", "user2"]) # Blacklist example
```
-4. Start mining! `python run.py`
+
+### By cloning the repository
+1. Clone this repository `git clone https://github.com/Tkd-Alex/Twitch-Channel-Points-Miner-v2`
+2. Install all the requirements `pip install -r requirements.txt` . If you have problems with requirements, make sure to have at least Python3.6. You could also try to create a _virtualenv_ and then install all the requirements
+```sh
+pip install virtualenv
+virtualenv -p python3 venv
+source venv/bin/activate
+pip install -r requirements.txt
+```
+
+Start mining! `python run.py` π₯³
+
+### pip
+Install the package via pip, you will find a stable version - maybe a different version from the master branch.
+- `pip install Twitch-Channel-Points-Miner-v2`
+- Exceute the run.py file `python run.py` π₯³
### Docker
@@ -300,16 +322,17 @@ services:
```
### Limits
-> Twitch has a limit - you can't watch more than 2 channels at one time. We take the first two streamers from the list as they have the highest priority.
+> Twitch has a limit - you can't watch more than two channels at one time. We take the first two streamers from the list as they have the highest priority.
Make sure to write the streamers array in order of priority from left to right. If you use `followers=True` Twitch return the streamers order by followed_at. So your last follow has the highest priority.
## Settings
-Most of the settings are self-explained and are commented in example.
-You can watch only two streamers per time. With `priority` settings you can select which streamers watch by use priority. You can use an array of priority or single item. I suggest to use at least one priority from `ORDER`, `POINTS_ASCENDING`, `POINTS_DESCEDING` because for example If you set only `STREAK` after catch all watch streak the script will stop to watch streamers.
+Most of the settings are self-explained and are commented on in the example.
+You can watch only two streamers per time. With `priority` settings, you can select which streamers watch by use priority. You can use an array of priority or single item. I suggest using at least one priority from `ORDER`, `POINTS_ASCENDING`, `POINTS_DESCEDING` because, for example, If you set only `STREAK` after catch all watch streak, the script will stop to watch streamers.
Available values are the following:
- `STREAK` - Catch the watch streak from all streamers
- `DROPS` - Claim all drops from streamers with drops tags enabled
+ - `SUBSCRIBED` - Prioritize streamers you're subscribed to (higher subscription tiers are mined first)
- `ORDER` - Following the order of the list
- `POINTS_ASCENDING` - On top the streamers with the lowest points
- `POINTS_DESCEDING` - On top the streamers with the highest points
@@ -325,6 +348,7 @@ You can combine all priority but keep in mind that use `ORDER` and `POINTS_ASCEN
| `file_level` | level | logging.DEBUG | Level of logs in file save - If you think the log file it's too big, use logging.INFO |
| `emoji` | bool | For Windows is False else True | On Windows, we have a problem printing emoji. Set to false if you have a problem |
| `colored` | bool | True | If you want to print colored text [#45](https://github.com/Tkd-Alex/Twitch-Channel-Points-Miner-v2/issues/45) [#82](https://github.com/Tkd-Alex/Twitch-Channel-Points-Miner-v2/issues/82) |
+| `auto_clear` | bool | True | Create a file rotation handler with interval = 1D and backupCount = 7 [#215](https://github.com/Tkd-Alex/Twitch-Channel-Points-Miner-v2/issues/215) |
| `color_palette` | ColorPalette | All messages are Fore.RESET except WIN and LOSE bet (GREEN and RED) | Create your custom color palette. Read more above. |
#### Color Palette
@@ -348,17 +372,18 @@ The script was developed to handle all the human error, lower-case upper case an
```python
from colorama import Fore
ColorPalette(
- "STREAMER_ONLINE" = Fore.GREEN,
- "STREAMER_OFFLINE" = Fore.RED,
- "GAIN_FOR_RAID" = Fore.YELLOW,
- "GAIN_FOR_CLAIM" = Fore.YELLOW,
- "GAIN_FOR_WATCH" = Fore.YELLOW,
- "BET_WIN" = Fore.GREEN,
- "BET_LOSE" = Fore.RED,
- "BET_REFUND" = Fore.RESET,
- "BET_FILTERS" = Fore.MAGENTA,
- "BET_GENERAL" = Fore.BLUE,
- "BET_FAILED" = Fore.RED,
+ STREAMER_ONLINE = Fore.GREEN,
+ STREAMER_OFFLINE = Fore.RED,
+ GAIN_FOR_RAID = Fore.YELLOW,
+ GAIN_FOR_CLAIM = Fore.YELLOW,
+ GAIN_FOR_WATCH = Fore.YELLOW,
+ GAIN_FOR_WATCH_STREAK = Fore.YELLOW,
+ BET_WIN = Fore.GREEN,
+ BET_LOSE = Fore.RED,
+ BET_REFUND = Fore.RESET,
+ BET_FILTERS = Fore.MAGENTA,
+ BET_GENERAL = Fore.BLUE,
+ BET_FAILED = Fore.RED,
)
```
@@ -367,34 +392,36 @@ ColorPalette(
|-------------------- |------------- |-------------------------------- |---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `make_predictions` | bool | True | Choose if you want to make predictions / bet or not |
| `follow_raid` | bool | True | Choose if you want to follow raid +250 points |
-| `claim_drops` | bool | True | If this value is True, the script will increase the watch-time for the current game. With this, you are able to claim the drops from Twitch Inventory [#21](https://github.com/Tkd-Alex/Twitch-Channel-Points-Miner-v2/issues/21) |
+| `claim_drops` | bool | True | If this value is True, the script will increase the watch-time for the current game. With this, you can claim the drops from Twitch Inventory [#21](https://github.com/Tkd-Alex/Twitch-Channel-Points-Miner-v2/issues/21) |
| `watch_streak` | bool | True | Choose if you want to change a priority for these streamers and try to catch the Watch Streak event [#11](https://github.com/Tkd-Alex/Twitch-Channel-Points-Miner-v2/issues/11) |
+| `join_chat` | bool | True | Join IRC-Chat to appear online in chat and attempt to get StreamElements channel points and increase view-time [#47](https://github.com/Tkd-Alex/Twitch-Channel-Points-Miner-v2/issues/47) |
| `bet` | BetSettings | | Rules to follow for the bet |
### BetSettings
-| Key | Type | Default | Description |
-|-------------------- |----------------- |--------- |--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| `strategy` | Strategy | SMART | Choose your strategy! See above for more info |
-| `percentage` | int | 5 | Place the x% of your channel points |
-| `percentage_gap` | int | 20 | Gap difference between outcomesA and outcomesB (for SMART stragegy) |
-| `max_points` | int | 50000 | If the x percentage of your channel points is GT bet_max_points set this value |
-| `stealth_mode` | bool | False | If the calculated amount of channel points is GT the highest bet, place the highest value minus 1-2 points [#33](https://github.com/Tkd-Alex/Twitch-Channel-Points-Miner-v2/issues/33) |
-| `filter_condition` | FilterCondition | None | Based on this filter the script will skip some bet [#29](https://github.com/Tkd-Alex/Twitch-Channel-Points-Miner-v2/issues/29) |
+| Key | Type | Default | Description |
+|-------------------- |----------------- |--------- |-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| `strategy` | Strategy | SMART | Choose your strategy! See above for more info |
+| `percentage` | int | 5 | Place the x% of your channel points |
+| `percentage_gap` | int | 20 | Gap difference between outcomesA and outcomesB (for SMART stragegy) |
+| `max_points` | int | 50000 | If the x percentage of your channel points is GT bet_max_points set this value |
+| `stealth_mode` | bool | False | If the calculated amount of channel points is GT the highest bet, place the highest value minus 1-2 points [#33](https://github.com/Tkd-Alex/Twitch-Channel-Points-Miner-v2/issues/33) |
+| `delay_mode` | DelayMode | FROM_END | Define how is calculating the waiting time before placing a bet |
+| `delay` | float | 6 | Value to be used to calculate bet delay depending on `delay_mode` value |
#### Bet strategy
- **MOST_VOTED**: Select the option most voted based on users count
- **HIGH_ODDS**: Select the option with the highest odds
- **PERCENTAGE**: Select the option with the highest percentage based on odds (It's the same that show Twitch) - Should be the same as select LOWEST_ODDS
-- **SMART**: If the majority in percent chose an option, then follow the other users, otherwise choose the option with the highest odds
+- **SMART**: If the majority in percent chose an option, then follow the other users, otherwise select the option with the highest odds
-
+
Here a concrete example:
- **MOST_VOTED**: 21 Users have select **'over 7.5'**, instead of 9 'under 7.5'
- **HIGH_ODDS**: The highest odd is 2.27 on **'over 7.5'** vs 1.79 on 'under 7.5'
- **PERCENTAGE**: The highest percentage is 56% for **'under 7.5'**
-- **SMART**: Calculate the percentage based on the users. The percentages are: 'over 7.5': 70% and 'under 7.5': 30%. If the difference between the two percentages are higher than `percentage_gap` select the highest percentage, else the highest odds.
+- **SMART**: Calculate the percentage based on the users. The percentages are: 'over 7.5': 70% and 'under 7.5': 30%. If the difference between the two percentages is higher than `percentage_gap` select the highest percentage, else the highest odds.
In this case if percentage_gap = 20 ; 70-30 = 40 > percentage_gap, so the bot will select 'over 7.5'
### FilterCondition
@@ -424,8 +451,39 @@ Allowed values for `where` are: `GT, LT, GTE, LTE`
- If you want to place the bet ONLY if the highest bet is lower than 2000
`FilterCondition(by=OutcomeKeys.TOP_POINTS, where=Condition.LT, value=2000)`
+### DelayMode
+
+- **FROM_START**: Will wait `delay` seconds from when the bet was opened
+- **FROM_END**: Will until there is `delay` seconds left to place the bet
+- **PERCENTAGE**: Will place the bet when `delay` percent of the set timer is elapsed
+
+Here's a concrete example. Let's suppose we have a bet that is opened with a timer of 10 minutes:
+
+- **FROM_START** with `delay=20`: The bet will be placed 20s after the bet is opened
+- **FROM_END** with `delay=20`: The bet will be placed 20s before the end of the bet (so 9mins 40s after the bet is opened)
+- **PERCENTAGE** with `delay=0.2`: The bet will be placed when the timer went down by 20% (so 2mins after the bet is opened)
+
+## Analytics
+We have recently introduced a little frontend where you can show with a chart you points trend. The script will spawn a Flask web-server on your machine where you can select binding address and port.
+The chart provides some annotation to handle the prediction and watch strike events. Usually annotation are used to notice big increase / decrease of points. If you want to can disable annotations.
+On each (x, y) points Its present a tooltip that show points, date time and reason of points gained / lost. This web page was just a funny idea, and it is not intended to use for a professional usage.
+If you want you can toggle the dark theme with the dedicated checkbox.
+
+| Light theme | Dark theme |
+| ----------- | ---------- |
+|  |  |
+
+For use this feature just call the `analytics` method before start mining. Read more at: [#96](https://github.com/Tkd-Alex/Twitch-Channel-Points-Miner-v2/issues/96)
+The chart will be autofreshed each `refresh` minutes. If you want to connect from one to second machine that have that webpanel you have to use `0.0.0.0` instead of `127.0.0.1`.
+```python
+from TwitchChannelPointsMiner import TwitchChannelPointsMiner
+twitch_miner = TwitchChannelPointsMiner("your-twitch-username")
+twitch_miner.analytics(host="127.0.0.1", port=5000, refresh=5) # Analytics web-server
+twitch_miner.mine(followers=True, blacklist=["user1", "user2"])
+```
+
## Migrating from an old repository (the original one):
-If you already have a `twitch-cookies.pkl` and you don't want to login again, please create a `cookies/` folder in the current directory and then copy the .pkl file with a new name `your-twitch-username.pkl`
+If you already have a `twitch-cookies.pkl` and you don't want to log in again, please create a `cookies/` folder in the current directory and then copy the .pkl file with a new name `your-twitch-username.pkl`
```
.
+-- run.py
@@ -444,5 +502,35 @@ Other useful info can be founded here:
You can also follow this [video tutorial](https://www.youtube.com/watch?v=0VkM7NOZkuA).
+## Termux
+Install the requirements
+```
+pkg install python git rust libjpeg-turbo libcrypt ndk-sysroot clang zlib`
+LDFLAGS="-L${PREFIX}/lib/" CFLAGS="-I${PREFIX}/include/" pip install --upgrade wheel pillow
+```
+
+Clone this repository
+`git clone https://github.com/Tkd-Alex/Twitch-Channel-Points-Miner-v2`
+
+(2 way):
+Download sources from GitHub and put it into your Termux storage
+
+Now you can enter the directory with our miner, type this command:
+`cd Twitch-Channel-Points-Miner-v2`
+
+Configure your miner on your preferences by typing
+`nano example.py`
+
+When you have configured it now we can rename it (optional):
+`mv example.py run.py`
+
+We have to also install dependences required to run miner:
+`pip install -r requirements.txt`
+
+Now when we did everything we can run miner:
+`python run.py`
+
+Read more at [#92](https://github.com/Tkd-Alex/Twitch-Channel-Points-Miner-v2/issues/92) [#76](https://github.com/Tkd-Alex/Twitch-Channel-Points-Miner-v2/issues/76)
+
## Disclaimer
This project comes with no guarantee or warranty. You are responsible for whatever happens from using this project. It is possible to get soft or hard banned by using this project if you are not careful. This is a personal project and is in no way affiliated with Twitch.
diff --git a/TwitchChannelPointsMiner/TwitchChannelPointsMiner.py b/TwitchChannelPointsMiner/TwitchChannelPointsMiner.py
index 0aa8ef9..fb32852 100644
--- a/TwitchChannelPointsMiner/TwitchChannelPointsMiner.py
+++ b/TwitchChannelPointsMiner/TwitchChannelPointsMiner.py
@@ -1,16 +1,18 @@
# -*- coding: utf-8 -*-
-import copy
import logging
+import os
import random
import signal
import sys
import threading
import time
import uuid
-from collections import OrderedDict
from datetime import datetime
+from pathlib import Path
+from TwitchChannelPointsMiner.classes.AnalyticsServer import AnalyticsServer
+from TwitchChannelPointsMiner.classes.Chat import ThreadChat
from TwitchChannelPointsMiner.classes.entities.PubsubTopic import PubsubTopic
from TwitchChannelPointsMiner.classes.entities.Streamer import (
Streamer,
@@ -24,6 +26,7 @@ from TwitchChannelPointsMiner.logger import LoggerSettings, configure_loggers
from TwitchChannelPointsMiner.utils import (
_millify,
at_least_one_value_in_settings_is,
+ check_versions,
get_user_agent,
internet_connection_available,
set_default_settings,
@@ -33,8 +36,14 @@ from TwitchChannelPointsMiner.utils import (
# - chardet.charsetprober - [feed]
# - chardet.charsetprober - [get_confidence]
# - requests - [Starting new HTTPS connection (1)]
+# - Flask (werkzeug) logs
+# - irc.client - [process_data]
+# - irc.client - [_dispatcher]
+# - irc.client - [_handle_message]
logging.getLogger("chardet.charsetprober").setLevel(logging.ERROR)
logging.getLogger("requests").setLevel(logging.ERROR)
+logging.getLogger("werkzeug").setLevel(logging.ERROR)
+logging.getLogger("irc.client").setLevel(logging.ERROR)
logger = logging.getLogger(__name__)
@@ -62,12 +71,16 @@ class TwitchChannelPointsMiner:
username: str,
password: str = None,
claim_drops_startup: bool = False,
+ # Settings for logging and selenium as you can see.
priority: list = [Priority.STREAK, Priority.DROPS, Priority.ORDER],
# This settings will be global shared trought Settings class
logger_settings: LoggerSettings = LoggerSettings(),
# Default values for all streamers
streamer_settings: StreamerSettings = StreamerSettings(),
):
+ Settings.analytics_path = os.path.join(Path().absolute(), "analytics", username)
+ Path(Settings.analytics_path).mkdir(parents=True, exist_ok=True)
+
self.username = username
# Set as global config
@@ -97,9 +110,25 @@ class TwitchChannelPointsMiner:
self.logs_file = configure_loggers(self.username, logger_settings)
+ # Check for the latest version of the script
+ current_version, github_version = check_versions()
+ if github_version == "0.0.0":
+ logger.error(
+ "Unable to detect if you have the latest version of this script"
+ )
+ elif current_version != github_version:
+ logger.info(f"You are running the version {current_version} of this script")
+ logger.info(f"The latest version on GitHub is: {github_version}")
+
for sign in [signal.SIGINT, signal.SIGSEGV, signal.SIGTERM]:
signal.signal(sign, self.end)
+ def analytics(self, host: str = "127.0.0.1", port: int = 5000, refresh: int = 5):
+ http_server = AnalyticsServer(host=host, port=port, refresh=refresh)
+ http_server.daemon = True
+ http_server.name = "Analytics Thread"
+ http_server.start()
+
def mine(self, streamers: list = [], blacklist: list = [], followers=False):
self.run(streamers=streamers, blacklist=blacklist, followers=followers)
@@ -139,53 +168,55 @@ class TwitchChannelPointsMiner:
)
for username in followers_array:
if username not in streamers_dict and username not in blacklist:
+ streamers_name.append(username)
streamers_dict[username] = username.lower().strip()
- else:
- followers_array = []
-
- streamers_name = list(
- OrderedDict.fromkeys(streamers_name + followers_array)
- )
logger.info(
f"Loading data for {len(streamers_name)} streamers. Please wait...",
extra={"emoji": ":nerd_face:"},
)
for username in streamers_name:
- time.sleep(random.uniform(0.3, 0.7))
- try:
- streamer = (
- streamers_dict[username]
- if isinstance(streamers_dict[username], Streamer) is True
- else Streamer(username)
- )
- streamer.channel_id = self.twitch.get_channel_id(username)
- streamer.settings = set_default_settings(
- streamer.settings, Settings.streamer_settings
- )
- streamer.settings.bet = set_default_settings(
- streamer.settings.bet, Settings.streamer_settings.bet
- )
- self.streamers.append(streamer)
- except StreamerDoesNotExistException:
- logger.info(
- f"Streamer {username} does not exist",
- extra={"emoji": ":cry:"},
- )
+ if username in streamers_name:
+ time.sleep(random.uniform(0.3, 0.7))
+ try:
+ streamer = (
+ streamers_dict[username]
+ if isinstance(streamers_dict[username], Streamer) is True
+ else Streamer(username)
+ )
+ streamer.channel_id = self.twitch.get_channel_id(username)
+ streamer.settings = set_default_settings(
+ streamer.settings, Settings.streamer_settings
+ )
+ streamer.settings.bet = set_default_settings(
+ streamer.settings.bet, Settings.streamer_settings.bet
+ )
+ if streamer.settings.join_chat is True:
+ streamer.irc_chat = ThreadChat(
+ self.username,
+ self.twitch.twitch_login.get_auth_token(),
+ streamer.username,
+ )
+ self.streamers.append(streamer)
+ except StreamerDoesNotExistException:
+ logger.info(
+ f"Streamer {username} does not exist",
+ extra={"emoji": ":cry:"},
+ )
# Populate the streamers with default values.
# 1. Load channel points and auto-claim bonus
# 2. Check if streamers are online
- # 3. Check if the user is a Streamer. In thi case you can't do prediction
+ # 3. DEACTIVATED: Check if the user is a moderator. (was used before the 5th of April 2021 to deactivate predictions)
for streamer in self.streamers:
time.sleep(random.uniform(0.3, 0.7))
self.twitch.load_channel_points_context(streamer)
self.twitch.check_streamer_online(streamer)
- self.twitch.viewer_is_mod(streamer)
- if streamer.viewer_is_mod is True:
- streamer.settings.make_predictions = False
+ # self.twitch.viewer_is_mod(streamer)
- self.original_streamers = copy.deepcopy(self.streamers)
+ self.original_streamers = [
+ streamer.channel_points for streamer in self.streamers
+ ]
# If we have at least one streamer with settings = make_predictions True
make_predictions = at_least_one_value_in_settings_is(
@@ -220,10 +251,11 @@ class TwitchChannelPointsMiner:
)
# Subscribe to community-points-user. Get update for points spent or gains
+ user_id = self.twitch.twitch_login.get_user_id()
self.ws_pool.submit(
PubsubTopic(
"community-points-user-v1",
- user_id=self.twitch.twitch_login.get_user_id(),
+ user_id=user_id,
)
)
@@ -232,7 +264,7 @@ class TwitchChannelPointsMiner:
self.ws_pool.submit(
PubsubTopic(
"predictions-user-v1",
- user_id=self.twitch.twitch_login.get_user_id(),
+ user_id=user_id,
)
)
@@ -249,6 +281,7 @@ class TwitchChannelPointsMiner:
PubsubTopic("predictions-channel-v1", streamer=streamer)
)
+ refresh_context = time.time()
while self.running:
time.sleep(random.uniform(20, 60))
# Do an external control for WebSocket. Check if the thread is running
@@ -264,11 +297,26 @@ class TwitchChannelPointsMiner:
)
WebSocketsPool.handle_reconnection(self.ws_pool.ws[index])
+ if ((time.time() - refresh_context) // 60) >= 30:
+ refresh_context = time.time()
+ for index in range(0, len(self.streamers)):
+ if self.streamers[index].is_online:
+ self.twitch.load_channel_points_context(
+ self.streamers[index]
+ )
+
def end(self, signum, frame):
logger.info("CTRL+C Detected! Please wait just a moment!")
+ for streamer in self.streamers:
+ if streamer.irc_chat is not None:
+ streamer.leave_chat()
+ if streamer.irc_chat.is_alive() is True:
+ streamer.irc_chat.join()
+
self.running = self.twitch.running = False
- self.ws_pool.end()
+ if self.ws_pool is not None:
+ self.ws_pool.end()
if self.minute_watcher_thread is not None:
self.minute_watcher_thread.join()
@@ -276,7 +324,13 @@ class TwitchChannelPointsMiner:
if self.sync_campaigns_thread is not None:
self.sync_campaigns_thread.join()
- time.sleep(1)
+ # Check if all the mutex are unlocked.
+ # Prevent breaks of .json file
+ for streamer in self.streamers:
+ if streamer.mutex.locked():
+ streamer.mutex.acquire()
+ streamer.mutex.release()
+
self.__print_report()
sys.exit(0)
@@ -322,7 +376,7 @@ class TwitchChannelPointsMiner:
if self.streamers[streamer_index].history != {}:
gained = (
self.streamers[streamer_index].channel_points
- - self.original_streamers[streamer_index].channel_points
+ - self.original_streamers[streamer_index]
)
logger.info(
f"{repr(self.streamers[streamer_index])}, Total Points Gained (after farming - before farming): {_millify(gained)}",
diff --git a/TwitchChannelPointsMiner/__init__.py b/TwitchChannelPointsMiner/__init__.py
index 4c150ca..cf775fa 100644
--- a/TwitchChannelPointsMiner/__init__.py
+++ b/TwitchChannelPointsMiner/__init__.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-__version__ = "2.7.1"
+__version__ = "2.0.5"
from .TwitchChannelPointsMiner import TwitchChannelPointsMiner
__all__ = [
diff --git a/TwitchChannelPointsMiner/classes/AnalyticsServer.py b/TwitchChannelPointsMiner/classes/AnalyticsServer.py
new file mode 100644
index 0000000..3daa843
--- /dev/null
+++ b/TwitchChannelPointsMiner/classes/AnalyticsServer.py
@@ -0,0 +1,92 @@
+import logging
+import os
+from pathlib import Path
+from threading import Thread
+
+from flask import Flask, Response, cli, render_template
+
+from TwitchChannelPointsMiner.classes.Settings import Settings
+from TwitchChannelPointsMiner.utils import download_file
+
+cli.show_server_banner = lambda *_: None
+logger = logging.getLogger(__name__)
+
+
+def streamers_available():
+ path = Settings.analytics_path
+ return [
+ f
+ for f in os.listdir(path)
+ if os.path.isfile(os.path.join(path, f)) and f.endswith(".json")
+ ]
+
+
+def read_json(streamer):
+ path = Settings.analytics_path
+ streamer = streamer if streamer.endswith(".json") else f"{streamer}.json"
+ return Response(
+ open(os.path.join(path, streamer)) if streamer in streamers_available() else [],
+ status=200,
+ mimetype="application/json",
+ )
+
+
+def index(refresh=5):
+ return render_template(
+ "charts.html",
+ refresh=(refresh * 60 * 1000),
+ streamers=",".join(streamers_available()),
+ )
+
+
+def download_assets(assets_folder, required_files):
+ Path(assets_folder).mkdir(parents=True, exist_ok=True)
+ logger.info(f"Downloading assets to {assets_folder}")
+
+ for f in required_files:
+ if os.path.isfile(os.path.join(assets_folder, f)) is False:
+ if (
+ download_file(os.path.join("assets", f), os.path.join(assets_folder, f))
+ is True
+ ):
+ logger.info(f"Downloaded {f}")
+
+
+def check_assets():
+ required_files = ["banner.png", "charts.html", "dark-theme.css"]
+ assets_folder = os.path.join(Path().absolute(), "assets")
+ if os.path.isdir(assets_folder) is False:
+ logger.info(f"Assets folder not found at {assets_folder}")
+ download_assets(assets_folder, required_files)
+ else:
+ for f in required_files:
+ if os.path.isfile(os.path.join(assets_folder, f)) is False:
+ logger.info(f"Missing file {f} in {assets_folder}")
+ download_assets(assets_folder, required_files)
+ break
+
+
+class AnalyticsServer(Thread):
+ def __init__(self, host: str = "127.0.0.1", port: int = 5000, refresh: int = 5):
+ super(AnalyticsServer, self).__init__()
+
+ check_assets()
+
+ self.host = host
+ self.port = port
+ self.refresh = refresh
+
+ self.app = Flask(
+ __name__,
+ template_folder=os.path.join(Path().absolute(), "assets"),
+ static_folder=os.path.join(Path().absolute(), "assets"),
+ )
+ self.app.add_url_rule("/", "index", index, defaults={"refresh": refresh})
+ self.app.add_url_rule("/json/
+
+
+ {% for streamer in streamers.split(',')|sort %}
+
+
+
+
+