The project contains a selenium bot which was created to automate the Energy Air or Energy Star Night competition.
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Michael Reber 4eba664d20 Initial commit 5 years ago
install_on_system Initial commit 5 years ago
Download-WebDriver-for-Chrome.url Initial commit 5 years ago
README.md Initial commit 5 years ago
chromedriver.exe Initial commit 5 years ago
energy-bot.py Initial commit 5 years ago
gmail_nrg_code.py Initial commit 5 years ago
requirements.txt Initial commit 5 years ago

README.md

selenium-energy-bot_v2018

The project contains a selenium bot which was created to automate the Energy Air or Energy Star Night competition. It is only intended as a POC and not to be used to win real tickets. (If you want to win tickets with it, you do it at your own risk.)

It is written in Python3 and requires an Android app to redirect the SMS. After successful implementation of the Smartphone app and the Python Bot, the SMS code is automatically read after the end of the session and the game starts from the beginning.

Configuration

Download Python 3.7.4
After downloading the file, run it. During the installation it is important to note that the check mark under "Add Python 3.7 to PATH" is set.
Now open CMD and navigate to the folder "selenium-energy-bot":

cd \path\to\your\folder\selenium-energy-bot

There virtualenv must be installed:

pip3 install virtualenv
virtualenv venv

or:

python -m .\venv

Afterwards:

venv\Scripts\activate.bat
pip install -r requirements.txt

Gmail Account needed

  • Click on Enable The GMAIL API and "Download Client Config".
  • In the Gmail Inbox mail.google.com create a new "label".
  • Under Settings (top right), go to "Filters & blocked addresses "Create new filter".
  • As subject: Forward SMS message from number [+41YOURNR] (sender - Energy (No contact specified))
  • Contains the words: Dein Code für game.energy.ch
  • Create a filter and apply it to the newly created label.

Download APP PlayStore

  • Download App SMS to mail/phone - auto redirect
  • Configure the app to forward the SMS to your previously configured Gmail.
  • Attention: The app must remain open in the background, so do not delete the app from the "open apps". Possibly adjust the energy plan on your mobile phone.

App Iphone (optional)

  • If you don't have an Android, you can also use a corresponding app from the Appstore, which redirects SMS to Mail. The regex to find the code in the string has to be adjusted in the gmail_nrg_code.py script.
    Possible App: mysms mirror: Forward SMS

Other Downloads (REQUIRED)

  • Download the Chrome Webdriver in the appropriate version for your browser.
    Find out the Webdriver version:
  1. open Chrome Browser
  2. click on the three points in the upper right corner
  3. help, then "about Google Chrome"
  4. at the top you will see "Version 78.0.3904.97"
  • Alternatively you can also use webdriver of Edge or IE. But I personally had the best experiences with Chrome (adjust the webdriver in the script nggame_2019.py if you want to change it).

Usage

Unique execution

  • Place credentials.json (GMAIL Api Auth) and chromedriver.exe in the project folder.
  • In gmail_nrg_code.py there is a place (marked with Uncomment). Comment this block (Attention: After the "#" there is still a space, delete it).
  • Comment the function (main()) at the last place in the code and execute the script.
python gmail_nrg_code.py
  • Copy the id of the label and paste it at the following code position:
  • results = service.users().messages().list(userId='me', labelIds=['UNREAD', 'Label_YOURIDHERE'],
  • Comment code out again. Also the function at the end!

Execute

python energy-bot.py