Skip to content

WIP: Default run.py with env variables #673

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

Hattorius
Copy link

Description

Copied the example.py into run.py and made it read variables from the env. Also, created env.md explaining usage.

This isn't a change directly linked to an issue. I wanted to use this without having to copy / paste the example.py and work in the working directory of the container. Environmental variables work really nicely.

Now for anyone with Docker running, you just need to spin up a container with the miner image, and set some environment variables. It's a lot simpler.

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

I've built the image, and ran using environmental variables only.

Checklist:

  • My code follows the style guidelines of this project
  • 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
  • Any dependent changes have been updated in requirements.txt

@Hattorius
Copy link
Author

I won't make any changes to the README.md until this has an "OK to go". Either way, I'll just be using it like this from my fork..

@Hattorius Hattorius marked this pull request as draft April 12, 2025 11:46
@mpforce1
Copy link

mpforce1 commented Apr 14, 2025

I really like the idea of this, it would simplify a lot of Docker based setups.

I would like to suggest retaining support for custom run.py files as the default, to avoid breaking changes. You could rename what you've got here as run.py to something like docker_run.py, then, to enable the .env file feature, instruct the user to override the entry point to this new file in their docker configuration. An example docker compose might look like:

version: "3.9"

services:
  miner:
    image: rdavidoff/twitch-channel-points-miner-v2
    stdin_open: true
    tty: true
    environment:
      - TERM=xterm-256color
    volumes:
      - ./analytics:/usr/src/app/analytics
      - ./cookies:/usr/src/app/cookies
      - ./logs:/usr/src/app/logs
      - ./run.py:/usr/src/app/run.py:ro
    ports:
      - "5000:5000"
     entrypoint: python docker-run.py

I would also like to suggest supporting all configuration options. Looking through the env.md file you appear to be missing support for:

  • Several logger color_palette events, you only have support for ONLINE, OFFLINE, and BET_WIN. This setting support should all Events.
  • All Notification type environment variables should allow the user to specify the events variable.
  • Telegram is missing the disable_notification variable.
  • You support streamer settings in the actual run.py file but don't document them in the .env.md file.
  • Currently, there doesn't seem to be a way to override settings on a per Streamer basis. I suggest adding support for this by using prefixed (or suffixed) environment variables like {streamer name}_{setting key}={setting value}, for example:
STREAMERS=example_streamer,another_streamer,a_third_streamer

example_streamer_MAKE_PREDICTIONS=True
example_streamer_BET_DISABLED=False
example_streamer_BET_STRATEGY=SMART
example_streamer_BET_PERCENTAGE=5
example_streamer_BET_PERCENTAGE_GAP=20
example_streamer_BET_MAX_POINTS=50000
example_streamer_BET_MIN_POINTS=20000
example_streamer_BET_STEALTH_MODE=True
example_streamer_BET_DELAY=6
example_streamer_BET_DELAY_MODE=FROM_END
example_streamer_FILTER_BY=TOTAL_USERS
example_streamer_FILTER_WHERE=LTE
example_streamer_FILTER_VALUE=800

another_streamer_MAKE_PREDICTIONS=False
another_streamer_FOLLOW_RAID=False
another_streamer_CLAIM_DROPS=True

a_third_streamer_MAKE_PREDICTIONS=False
a_third_streamer_COMMUNITY_GOALS=True

I think that's it but feel free to check again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants