Skip to content

Commit

Permalink
Merge pull request #2 from mrgretwon/add_windows_compatibility
Browse files Browse the repository at this point in the history
Update chromedriver and add windows compatibility
  • Loading branch information
mrgretwon authored Oct 15, 2020
2 parents ce49a08 + a0ab2f9 commit 2da9ee2
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 26 deletions.
21 changes: 14 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@ The bot stops working when you have no more money, or after 5 bought players (be

The current status is described in the console logs, so you have real-time access to information about the activities performed.

## Install requirements
## Installation

```
pip install -r requirements.txt
```
Make sure you also have `mpg123` package installed.

## Configuration

Expand Down Expand Up @@ -61,22 +60,30 @@ PLAYER = {
}
```

You can turn on voice notification when you find a player.
## Running

**Linux/Mac systems**

Run:

```
ALLOW_NOTIFICATIONS = True
make run
```

## Running
**Windows**

Set the PYTHONPATH variable with the value of the code directory - [check this link](https://stackoverflow.com/questions/3701646/how-to-add-to-the-pythonpath-in-windows-so-it-finds-my-modules-packages).

Run:

```
make run
python src\main.py
```


## Info

Currently it works only Linux and Mac systems.
Currently it works on Linux, Mac and Windows systems with Chrome version >=86.

It's just first version of fut web app bot. The project will be further developed and new features will appear.

Expand Down
Binary file modified chrome_linux/chromedriver
Binary file not shown.
Binary file modified chrome_mac/chromedriver
Binary file not shown.
Binary file added chrome_windows/chromedriver.exe
Binary file not shown.
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
selenium==3.141.0
gTTS==2.1.1
16 changes: 2 additions & 14 deletions src/bot.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import os
from time import sleep

from gtts import gTTS
from selenium.common.exceptions import TimeoutException, WebDriverException
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.action_chains import ActionChains

from src.config import create_driver, ALLOW_NOTIFICATIONS, INCREASE_COUNT
from src.config import URL
from src.config import create_driver, INCREASE_COUNT
from src.email_manager import get_access_code
from src.helpers import wait_for_shield_invisibility

Expand All @@ -21,14 +19,6 @@ def __init__(self):
self.driver.get(URL)
print("Starting sniping bot...")

@staticmethod
def read(text, language='en'):
if ALLOW_NOTIFICATIONS:
message = gTTS(text=text, lang=language, slow=False)
message.save("message.mp3")
os.system("mpg123 message.mp3")
os.system("rm message.mp3")

def login(self, user):
WebDriverWait(self.driver, 15).until(
EC.visibility_of_element_located((By.XPATH, '//*[@class="ut-login-content"]//button'))
Expand Down Expand Up @@ -107,7 +97,6 @@ def search_player(self, player, max_price):
print("Success! You bought " + player + " for " + str(price) + " coins.")
coins = new_coins
success_count += 1
self.read("Success")

try:
self.driver.find_element(By.XPATH, '//button[contains(@class, "ut-navigation-button-control")]').click()
Expand Down Expand Up @@ -162,4 +151,3 @@ def buy_player(self, player, max_price):

except TimeoutException:
print("Error, check the browser")
self.read("Error, check the browser")
9 changes: 5 additions & 4 deletions src/config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from selenium import webdriver
import platform
import os


def create_driver():
Expand All @@ -9,6 +10,8 @@ def create_driver():
path = 'chrome_mac/chromedriver'
elif system == 'Linux':
path = 'chrome_linux/chromedriver'
elif system == 'Windows':
path = os.getcwd() + '\chrome_windows\chromedriver.exe'
else:
raise OSError(f'Operating system {system} is not supported')

Expand All @@ -28,8 +31,8 @@ def create_driver():
}

PLAYER = {
"name": "ndombele",
"cost": 5500,
"name": "Kloster",
"cost": 20000,
}

EMAIL_CREDENTIALS = {
Expand All @@ -39,6 +42,4 @@ def create_driver():

EA_EMAIL = "[email protected]"

ALLOW_NOTIFICATIONS = False

INCREASE_COUNT = 20

0 comments on commit 2da9ee2

Please sign in to comment.