Skip to content

RakambdaOrg/ChannelPointsMiner

Repository files navigation

Channel Points Miner

badge channel points miner

WARN: If you’re reading this on GitHub, this may correspond to the documentation of the develop branch. If you want documentation of the latest released version please go to pages.

The main objective of this miner is to acquire Twitch channel points automatically. Other forms of point, like those provided by bots through IRC (Streamlabs, etc.), isn’t in the scope of the miner.

  • Watch streams for you, earning the baseline points as you watch.

  • Get the watch streak points by watching streams regularly.

  • Claim bonus points when they are available.

  • Follow raids.

  • Participate and claim campaigns.

  • Join IRC chat.

  • Participate in predictions and record peoples predictions.

  • Claim moments.

Limits:

  • Twitch makes it so that only 2 streamers can be watched at once. However, actions that are not watching are not limited. This includes raids and predictions.

This project heavily inspired by Tkd-Alex/Twitch-Channel-Points-Miner-v2, just doing it my own way.

How to use

Clone

Java 17+ is required.

  1. Clone this repository git clone [email protected]:RakSrinaNa/ChannelPointsMiner.git.

  2. Get into the cloned directory cd ChannelPointsMiner.

  3. Build the jar ./gradlew build -x test

  4. Run

    • Default: java -jar miner/build/libs/miner-shaded.jar --settings config.json

    • With your own logger: java -Dlog4j.configurationFile=log4j2.xml -jar miner/build/libs/miner-shaded.jar --settings config.json

Docker

Image mrcraftcod/channel-points-miner can be used.

Here’s an example dockerfile:

version: "3.9"

services:
  miner:
    image: mrcraftcod/channel-points-miner:latest
    command: "--settings /usr/src/app/config.json"
    volumes:
      - ./authentication:/usr/src/app/authentication
      - ./streamers:/usr/src/app/streamers
      - ./config.json:/usr/src/app/config.json:ro

With a custom logger:

version: "3.9"

services:
  miner:
    image: mrcraftcod/channel-points-miner:latest
    command: "--settings /usr/src/app/config.json"
    environment:
      JDK_JAVA_OPTIONS: "-Dlog4j.configurationFile=/usr/src/app/log4j2.xml"
    volumes:
      - ./authentication:/usr/src/app/authentication
      - ./streamers:/usr/src/app/streamers
      - ./config.json:/usr/src/app/config.json:ro
      - ./log4j2.xml:/usr/src/app/log4j2.xml:ro
Note
If you have 2FA enabled you’ll have to enter your token the first time in order to login. As Docker doesn’t give an interactive shell by default you’ll have to run the container in interactive mode yourself the first time. More can be read about it in #87.

How to mine streamers

You have two options to load streamers in the mining list:

  • Be specific and define streamer settings for each streamer you want to watch. For this simply add a JSON file withing one of the streamer config directory with the name of the streamer (eg: mystreamer.json). The content of the file will override the default streamer settings for the keys that are redefined. If you want to use the default streamer settings simply use an empty file or put an empty JSON object in the file (ie: {}).

  • Load them from the follows list. Every follow will be loaded and default settings will be applied to them.

Note
If a stream is both defined in a JSON file and is followed, then the first case will apply.

Settings

2 kind of settings are present:

  • The global settings that defines the global behavior of the miner as well as the default streamer settings.

  • The streamer settings that’ll be applied for each streamer and override the default ones.

Global settings

The settings consist of on object with a list of account settings under the accounts field. Something like:

{
  "accounts": [{
    "accountSetting1": "value",
    "accountSetting2": "value"
  }]
}

Examples can be found in src/examples/config.

Account settings

Account settings define all the settings for a Twitch account that will be used to mine points.

Name Description Default value

username

Your Twitch account username.

password

Your Twitch account password.

use2FA

If you use 2-factor authentication enable this to ask the 2FA code directly when login in.

false

authenticationFolder

Path to the folder containing the authentication file

./authentication

loadFollows

If set to true streamers followed on the account will be mined.

false

enabled

If set to true the account will be mined. Otherwise, it won’t be mined but still allows you to have its configuration defined for later.

true

defaultStreamerSettings

Default streamer settings to apply to every streamer.

Default streamer settings

streamerConfigDirectories

A list of streamer directories containing streamer settings.

<empty>

discord

reloadEvery

Reload streamer settings every reloadEvery minutes. New streamer configurations will be added, already existing ones will be updated, and removed one will be removed.

A zero or negative value will disable this feature. We recommend setting this value to something not too low as this is a rather intensive treatment (15 minutes minimum seems fair).

Note
Only streamer settings are reloaded, not the global settings.

0

analytics

chatMode

Define what method is used to connect to Twitch chat.

  • WS: Using WebSocket method (used on Twitch website).

  • IRC: Using IRC protocol.

WS

Streamer directories

Name Description Default value

path

Path to a folder containing streamer settings.

recursive

If set to true, the folder will be scanned recursively.

false

Discord settings

Discord settings define settings to be used with Discord webhooks. Leave it empty if you don’t want the feature.

Name Description Default value

webhookUrl

Discord webhook url to publish events to.

embeds

If true embeds will be sent in the chat.

false

Analytics settings

Analytics settings define a way to collect data on your twitch account as time passes. This includes:

  • Balance evolution

  • Your own Predictions made & results

  • Predictions from other chat participants and their return-on-investment (only approximate as the bet amount is mostly anonymous).

These are stored in an external database which allows any external software to access it and process it the wanted way.

Several database types are supported and listed below. Each database (logical database for MariaDB, different file for H2/SQLite) will however represent one mined account. You’ll therefore have to adjust the settings for each mined account to not point to the same one.

Name Description Default value

enabled

If set to true, data will be collected.

false

database

Analytics database settings.

recordChatsPredictions

If set to true, other peoples predictions will be recorded. This is done from two sources, from the top-predictors list and from chat messages (via their badge). Reading from chat, requires the joinIrc setting to be set to true.

false

Analytics database

Name Description Default value

jdbcUrl

JDBC url for the database connection

  • MariaDB: jdbc:mariadb://host:port/database (great if you have a DB available or running inside docker as you can set a mariadb container)

  • SQLite: jdbc:sqlite:/path/to/file (great running locally and want to store it to a file, however less resilient and more prone to corruption).

username

Account username to access database.

Note
Can be omitted if no account

password

Account password to access database.

Note
Can be omitted if no password

maxPoolSize

Maximum number of connections to the database.

Note
For SQLite connection, value 1 will be forced.

10

Streamer settings

Streamer settings define settings that will override the default streamer settings for a particular streamer.

Each streamer setting will be defined in a json file named with the username of the streamer (eg: myusername.json) and placed in the streamerConfigDirectory directory.

An example can be found here.

Name Description Default value

enabled

If set to false, this streamer won’t be mined nor will join chat.

true

makePredictions

If set to true, predictions will be made for this streamer.

false

followRaid

If set to true, the miner raid will attend raids for extra points.

false

participateCampaigns

If set to true, progression towards campaigns will be made, and completed rewards will be claimed.

false

claimMoments

If set to true, moments will be claimed when available.

false

joinIrc

If set to true IRC channel of the streamer will be joined.

false

predictions

Settings related to predictions (see prediction settings.

Default predictions settings.

priorities

A list of conditions that if met will prioritize this streamer (see priorities).

empty

index

The streamer index. This value is used when streamers have the same score from the priorities, the one with the lowest index will be picked first.

max value (last to be picked)

Prediction settings

Name

Description

Default value

minimumPointsRequired

Minimum amount of points to have to place a bet. If this threshold is not reached, no bet is placed.

0

delayCalculator

How to calculate when to place the bet (see prediction delay).

fromEnd(10)

outcomePicker

How to choose what outcome (side / color) to place the bet on (see outcome pickers).

smart(0.2)

amountCalculator

How to calculate the amount to the bet (see amount calculators).

percentage(percentage: 20, max: 50000)

actions

A list of prediction actions to perform before a bet is placed

<empty>

Priorities

Priorities is a way to prioritize streamers among each others to mine one over another based on some conditions.

You can then modify the position of a streamer by adding priorities to the streamers you want and if the condition is met then a score will be added to its overall score (sum of all the priority’s scores). The 2 streamers that have the highest overall score will be those mined. If there’s an exe-quo they’ll be picked by their index, and if equal too it’ll be random.

Each priority is different and can have a set of different parameters. The table below will list their type to be used in the JSON configuration as well as the conditions of activation and parameters.

Type Description Condition Parameters

constant

Adds a constant value to the score of the streamer. For example if you want a streamer to always be first, you can set this priority with a score of 99999, and it’ll always have at least this amount.

Always

  • score: Score to give.

subscribed

Return a score if the logged-in user is subscribed to the streamer. Values can be defined per sub tier.

User is subscribed.

  • score: Score for a T1 sub.

  • score2: Score for a T2 sub.

  • score3: Score for a T3 sub.

pointsAbove

Return a score if owned points are above a defined value.

Channel points are above threshold.

  • score: Score to give.

  • threshold: Current points must strictly be above this value to give the score.

pointsBelow

Return a score if owned points are below a defined value.

Channel points are below threshold.

  • score: Score to give.

  • threshold: Current points must strictly be below this value to give the score.

watchStreak

Return a score if the streamer has a potential watch streak to claim.

A watch streak may be claimed.

  • score: Score to give.

drops

Return a score if a drop campaign may be progressed by watching this stream.

Drops can be progressed.

  • score : Score to give.

Note
If you’re banned from the chat of a channel, it’ll be skipped as you can’t gather points there.

Prediction delays

Prediction delays allow you to define when a bet should be placed.

Note
All delays will be within an imposed time window: [created date + 5s ; created date + prediction window - 5s].
Warning
Delay are calculated from when the prediction is created, if a moderator closes the bet early (which happens on some channels where a long timer is set) and the bet hasn’t already been placed, then it’ll be too late.

The table below will list their type to be used in the JSON configuration as well as how the delay is computed and parameters.

Type Description Computation Parameters

fromEnd

Place the bet a certain amount of time before the end of the original prediction.

Prediction end date - seconds seconds.

  • seconds: Number of seconds before the end to place the bet.

fromStart

Place the bet a certain amount of time after the beginning of the original prediction.

Prediction start date + seconds seconds.

  • seconds: Number of seconds after the start to place the bet.

percentage

Place the bet after percent% of the original timer elapsed.

Prediction stat date + precent * time window.

  • percent: The percentage of the timer, as a decimal value, between 0 and 1.

Outcome pickers

Outcome pickers allow you to define what outcome (side / color) will be chosen to place the bet on.

The table below will list their type to be used in the JSON configuration as well as how the side is computed and parameters.

Type Description Computation Parameters

mostUsers

Choose the outcome with the most users.

Outcome with the higher user count is picked.

leastUsers

Choose the outcome with the least users.

Outcome with the lower user count is picked.

mostPoints

Choose the outcome with the most points.

Outcome with the higher total points is picked.

This is the same as "the outcome with lower odds".

leastPoints

Choose the outcome with the least points.

Outcome with the lower total points is picked.

This is the same as "the outcome with higher odds".

biggestPredictor

Choose the outcome with the biggest predictor.

Outcome with the person that placed the biggest prediction overall.

mostTrusted

Choose the outcome that’s backed by other users with the highest average return-on-investment. Requires at least some data gathered beforehand via the 'recordChatsPredictions' setting! E.g. only users with at least 5 made predictions are taken into account by default.

Take the return-on-investment from people who already placed a prediction, calculate the average per outcome, then pick the highest.

  • minTotalBetsPlacedByUser: only user with at least this number of bets are considered in the calculation. Default is 5.

  • minTotalBetsPlacedOnPrediction: if not enough bets were placed, skip this prediction. Default is 10.

  • minTotalBetsPlacedOnOutcome: if not enough bets were placed on the chosen outcome, skip this prediction. Default is 5.

smart

Choose the outcome with the most users. However, if the two most picked outcomes have a user count similar, choose the outcome with the least points (higher odds).

If the difference of the user percentages between the 2 most picked outcomes is less than percentageGap% then choose the outcome with lower points, otherwise the one with most users.

  • percentageGap: The percent gap of the user count, as decimal, between 0 and 1.

(i.e. Setting this to 0.1, will mean that the condition switches states when the difference between sides is 10%, so 45% of the users on one side and 55% on the other)

Amount calculators

Amount calculators allow you to define how the amount to place is calculated.

Warning
The minimum amount that can be placed is 10.

The table below will list their type to be used in the JSON configuration as well as how the amount is computed and parameters.

Type Description Computation Parameters

constant

Always bet the same amount.

Place amount points.

  • amount: Amount to place.

percentage

Place a percentage of your points (with a limit).

Place percentage% of your current points. If this values goes over max then max points will be placed instead.

  • percentage: Percentage of your owned points to place, as a decimal value, between 0 and 1.

  • max: Maximum number of points.

Prediction actions

Prediction actions are a way to perform actions / verifications before a bet is placed.

The table below will list their type to be used in the JSON configuration as well as what is performed.

Type Description Computation Parameters

stealth

Ensure that the amount placed is lower than the top predictor.

If no top predictor is found, cancel the bet. Otherwise, if the amount placed by the top predictor is lower or equal to our prediction then set ours to his amount - 1.

Logs

You can define yourself how the logs looks like by supplying your own Log4j2 configuration file (see how to use to see how to load this config file).

Some examples are provided in the src/examples/loggers folder.

When you configure your patterns you’ll of course have access to all the default fields possible like the date, message, etc. In addition to that the context will be populated with some keys depending on the available data (in the caase of the Pattern layout, see %X). These keys are listed below:

Key Description

account_name

The account used to do the mining.

streamer_name

The name of the streamer for which the message is linked to.

websocket_id

The id of the websocket that is at the origin of the message sent/received on the websocket.

websocket_topic

Topic name of the message received on the websocket.

event_id

Event id of a prediction.

Viewer

Another module is available to display analytics data, see viewer module.

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.