From b3609df1a8a9fcfcb2b3a5b2f0c1752f8393708a Mon Sep 17 00:00:00 2001 From: theDebonair Date: Wed, 8 Jun 2022 16:48:34 +0530 Subject: [PATCH 01/80] Fixed the detection of "Mine" button --- .gitignore | 2 ++ awbot.py | 1 + 2 files changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index a38c0e3..d5a7741 100644 --- a/.gitignore +++ b/.gitignore @@ -133,3 +133,5 @@ dmypy.json # Pyre type checker .pyre/ +Pipfile +Pipfile.lock diff --git a/awbot.py b/awbot.py index 5f11310..c3ee330 100644 --- a/awbot.py +++ b/awbot.py @@ -152,6 +152,7 @@ def main(): # if button is not found except NoSuchElementException: + browser.refresh(); time.sleep(5) # if button is found From 98a20d1c0f4a04012725a62f2e9adab8a747d021 Mon Sep 17 00:00:00 2001 From: Harshit Gupta <51323434+theDebonair@users.noreply.github.com> Date: Wed, 8 Jun 2022 16:52:45 +0530 Subject: [PATCH 02/80] Update README.md --- README.md | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/README.md b/README.md index 91e3198..e91846f 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Alien Worlds automation using Python ### Installation Instructions - Clone this repository ``` -git clone https://github.com/dobizz/awbot.git +git clone https://github.com/theDebonair/awbot.git cd awbot ``` - Install all the required Python packages @@ -27,12 +27,3 @@ python awbot.py On the first run you need to login to your wax account, on the succeeding runs you will be logged in automatically as the session cookies will be saved. Follow the prompts in the command terminal. - -### Donations -Donations are much welcome to buy needed coffee. - -BTC `1zdraxHPQfZ8wvpMXt2VYhnGwmkLCf7UL` - -ETH `0x4e1736Db4d3912e6Ddd4E5a7A710D85ed369B987` - -XRP `rU2mEJSLqBRkYLVTv55rFTgQajkLTnT6mA` Destination Tag `107601` From 5f4129fc0a39af628e35b9905899b5601b6b3683 Mon Sep 17 00:00:00 2001 From: theDebonair Date: Wed, 8 Jun 2022 17:22:28 +0530 Subject: [PATCH 03/80] Updated XPath --- awbot.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/awbot.py b/awbot.py index c3ee330..7bed8cd 100644 --- a/awbot.py +++ b/awbot.py @@ -143,7 +143,7 @@ def main(): _print_(".") # try to find mine button try: - mine_btn = driver.find_element(By.XPATH, '//*[text()="Mine"]') + mine_btn = driver.find_element(By.XPATH, '//*[@id="root"]/div[3]/div[1]/div/div[3]/div[4]/div/div[2]/div/div/div/div/span') except KeyboardInterrupt: print('Stopping bot.') @@ -152,7 +152,6 @@ def main(): # if button is not found except NoSuchElementException: - browser.refresh(); time.sleep(5) # if button is found From d0f44d95519b518efc1ef5d6cebf7649da1409ca Mon Sep 17 00:00:00 2001 From: theDebonair Date: Thu, 9 Jun 2022 16:54:15 +0530 Subject: [PATCH 04/80] Improved button detection --- awbot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/awbot.py b/awbot.py index 7bed8cd..a8ef9ad 100644 --- a/awbot.py +++ b/awbot.py @@ -143,7 +143,7 @@ def main(): _print_(".") # try to find mine button try: - mine_btn = driver.find_element(By.XPATH, '//*[@id="root"]/div[3]/div[1]/div/div[3]/div[4]/div/div[2]/div/div/div/div/span') + mine_btn = driver.find_element(By.XPATH, "//*[contains(text(), 'Mine')]") except KeyboardInterrupt: print('Stopping bot.') @@ -163,7 +163,7 @@ def main(): break # wait for claim button - claim_btn = WebDriverWait(driver, 60).until(ec.visibility_of_element_located((By.XPATH, '//*[text()="Claim Mine"]'))) + claim_btn = WebDriverWait(driver, 60).until(ec.visibility_of_element_located((By.XPATH, "//*[contains(text(), 'Claim Mine')]"))) print("Found Claim button!") # click claim button From 88f29f340baf0392b73f028541d35172f63d1b90 Mon Sep 17 00:00:00 2001 From: theDebonair Date: Fri, 10 Jun 2022 13:53:15 +0530 Subject: [PATCH 05/80] Miscellaneous changes --- awbot.py | 107 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 67 insertions(+), 40 deletions(-) diff --git a/awbot.py b/awbot.py index a8ef9ad..660f27f 100644 --- a/awbot.py +++ b/awbot.py @@ -1,11 +1,10 @@ #!/usr/bin/env python3 -import os import sys -import json import time import random import pathlib -import platform +import requests +import winsound from itertools import count from selenium import webdriver from selenium.webdriver.chrome.options import Options @@ -14,22 +13,30 @@ from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as ec from selenium.common.exceptions import NoSuchElementException -from webdriver_manager.chrome import ChromeDriverManager from selenium_stealth import stealth +from webdriver_manager.chrome import ChromeDriverManager from awapi import Account -def _print_(text:str) -> None: +def _print_(text: str) -> None: sys.stdout.write(text) sys.stdout.flush() def main(): + # check internet connection + try: + requests.get('https://www.google.com', timeout=5) + print("\nInternet available.") + except (requests.ConnectionError, requests.Timeout): + print("\nNo internet.") + return + # define game url url = "https://play.alienworlds.io" # create AW Account instance - aw = Account(input("Please enter account name (e.g abcde.wam): ")) + aw = Account(input("\nPlease enter account name (e.g abcde.wam): ")) # define range for loop delay delay_min = 60 # min delay before next loop @@ -46,9 +53,10 @@ def main(): chrome_options.add_argument("--ignore-certificate-errors-spki-list") chrome_options.add_argument("--ignore-ssl-errors") # when there is already a persistent session, you may activate headless mode - # chrome_options.add_argument('--headless') + chrome_options.add_argument('--headless') - chrome_options.add_experimental_option("excludeSwitches", ["enable-automation"]) + chrome_options.add_experimental_option( + "excludeSwitches", ["enable-automation"]) chrome_options.add_experimental_option("useAutomationExtension", False) # save current browsing session to make it persistent @@ -62,21 +70,21 @@ def main(): options=chrome_options, ) except TypeError: - print("Please update your selenium package") + print("\nPlease update your selenium package.") return # change page load timeout driver.set_page_load_timeout(60) - # instatiate stealth + # instatiate stealth stealth( - driver, - languages=["en-US", "en"], - vendor="Google Inc.", - platform="Win32", - webgl_vendor="Intel Inc.", - renderer="Intel Iris OpenGL Engine", - fix_hairline=True, + driver, + languages=["en-US", "en"], + vendor="Google Inc.", + platform="Win32", + webgl_vendor="Intel Inc.", + renderer="Intel Iris OpenGL Engine", + fix_hairline=True, ) # save current window handle @@ -85,9 +93,20 @@ def main(): # make GET request driver.get(url) - input("\nPlease login and press when ready to Mine") + print("\nBot will start after 30 seconds, press \"Ctrl + C\" to pause the execution.") + + while True: + try: + # bot waits for 30 seconds + time.sleep(30) + break + + except KeyboardInterrupt: + print("\nPausing bot.") + input("\nPress any key to continue.") + break - print("\nStarting bot.\n") + print("\nStarting bot, press \"Ctrl + C\" to stop the execution.\n") # initialize crash count crashes = 0 @@ -117,24 +136,28 @@ def main(): width = 80 print("=" * width) - print("CPU: [ {:,} / {:,} ms ]\t\t\tUsed: {} %".format(cpu_used, cpu_max, cpu_pct)) - print("NET: [ {:,} / {:,} B ]\t\t\tUsed: {} %".format(net_used, net_max, net_pct)) - print("RAM: [ {:,} / {:,} B ]\t\t\tUsed: {} %".format(ram_used, ram_max, ram_pct)) + print( + "CPU: [ {:,} / {:,} ms ]\t\t\tUsed: {} %".format(cpu_used, cpu_max, cpu_pct)) + print( + "NET: [ {:,} / {:,} B ]\t\t\tUsed: {} %".format(net_used, net_max, net_pct)) + print( + "RAM: [ {:,} / {:,} B ]\t\t\tUsed: {} %".format(ram_used, ram_max, ram_pct)) print("=" * width) # get balances wax = aw.wax_balance tlm = aw.tlm_balance - + # show balances print("WAX Balance:", wax) print("TLM Balance:", tlm) if (cpu_pct > resource_limit) or (ram_pct > resource_limit) or (net_pct > resource_limit): - print("\nResource utilization is above the set threshold of {} %".format(resource_limit)) + print("\nResource utilization is above the set threshold of {} %".format( + resource_limit)) print("\nSleeping for {} seconds\n".format(resource_sleep)) time.sleep(resource_sleep) - continue + continue # wait for mine button to be found print("\nWaiting for Mine button") @@ -143,10 +166,12 @@ def main(): _print_(".") # try to find mine button try: - mine_btn = driver.find_element(By.XPATH, "//*[contains(text(), 'Mine')]") + mine_btn = driver.find_element( + By.XPATH, "//span[contains(text(), 'Mine')]") except KeyboardInterrupt: - print('Stopping bot.') + winsound.MessageBeep() + print('\nStopping bot.') driver.quit() sys.exit() @@ -156,15 +181,15 @@ def main(): # if button is found else: - _print_(":") print("\nFound Mine button!") # click mine_btn.click() break # wait for claim button - claim_btn = WebDriverWait(driver, 60).until(ec.visibility_of_element_located((By.XPATH, "//*[contains(text(), 'Claim Mine')]"))) - print("Found Claim button!") + claim_btn = WebDriverWait(driver, 60).until(ec.visibility_of_element_located( + (By.XPATH, "//span[contains(text(), 'Claim Mine')]"))) + print("\nFound Claim button!") # click claim button claim_btn.click() @@ -180,24 +205,25 @@ def main(): break # wait for approve button to be visible and click button - btn = WebDriverWait(driver, 60).until(ec.visibility_of_element_located((By.XPATH, "//*[contains(text(), 'Approve')]"))) + btn = WebDriverWait(driver, 60).until(ec.visibility_of_element_located( + (By.XPATH, "//*[contains(text(), 'Approve')]"))) # if approve button is found if btn: - print('\tFound Approve button.') + print('\n\tFound Approve button.') btn.click() - print('\tApproving transaction.') + print('\n\tApproving transaction.') # if approve button could not be found else: - raise IOError('\tUnable to load or find approve button.') + raise IOError('\n\tUnable to load or find approve button.') # go control back to main window - print('\tSwitching back to main window.\n') + print('\n\tSwitching back to main window.\n') driver.switch_to.window(main_window) # show the number of loops done - print(f"Total runs: {loop_count}") + print(f"\nTotal runs: {loop_count}") # delay the bot before starting next loop delay = random.randint(delay_min, delay_max) @@ -206,23 +232,24 @@ def main(): print("\nDone sleeping.\n") except KeyboardInterrupt: - print('Stopping bot.') + winsound.MessageBeep() + print('\nStopping bot.') break # if error occured except: crashes += 1 - print(f"Bot encountered an error. {crashes} Total crashes since start.") + print( + f"\nBot encountered an error. {crashes} Total crashes since start.") # make GET request driver.get(url) # close the webdriver driver.quit() - + if __name__ == '__main__': assert sys.version_info >= (3, 6), 'Python 3.6+ required.' # call main routine main() - From 96e4259910dcd8dc22862c4ef4f9e730d87e78c2 Mon Sep 17 00:00:00 2001 From: theDebonair Date: Fri, 10 Jun 2022 18:56:48 +0530 Subject: [PATCH 06/80] Various optimizations --- .gitignore | 5 +++++ README.md | 1 + awbot.py | 54 ++++++++++++++++++++++++++++++++++++------------------ 3 files changed, 42 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index d5a7741..f7e35d8 100644 --- a/.gitignore +++ b/.gitignore @@ -133,5 +133,10 @@ dmypy.json # Pyre type checker .pyre/ + +# pip file Pipfile Pipfile.lock + +# Wallet address +account.txt diff --git a/README.md b/README.md index e91846f..aea3701 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ cd awbot ``` pip install -r requirements.txt ``` +- It is recommended to use VirtualEnv for different instances of the bot. ### Running Instructions After all the dependencies have been downloaded and installed, simply run awbot.py diff --git a/awbot.py b/awbot.py index 660f27f..7fc2cb9 100644 --- a/awbot.py +++ b/awbot.py @@ -1,10 +1,9 @@ #!/usr/bin/env python3 import sys +import os import time import random import pathlib -import requests -import winsound from itertools import count from selenium import webdriver from selenium.webdriver.chrome.options import Options @@ -24,19 +23,38 @@ def _print_(text: str) -> None: def main(): - # check internet connection - try: - requests.get('https://www.google.com', timeout=5) - print("\nInternet available.") - except (requests.ConnectionError, requests.Timeout): - print("\nNo internet.") - return - # define game url url = "https://play.alienworlds.io" + # check for account.txt file + if os.path.exists("account.txt"): + + # check for file size + if os.stat("account.txt").st_size != 0: + file = open("account.txt", "r") + wallet = file.read() + file.close() + + # delete the file if found empty account.txt file + else: + print("\nDeleting corrupted \"account.txt\" file in the directory.") + time.sleep(1) + os.remove("account.txt") + print("\nDeleted.\nRestarting bot.") + time.sleep(1) + return + + # create account.txt file if not found + else: + nfile = open("account.txt", "w") + nfile.write(input("\nPlease enter your wax wallet address: ")) + nfile.close() + print("\nRestarting bot.") + time.sleep(1) + return + # create AW Account instance - aw = Account(input("\nPlease enter account name (e.g abcde.wam): ")) + aw = Account(wallet) # define range for loop delay delay_min = 60 # min delay before next loop @@ -52,8 +70,9 @@ def main(): chrome_options.add_argument("--ignore-certificate-errors") chrome_options.add_argument("--ignore-certificate-errors-spki-list") chrome_options.add_argument("--ignore-ssl-errors") + chrome_options.add_argument("--window-size=480,270") # when there is already a persistent session, you may activate headless mode - chrome_options.add_argument('--headless') + # chrome_options.add_argument("--headless") chrome_options.add_experimental_option( "excludeSwitches", ["enable-automation"]) @@ -93,7 +112,7 @@ def main(): # make GET request driver.get(url) - print("\nBot will start after 30 seconds, press \"Ctrl + C\" to pause the execution.") + print("\nStarting in 30 seconds, press \"Ctrl + C\" to pause.") while True: try: @@ -106,7 +125,7 @@ def main(): input("\nPress any key to continue.") break - print("\nStarting bot, press \"Ctrl + C\" to stop the execution.\n") + print("\nStarting bot, press \"Ctrl + C\" to stop.\n") # initialize crash count crashes = 0 @@ -170,7 +189,6 @@ def main(): By.XPATH, "//span[contains(text(), 'Mine')]") except KeyboardInterrupt: - winsound.MessageBeep() print('\nStopping bot.') driver.quit() sys.exit() @@ -232,9 +250,9 @@ def main(): print("\nDone sleeping.\n") except KeyboardInterrupt: - winsound.MessageBeep() print('\nStopping bot.') - break + driver.quit() + sys.exit() # if error occured except: @@ -248,7 +266,7 @@ def main(): driver.quit() -if __name__ == '__main__': +while True: assert sys.version_info >= (3, 6), 'Python 3.6+ required.' # call main routine From 1599996915a2e36fdec779a96ca367196ae6d9fe Mon Sep 17 00:00:00 2001 From: theDebonair Date: Fri, 10 Jun 2022 20:52:26 +0530 Subject: [PATCH 07/80] Updated requirements, now more easy to use the bot, less interaction --- README.md | 24 ++++++++++++++++++++---- awbot.py | 23 +++++++++++------------ requirements.txt | 29 ++++++++++++++++++++++++----- run.ps1 | 15 +++++++++++++++ 4 files changed, 70 insertions(+), 21 deletions(-) create mode 100644 run.ps1 diff --git a/README.md b/README.md index aea3701..3f96261 100644 --- a/README.md +++ b/README.md @@ -13,14 +13,23 @@ Alien Worlds automation using Python git clone https://github.com/theDebonair/awbot.git cd awbot ``` -- Install all the required Python packages +- Install all the required Python packages (Globally, not in VirtualEnv) ``` pip install -r requirements.txt ``` -- It is recommended to use VirtualEnv for different instances of the bot. -### Running Instructions -After all the dependencies have been downloaded and installed, simply run awbot.py +### Recommendations +- Use VirtualEnv for different instances of the bot. +- Use high speed internet for better and error-free functionality. + +### Running Instructions (For Windows users) +After all the dependencies have been downloaded and installed, simply run "run.ps1" from powershell +``` +run.ps1 +``` + +### Running Instructions (For non-Windows users) +After all the dependencies have been downloaded and installed, simply run "awbot.py" ``` python awbot.py ``` @@ -28,3 +37,10 @@ python awbot.py On the first run you need to login to your wax account, on the succeeding runs you will be logged in automatically as the session cookies will be saved. Follow the prompts in the command terminal. + +### PS +- For Windows users, VirtualEnv will be created automatically when following the above instructions. +- For non- Windows users, please create a VirtualEnv using +``` +python -m venv venv +``` diff --git a/awbot.py b/awbot.py index 7fc2cb9..b94dd0b 100644 --- a/awbot.py +++ b/awbot.py @@ -71,6 +71,7 @@ def main(): chrome_options.add_argument("--ignore-certificate-errors-spki-list") chrome_options.add_argument("--ignore-ssl-errors") chrome_options.add_argument("--window-size=480,270") + chrome_options.add_argument("−−mute−audio") # when there is already a persistent session, you may activate headless mode # chrome_options.add_argument("--headless") @@ -90,7 +91,8 @@ def main(): ) except TypeError: print("\nPlease update your selenium package.") - return + driver.quit() + sys.exit() # change page load timeout driver.set_page_load_timeout(60) @@ -112,18 +114,15 @@ def main(): # make GET request driver.get(url) - print("\nStarting in 30 seconds, press \"Ctrl + C\" to pause.") - - while True: - try: - # bot waits for 30 seconds - time.sleep(30) - break + # check for chrome-data dir + if os.path.isdir("chrome-data"): + print("\nStarting bot in 10 seconds.") + time.sleep(10) - except KeyboardInterrupt: - print("\nPausing bot.") - input("\nPress any key to continue.") - break + # create chrome-data dir if not found + else: + print("\nPausing bot.") + input("\nPlease sign-in .Then, press any key to continue.") print("\nStarting bot, press \"Ctrl + C\" to stop.\n") diff --git a/requirements.txt b/requirements.txt index a3feb2a..b0abf54 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,24 @@ -requests -selenium -lxml -selenium-stealth -webdriver-manager +async-generator==1.10 +attrs==21.4.0 +certifi==2022.5.18.1 +cffi==1.15.0 +charset-normalizer==2.0.12 +cryptography==37.0.2 +h11==0.13.0 +idna==3.3 +lxml==4.9.0 +outcome==1.1.0 +pycparser==2.21 +pyOpenSSL==22.0.0 +PySocks==1.7.1 +python-dotenv==0.20.0 +requests==2.27.1 +selenium==4.2.0 +selenium-stealth==1.0.6 +sniffio==1.2.0 +sortedcontainers==2.4.0 +trio==0.21.0 +trio-websocket==0.9.2 +urllib3==1.26.9 +webdriver-manager==3.7.0 +wsproto==1.1.0 \ No newline at end of file diff --git a/run.ps1 b/run.ps1 new file mode 100644 index 0000000..a4e99c2 --- /dev/null +++ b/run.ps1 @@ -0,0 +1,15 @@ +$temp = 'False' +$Folder = '.\venv' + +Do { + # checking for venv dir + if (Test-Path -Path $Folder) { + .\venv\Scripts\activate + $temp = 'True' + } else { + py -m venv venv # creating venv + } +} While($temp -eq 'False') + +# to run the bot +py awbot.py; \ No newline at end of file From 58ca99a4c2261dc7cea6da6c7cf86ca1a257fce6 Mon Sep 17 00:00:00 2001 From: theDebonair Date: Sat, 11 Jun 2022 12:58:13 +0530 Subject: [PATCH 08/80] Updated signin prompt --- awbot.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/awbot.py b/awbot.py index b94dd0b..ed8d75f 100644 --- a/awbot.py +++ b/awbot.py @@ -114,15 +114,16 @@ def main(): # make GET request driver.get(url) - # check for chrome-data dir - if os.path.isdir("chrome-data"): + # check for sign.file file + if os.path.exists("signin.file"): print("\nStarting bot in 10 seconds.") time.sleep(10) - # create chrome-data dir if not found + # create sign.file if not found else: print("\nPausing bot.") input("\nPlease sign-in .Then, press any key to continue.") + open("sign.file") print("\nStarting bot, press \"Ctrl + C\" to stop.\n") From b3520fd0840e964c13a26e886ba71a1f46bb771d Mon Sep 17 00:00:00 2001 From: theDebonair Date: Sat, 11 Jun 2022 13:06:35 +0530 Subject: [PATCH 09/80] Updated signin check mechanism --- awbot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awbot.py b/awbot.py index ed8d75f..18644ec 100644 --- a/awbot.py +++ b/awbot.py @@ -123,7 +123,7 @@ def main(): else: print("\nPausing bot.") input("\nPlease sign-in .Then, press any key to continue.") - open("sign.file") + open("sign.file", "a").close() print("\nStarting bot, press \"Ctrl + C\" to stop.\n") From d94c4ddd4a3f969703886490bac147aade38bf8b Mon Sep 17 00:00:00 2001 From: theDebonair Date: Sat, 11 Jun 2022 13:18:36 +0530 Subject: [PATCH 10/80] Some fixes --- .gitignore | 3 +++ awbot.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index f7e35d8..c39a99a 100644 --- a/.gitignore +++ b/.gitignore @@ -140,3 +140,6 @@ Pipfile.lock # Wallet address account.txt + +# Signin check file +sign.file diff --git a/awbot.py b/awbot.py index 18644ec..a039da7 100644 --- a/awbot.py +++ b/awbot.py @@ -71,7 +71,7 @@ def main(): chrome_options.add_argument("--ignore-certificate-errors-spki-list") chrome_options.add_argument("--ignore-ssl-errors") chrome_options.add_argument("--window-size=480,270") - chrome_options.add_argument("−−mute−audio") + chrome_options.add_argument("--mute-audio") # when there is already a persistent session, you may activate headless mode # chrome_options.add_argument("--headless") From b8ac5be8108a10c276efc0ab22a1510c9ad34949 Mon Sep 17 00:00:00 2001 From: theDebonair Date: Sat, 11 Jun 2022 13:21:49 +0530 Subject: [PATCH 11/80] Bug fix --- awbot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awbot.py b/awbot.py index a039da7..7bff74f 100644 --- a/awbot.py +++ b/awbot.py @@ -115,7 +115,7 @@ def main(): driver.get(url) # check for sign.file file - if os.path.exists("signin.file"): + if os.path.exists("sign.file"): print("\nStarting bot in 10 seconds.") time.sleep(10) From 56eba2270c3f55aec0c2e3230a0b9ba34cb0e579 Mon Sep 17 00:00:00 2001 From: theDebonair Date: Sat, 11 Jun 2022 13:40:09 +0530 Subject: [PATCH 12/80] Fix formatting --- awbot.py | 41 +++++++++++++++++------------------------ 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/awbot.py b/awbot.py index 7bff74f..641baec 100644 --- a/awbot.py +++ b/awbot.py @@ -75,8 +75,7 @@ def main(): # when there is already a persistent session, you may activate headless mode # chrome_options.add_argument("--headless") - chrome_options.add_experimental_option( - "excludeSwitches", ["enable-automation"]) + chrome_options.add_experimental_option("excludeSwitches", ["enable-automation"]) chrome_options.add_experimental_option("useAutomationExtension", False) # save current browsing session to make it persistent @@ -155,12 +154,9 @@ def main(): width = 80 print("=" * width) - print( - "CPU: [ {:,} / {:,} ms ]\t\t\tUsed: {} %".format(cpu_used, cpu_max, cpu_pct)) - print( - "NET: [ {:,} / {:,} B ]\t\t\tUsed: {} %".format(net_used, net_max, net_pct)) - print( - "RAM: [ {:,} / {:,} B ]\t\t\tUsed: {} %".format(ram_used, ram_max, ram_pct)) + print("CPU: [ {:,} / {:,} ms ]\t\t\tUsed: {} %".format(cpu_used, cpu_max, cpu_pct)) + print("NET: [ {:,} / {:,} B ]\t\t\tUsed: {} %".format(net_used, net_max, net_pct)) + print("RAM: [ {:,} / {:,} B ]\t\t\tUsed: {} %".format(ram_used, ram_max, ram_pct)) print("=" * width) # get balances @@ -172,8 +168,7 @@ def main(): print("TLM Balance:", tlm) if (cpu_pct > resource_limit) or (ram_pct > resource_limit) or (net_pct > resource_limit): - print("\nResource utilization is above the set threshold of {} %".format( - resource_limit)) + print("\nResource utilization is above the set threshold of {} %".format(resource_limit)) print("\nSleeping for {} seconds\n".format(resource_sleep)) time.sleep(resource_sleep) continue @@ -183,13 +178,13 @@ def main(): while True: _print_(".") + # try to find mine button try: - mine_btn = driver.find_element( - By.XPATH, "//span[contains(text(), 'Mine')]") + mine_btn = driver.find_element(By.XPATH, "//span[contains(text(), 'Mine')]") except KeyboardInterrupt: - print('\nStopping bot.') + print("\nStopping bot.") driver.quit() sys.exit() @@ -205,8 +200,7 @@ def main(): break # wait for claim button - claim_btn = WebDriverWait(driver, 60).until(ec.visibility_of_element_located( - (By.XPATH, "//span[contains(text(), 'Claim Mine')]"))) + claim_btn = WebDriverWait(driver, 60).until(ec.visibility_of_element_located((By.XPATH, "//span[contains(text(), 'Claim Mine')]"))) print("\nFound Claim button!") # click claim button @@ -218,26 +212,25 @@ def main(): # switch control to pop-up window for this_window in driver.window_handles: if this_window != main_window: - print('\n\tSwitching to new window.') + print("\n\tSwitching to new window.") driver.switch_to.window(this_window) break # wait for approve button to be visible and click button - btn = WebDriverWait(driver, 60).until(ec.visibility_of_element_located( - (By.XPATH, "//*[contains(text(), 'Approve')]"))) + btn = WebDriverWait(driver, 60).until(ec.visibility_of_element_located((By.XPATH, "//*[contains(text(), 'Approve')]"))) # if approve button is found if btn: - print('\n\tFound Approve button.') + print("\n\tFound Approve button.") btn.click() - print('\n\tApproving transaction.') + print("\n\tApproving transaction.") # if approve button could not be found else: raise IOError('\n\tUnable to load or find approve button.') # go control back to main window - print('\n\tSwitching back to main window.\n') + print("\n\tSwitching back to main window.\n") driver.switch_to.window(main_window) # show the number of loops done @@ -250,15 +243,15 @@ def main(): print("\nDone sleeping.\n") except KeyboardInterrupt: - print('\nStopping bot.') + print("\nStopping bot.") driver.quit() sys.exit() # if error occured except: crashes += 1 - print( - f"\nBot encountered an error. {crashes} Total crashes since start.") + print(f"\nBot encountered an error. {crashes} Total crashes since start.") + # make GET request driver.get(url) From f36b042dd3c6944e11d1bf442644b43c2825af69 Mon Sep 17 00:00:00 2001 From: theDebonair Date: Sat, 11 Jun 2022 17:20:01 +0530 Subject: [PATCH 13/80] Fixed bugs in awapi --- awapi.py | 12 +++++++++--- awbot.py | 10 +++++----- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/awapi.py b/awapi.py index 0be2899..d69785e 100644 --- a/awapi.py +++ b/awapi.py @@ -51,12 +51,18 @@ def get_balance(self, contract:str, currency:str) -> float: try: url = 'https://wax.greymass.com/v1/chain/get_currency_balance' reply = self._session.post(url, json=json_payload, timeout=Account.HTTP_TIMEOUT) + assert reply.status_code == 200 + balance = float(reply.json()[0].split()[0]) + return balance except ReadTimeout: url = 'https://chain.wax.io/v1/chain/get_currency_balance' reply = self._session.post(url, json=json_payload, timeout=Account.HTTP_TIMEOUT) - assert reply.status_code == 200 - balance = float(reply.json()[0].split()[0]) - return balance + assert reply.status_code == 200 + balance = float(reply.json()[0].split()[0]) + return balance + except: + balance = "Error retrieving values" + return balance def get_account(self) -> dict: """ diff --git a/awbot.py b/awbot.py index 641baec..64f1f33 100644 --- a/awbot.py +++ b/awbot.py @@ -154,9 +154,9 @@ def main(): width = 80 print("=" * width) - print("CPU: [ {:,} / {:,} ms ]\t\t\tUsed: {} %".format(cpu_used, cpu_max, cpu_pct)) - print("NET: [ {:,} / {:,} B ]\t\t\tUsed: {} %".format(net_used, net_max, net_pct)) - print("RAM: [ {:,} / {:,} B ]\t\t\tUsed: {} %".format(ram_used, ram_max, ram_pct)) + print("CPU: [ {:,} / {:,} ms ]\t\tUsed: {} %".format(cpu_used, cpu_max, cpu_pct)) + print("NET: [ {:,} / {:,} B ]\t\tUsed: {} %".format(net_used, net_max, net_pct)) + print("RAM: [ {:,} / {:,} B ]\t\tUsed: {} %".format(ram_used, ram_max, ram_pct)) print("=" * width) # get balances @@ -164,8 +164,8 @@ def main(): tlm = aw.tlm_balance # show balances - print("WAX Balance:", wax) - print("TLM Balance:", tlm) + print("\nWAX Balance: ", wax) + print("\nTLM Balance: ", tlm) if (cpu_pct > resource_limit) or (ram_pct > resource_limit) or (net_pct > resource_limit): print("\nResource utilization is above the set threshold of {} %".format(resource_limit)) From 0dddb9b9d2a37039779702d9d51477b07a33896d Mon Sep 17 00:00:00 2001 From: Harshit Gupta <51323434+theDebonair@users.noreply.github.com> Date: Sat, 11 Jun 2022 18:56:48 +0530 Subject: [PATCH 14/80] Update README.md --- README.md | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 3f96261..241fa75 100644 --- a/README.md +++ b/README.md @@ -1,46 +1,47 @@ # awbot -Alien Worlds automation using Python +###### Alien Worlds automation using Python. ### Requirements -- Python 3.6 or later (You may download Python from here https://www.python.org/downloads) -- Chrome Driver (Downloaded automatically during runtime. If Chrome Driver could not be downloaded automatically, please manually download the correct version from here https://chromedriver.chromium.org/downloads) -- Python Packages (Listed in requirements.txt) -- Active Alien Worlds account +- ###### Python 3.6 or later (You may download Python from here https://www.python.org/downloads), +- ###### Chrome Driver (Downloaded automatically during runtime. If Chrome Driver could not be downloaded automatically, please manually download the correct version from here https://chromedriver.chromium.org/downloads), +- ###### Python Packages (Listed in requirements.txt), +- ###### Active Alien Worlds account. ### Installation Instructions -- Clone this repository +- ###### Clone this repository, ``` git clone https://github.com/theDebonair/awbot.git cd awbot ``` -- Install all the required Python packages (Globally, not in VirtualEnv) +- ###### Install all the required Python packages (Globally, not in VirtualEnv). ``` pip install -r requirements.txt ``` ### Recommendations -- Use VirtualEnv for different instances of the bot. -- Use high speed internet for better and error-free functionality. +- ###### Use VirtualEnv for different instances of the bot, +- ###### Use high speed internet for better and error-free functionality. ### Running Instructions (For Windows users) -After all the dependencies have been downloaded and installed, simply run "run.ps1" from powershell +###### After all the dependencies have been downloaded and installed, simply run "run.ps1" from powershell. ``` run.ps1 ``` ### Running Instructions (For non-Windows users) -After all the dependencies have been downloaded and installed, simply run "awbot.py" +###### After all the dependencies have been downloaded and installed, simply run "awbot.py". ``` python awbot.py ``` -On the first run you need to login to your wax account, on the succeeding runs you will be logged in automatically as the session cookies will be saved. +###### On the first run you need to login to your wax account, on the succeeding runs you will be logged in automatically as the session cookies will be saved. -Follow the prompts in the command terminal. +###### Follow the prompts in the command terminal. ### PS -- For Windows users, VirtualEnv will be created automatically when following the above instructions. -- For non- Windows users, please create a VirtualEnv using +- ###### For Windows users, VirtualEnv will be created automatically when following the above instructions. +- ###### For non- Windows users, please create a VirtualEnv using ``` python -m venv venv ``` +- ###### Feel free to make suggestions, report bugs on this project's [discussions](https://github.com/theDebonair/ryzenadj_2500u_a315/discussions) tab. From 2e2c203b3de5239fe9ddbba033cbe477619c1023 Mon Sep 17 00:00:00 2001 From: Harshit Gupta <51323434+theDebonair@users.noreply.github.com> Date: Sat, 11 Jun 2022 18:59:57 +0530 Subject: [PATCH 15/80] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 241fa75..51503ad 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ python awbot.py ### PS - ###### For Windows users, VirtualEnv will be created automatically when following the above instructions. -- ###### For non- Windows users, please create a VirtualEnv using +- ###### For non- Windows users, please create a VirtualEnv. ``` python -m venv venv ``` From 93ed21da120ad4530a3a376608f0655f5125e1bf Mon Sep 17 00:00:00 2001 From: theDebonair Date: Sat, 11 Jun 2022 19:18:30 +0530 Subject: [PATCH 16/80] Updated readme --- README.md | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 3f96261..566e700 100644 --- a/README.md +++ b/README.md @@ -1,46 +1,49 @@ # awbot -Alien Worlds automation using Python +###### Alien Worlds automation using Python. ### Requirements -- Python 3.6 or later (You may download Python from here https://www.python.org/downloads) -- Chrome Driver (Downloaded automatically during runtime. If Chrome Driver could not be downloaded automatically, please manually download the correct version from here https://chromedriver.chromium.org/downloads) -- Python Packages (Listed in requirements.txt) -- Active Alien Worlds account +- ###### Python 3.6 or later (You may download Python from here https://www.python.org/downloads), +- ###### Chrome Driver (Downloaded automatically during runtime. If Chrome Driver could not be downloaded automatically, please manually download the correct version from here https://chromedriver.chromium.org/downloads), +- ###### Python Packages (Listed in requirements.txt), +- ###### Active Alien Worlds account. ### Installation Instructions -- Clone this repository +- ###### Clone this repository, ``` git clone https://github.com/theDebonair/awbot.git cd awbot ``` -- Install all the required Python packages (Globally, not in VirtualEnv) +- ###### Install all the required Python packages (Globally, not in VirtualEnv). ``` pip install -r requirements.txt ``` ### Recommendations -- Use VirtualEnv for different instances of the bot. -- Use high speed internet for better and error-free functionality. +- ###### Use VirtualEnv for different instances of the bot, +- ###### Use high speed internet for better and error-free functionality. ### Running Instructions (For Windows users) -After all the dependencies have been downloaded and installed, simply run "run.ps1" from powershell +###### After all the dependencies have been downloaded and installed, simply run "run.ps1" from powershell. ``` run.ps1 ``` ### Running Instructions (For non-Windows users) -After all the dependencies have been downloaded and installed, simply run "awbot.py" +###### After all the dependencies have been downloaded and installed, simply run "awbot.py". ``` python awbot.py ``` -On the first run you need to login to your wax account, on the succeeding runs you will be logged in automatically as the session cookies will be saved. +###### On the first run you need to login to your wax account, on the succeeding runs you will be logged in automatically as the session cookies will be saved. -Follow the prompts in the command terminal. +###### Follow the prompts in the command terminal. + +###### You must open the terminal in the same directory where the files are stored. ### PS -- For Windows users, VirtualEnv will be created automatically when following the above instructions. -- For non- Windows users, please create a VirtualEnv using +- ###### For Windows users, VirtualEnv will be created automatically when following the above instructions. +- ###### For non- Windows users, please create a VirtualEnv. ``` python -m venv venv ``` +- ###### Feel free to make suggestions, report bugs on this project's [discussions](https://github.com/theDebonair/awbot/discussions) tab. From 9e1fc757b9f34a36cd8516f946eebab61144e679 Mon Sep 17 00:00:00 2001 From: theDebonair Date: Sat, 11 Jun 2022 19:23:44 +0530 Subject: [PATCH 17/80] Updated readme --- README.md | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 3ebfb64..6426c26 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ git clone https://github.com/theDebonair/awbot.git cd awbot ``` + - ###### Install all the required Python packages (Globally, not in VirtualEnv). ``` pip install -r requirements.txt @@ -23,34 +24,24 @@ pip install -r requirements.txt - ###### Use high speed internet for better and error-free functionality. ### Running Instructions (For Windows users) -###### After all the dependencies have been downloaded and installed, simply run "run.ps1" from powershell. +- ###### After all the dependencies have been downloaded and installed, simply run "run.ps1" from powershell. ``` run.ps1 ``` ### Running Instructions (For non-Windows users) -###### After all the dependencies have been downloaded and installed, simply run "awbot.py". +- ###### After all the dependencies have been downloaded and installed, simply run "awbot.py". ``` python awbot.py ``` -###### On the first run you need to login to your wax account, on the succeeding runs you will be logged in automatically as the session cookies will be saved. - -###### Follow the prompts in the command terminal. -<<<<<<< HEAD - -###### You must open the terminal in the same directory where the files are stored. -======= ->>>>>>> 2e2c203b3de5239fe9ddbba033cbe477619c1023 - ### PS +- ###### On the first run you need to login to your wax account, on the succeeding runs you will be logged in automatically as the session cookies will be saved. +- ###### Follow the prompts in the command terminal. +- ###### You must open the terminal in the same directory where the files are stored. - ###### For Windows users, VirtualEnv will be created automatically when following the above instructions. - ###### For non- Windows users, please create a VirtualEnv. ``` python -m venv venv ``` -<<<<<<< HEAD - ###### Feel free to make suggestions, report bugs on this project's [discussions](https://github.com/theDebonair/awbot/discussions) tab. -======= -- ###### Feel free to make suggestions, report bugs on this project's [discussions](https://github.com/theDebonair/ryzenadj_2500u_a315/discussions) tab. ->>>>>>> 2e2c203b3de5239fe9ddbba033cbe477619c1023 From b723266fc1488e9e243e207fc49caa009d6b71ee Mon Sep 17 00:00:00 2001 From: theDebonair Date: Sun, 12 Jun 2022 16:49:25 +0530 Subject: [PATCH 18/80] Added show average and last mined value. --- awbot.py | 148 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 98 insertions(+), 50 deletions(-) diff --git a/awbot.py b/awbot.py index 64f1f33..6a195c1 100644 --- a/awbot.py +++ b/awbot.py @@ -1,9 +1,11 @@ #!/usr/bin/env python3 +import re import sys import os import time import random import pathlib +import http.client as httplib from itertools import count from selenium import webdriver from selenium.webdriver.chrome.options import Options @@ -11,7 +13,7 @@ from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as ec -from selenium.common.exceptions import NoSuchElementException +from selenium.common.exceptions import * from selenium_stealth import stealth from webdriver_manager.chrome import ChromeDriverManager from awapi import Account @@ -23,6 +25,24 @@ def _print_(text: str) -> None: def main(): + # clear terminal + os.system('cls' if os.name == 'nt' else 'clear') + + # check internet connection + conn = httplib.HTTPConnection("1.1.1.1", timeout = 5) + try: + print("Internet check.") + conn.request("HEAD", "/") + conn.close() + print("Internet available.") + except: + conn.close() + print("No Internet. Re-checking in 30 seconds.") + for x in range(30): + time.sleep(1) + _print_(".") + return + # define game url url = "https://play.alienworlds.io" @@ -40,7 +60,8 @@ def main(): print("\nDeleting corrupted \"account.txt\" file in the directory.") time.sleep(1) os.remove("account.txt") - print("\nDeleted.\nRestarting bot.") + print("File deleted.") + print("Restarting bot.") time.sleep(1) return @@ -49,7 +70,7 @@ def main(): nfile = open("account.txt", "w") nfile.write(input("\nPlease enter your wax wallet address: ")) nfile.close() - print("\nRestarting bot.") + print("Restarting bot.") time.sleep(1) return @@ -70,8 +91,9 @@ def main(): chrome_options.add_argument("--ignore-certificate-errors") chrome_options.add_argument("--ignore-certificate-errors-spki-list") chrome_options.add_argument("--ignore-ssl-errors") - chrome_options.add_argument("--window-size=480,270") + chrome_options.add_argument("--window-size=0,180") chrome_options.add_argument("--mute-audio") + # when there is already a persistent session, you may activate headless mode # chrome_options.add_argument("--headless") @@ -91,12 +113,12 @@ def main(): except TypeError: print("\nPlease update your selenium package.") driver.quit() - sys.exit() + sys.exit(0) # change page load timeout driver.set_page_load_timeout(60) - # instatiate stealth + # instantiate stealth stealth( driver, languages=["en-US", "en"], @@ -116,21 +138,31 @@ def main(): # check for sign.file file if os.path.exists("sign.file"): print("\nStarting bot in 10 seconds.") - time.sleep(10) + for x in range(10): + time.sleep(1) + _print_(".") # create sign.file if not found else: print("\nPausing bot.") - input("\nPlease sign-in .Then, press any key to continue.") + input("Please sign-in .Then, press any key to continue.") open("sign.file", "a").close() - print("\nStarting bot, press \"Ctrl + C\" to stop.\n") + print("\nStarting bot, press \"Ctrl + C\" to stop.") + + # initialize mine loop count + mine_loop_count = 0 - # initialize crash count - crashes = 0 + # load tlm balance + tlm_old = aw.tlm_balance + + # activation switch for checking tlm mined per click + i = False # main bot loop for loop_count in count(1): + # clear terminal + os.system('cls' if os.name == 'nt' else 'clear') try: # fetch cpu usage details cpu_usage = aw.cpu_usage @@ -150,35 +182,43 @@ def main(): net_used = net_usage['used'] net_pct = int(net_used / net_max * 100) - # line width - width = 80 + print("CPU: [ {:,} / {:,} ms ]\tUsed: {} %".format(cpu_used, cpu_max, cpu_pct)) + print("NET: [ {:,} / {:,} B ]\tUsed: {} %".format(net_used, net_max, net_pct)) + print("RAM: [ {:,} / {:,} B ]\tUsed: {} %".format(ram_used, ram_max, ram_pct)) + + # show balances + print(f"\nWAX Balance: {aw.wax_balance}") + print(f"TLM Balance: {aw.tlm_balance}") - print("=" * width) - print("CPU: [ {:,} / {:,} ms ]\t\tUsed: {} %".format(cpu_used, cpu_max, cpu_pct)) - print("NET: [ {:,} / {:,} B ]\t\tUsed: {} %".format(net_used, net_max, net_pct)) - print("RAM: [ {:,} / {:,} B ]\t\tUsed: {} %".format(ram_used, ram_max, ram_pct)) - print("=" * width) + # show tlm mined per click + if i: + try: - # get balances - wax = aw.wax_balance - tlm = aw.tlm_balance + # to find the value of tlm mined + tlm_new = aw.tlm_balance + tlm_mined = tlm_new - tlm_old + print(f"TLM mined on last claim: {tlm_mined:.4f}") + tlm_old = tlm_new - # show balances - print("\nWAX Balance: ", wax) - print("\nTLM Balance: ", tlm) + # to find average rate of tlm mining + tlm_sum += tlm_mined + average = tlm_sum/mine_loop_count + print(f"Average rate for TLM mining: {average}/claim") + except: + print("\nUnable to show the average rate & the difference between the claims.") if (cpu_pct > resource_limit) or (ram_pct > resource_limit) or (net_pct > resource_limit): print("\nResource utilization is above the set threshold of {} %".format(resource_limit)) - print("\nSleeping for {} seconds\n".format(resource_sleep)) - time.sleep(resource_sleep) + print("Sleeping for {} seconds\n".format(resource_sleep)) + for x in range(resource_sleep): + time.sleep(1) + _print_(".") continue # wait for mine button to be found - print("\nWaiting for Mine button") + print("\nWaiting for \"Mine\" button.") while True: - _print_(".") - # try to find mine button try: mine_btn = driver.find_element(By.XPATH, "//span[contains(text(), 'Mine')]") @@ -186,76 +226,84 @@ def main(): except KeyboardInterrupt: print("\nStopping bot.") driver.quit() - sys.exit() + sys.exit(0) # if button is not found except NoSuchElementException: - time.sleep(5) + time.sleep(1) + _print_(".") # if button is found else: - print("\nFound Mine button!") + print("Found \"Mine\" button!") + # click mine_btn.click() break # wait for claim button + print("\nSearching for \"Claim\" button.") claim_btn = WebDriverWait(driver, 60).until(ec.visibility_of_element_located((By.XPATH, "//span[contains(text(), 'Claim Mine')]"))) - print("\nFound Claim button!") + print("Found \"Claim\" button!") # click claim button claim_btn.click() - # pause for 3 seconds + # wait for pop-up window + print("\n\tSearching for pop-up window.") time.sleep(3) # switch control to pop-up window for this_window in driver.window_handles: if this_window != main_window: - print("\n\tSwitching to new window.") + print("\tSwitching to pop-up window.") driver.switch_to.window(this_window) break - # wait for approve button to be visible and click button + # wait for approve button to be visible & click button btn = WebDriverWait(driver, 60).until(ec.visibility_of_element_located((By.XPATH, "//*[contains(text(), 'Approve')]"))) # if approve button is found if btn: - print("\n\tFound Approve button.") + print("\n\tFound \"Approve\" button.") btn.click() - print("\n\tApproving transaction.") + print("\tApproving transaction.") + mine_loop_count += 1 # if approve button could not be found else: raise IOError('\n\tUnable to load or find approve button.') # go control back to main window - print("\n\tSwitching back to main window.\n") + print("\n\tSwitching back to main window.") driver.switch_to.window(main_window) # show the number of loops done - print(f"\nTotal runs: {loop_count}") + print(f"\nTotal number of execution(s): {loop_count}") + + # show the number of loops done + print(f"Total number of approval(s): {mine_loop_count}") # delay the bot before starting next loop delay = random.randint(delay_min, delay_max) print(f"\nSleeping for {delay} seconds.") - time.sleep(delay) - print("\nDone sleeping.\n") + for x in range(delay): + time.sleep(1) + _print_(".") + print("Done sleeping.") + i = True except KeyboardInterrupt: print("\nStopping bot.") driver.quit() - sys.exit() + sys.exit(0) - # if error occured + # if any error occured except: - crashes += 1 - print(f"\nBot encountered an error. {crashes} Total crashes since start.") - - # make GET request - driver.get(url) + print("\nBot encountered an error. Restarting.") + return - # close the webdriver + # close the webdriver & exit driver.quit() From 09617e16d7719fedfd3e80150c97b2d99737d186 Mon Sep 17 00:00:00 2001 From: theDebonair Date: Sun, 12 Jun 2022 16:51:56 +0530 Subject: [PATCH 19/80] Minor fixes --- awbot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awbot.py b/awbot.py index 6a195c1..a0eaf5b 100644 --- a/awbot.py +++ b/awbot.py @@ -235,7 +235,7 @@ def main(): # if button is found else: - print("Found \"Mine\" button!") + print("\nFound \"Mine\" button!") # click mine_btn.click() From 10c3c3253da5591cedea36db5a8246236c7e0283 Mon Sep 17 00:00:00 2001 From: theDebonair Date: Sun, 12 Jun 2022 16:56:33 +0530 Subject: [PATCH 20/80] Updated formatting --- awbot.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/awbot.py b/awbot.py index a0eaf5b..1c1cab7 100644 --- a/awbot.py +++ b/awbot.py @@ -208,8 +208,8 @@ def main(): print("\nUnable to show the average rate & the difference between the claims.") if (cpu_pct > resource_limit) or (ram_pct > resource_limit) or (net_pct > resource_limit): - print("\nResource utilization is above the set threshold of {} %".format(resource_limit)) - print("Sleeping for {} seconds\n".format(resource_sleep)) + print("\nResource utilization is above the set threshold of {} %.".format(resource_limit)) + print("Sleeping for {} seconds.".format(resource_sleep)) for x in range(resource_sleep): time.sleep(1) _print_(".") @@ -265,7 +265,7 @@ def main(): # if approve button is found if btn: - print("\n\tFound \"Approve\" button.") + print("\n\tFound \"Approve\" button!") btn.click() print("\tApproving transaction.") mine_loop_count += 1 From 8dc2dc9c93f3c77499f215cd03bf948d4b55ee29 Mon Sep 17 00:00:00 2001 From: theDebonair Date: Sun, 12 Jun 2022 17:35:32 +0530 Subject: [PATCH 21/80] Fixed avg rate --- awbot.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/awbot.py b/awbot.py index 1c1cab7..1b5c8ae 100644 --- a/awbot.py +++ b/awbot.py @@ -97,13 +97,13 @@ def main(): # when there is already a persistent session, you may activate headless mode # chrome_options.add_argument("--headless") - chrome_options.add_experimental_option("excludeSwitches", ["enable-automation"]) - chrome_options.add_experimental_option("useAutomationExtension", False) - # save current browsing session to make it persistent pwd = pathlib.Path().absolute() chrome_options.add_argument(f"--user-data-dir={pwd}\\chrome-data") + chrome_options.add_experimental_option("excludeSwitches", ["enable-automation"]) + chrome_options.add_experimental_option("useAutomationExtension", False) + # instantiate Chrome driver with given Chrome options try: driver = webdriver.Chrome( @@ -156,6 +156,9 @@ def main(): # load tlm balance tlm_old = aw.tlm_balance + # initialize tlm_sum + tlm_sum = 0 + # activation switch for checking tlm mined per click i = False @@ -203,7 +206,7 @@ def main(): # to find average rate of tlm mining tlm_sum += tlm_mined average = tlm_sum/mine_loop_count - print(f"Average rate for TLM mining: {average}/claim") + print(f"Average rate for TLM mining: {average:.4f}/claim") except: print("\nUnable to show the average rate & the difference between the claims.") From 07c0b287ba132940dfb9724808a09c55668b73ce Mon Sep 17 00:00:00 2001 From: theDebonair Date: Sun, 12 Jun 2022 18:48:39 +0530 Subject: [PATCH 22/80] Minor fixes --- awbot.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/awbot.py b/awbot.py index 1b5c8ae..7c2ade2 100644 --- a/awbot.py +++ b/awbot.py @@ -205,7 +205,8 @@ def main(): # to find average rate of tlm mining tlm_sum += tlm_mined - average = tlm_sum/mine_loop_count + avg = tlm_sum/mine_loop_count + average = abs(avg) print(f"Average rate for TLM mining: {average:.4f}/claim") except: print("\nUnable to show the average rate & the difference between the claims.") From f52b1b397d20d723357da689c88984d162285bc3 Mon Sep 17 00:00:00 2001 From: theDebonair Date: Mon, 13 Jun 2022 13:01:59 +0530 Subject: [PATCH 23/80] Added resource(s) over-utilization --- .gitignore | 3 ++ awbot.py | 85 +++++++++++++++++++++++++++++++++++++++++------------- 2 files changed, 68 insertions(+), 20 deletions(-) diff --git a/.gitignore b/.gitignore index c39a99a..8b38688 100644 --- a/.gitignore +++ b/.gitignore @@ -143,3 +143,6 @@ account.txt # Signin check file sign.file + +# Throttle file check +throttle.txt diff --git a/awbot.py b/awbot.py index 7c2ade2..a549a94 100644 --- a/awbot.py +++ b/awbot.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -import re import sys import os import time @@ -49,17 +48,17 @@ def main(): # check for account.txt file if os.path.exists("account.txt"): - # check for file size + # check for file size & read if os.stat("account.txt").st_size != 0: - file = open("account.txt", "r") - wallet = file.read() - file.close() + afile = open("account.txt", "r") + wallet = afile.read() + afile.close() # delete the file if found empty account.txt file else: - print("\nDeleting corrupted \"account.txt\" file in the directory.") - time.sleep(1) + print("\nDeleting corrupted \"account.txt\".") os.remove("account.txt") + time.sleep(1) print("File deleted.") print("Restarting bot.") time.sleep(1) @@ -67,9 +66,9 @@ def main(): # create account.txt file if not found else: - nfile = open("account.txt", "w") - nfile.write(input("\nPlease enter your wax wallet address: ")) - nfile.close() + anfile = open("account.txt", "w") + anfile.write(input("\nPlease enter your wax wallet address: ")) + anfile.close() print("Restarting bot.") time.sleep(1) return @@ -137,7 +136,7 @@ def main(): # check for sign.file file if os.path.exists("sign.file"): - print("\nStarting bot in 10 seconds.") + print("\nStarting bot in 10 seconds. Delete \"sign.file\" in case of re-login.") for x in range(10): time.sleep(1) _print_(".") @@ -200,7 +199,7 @@ def main(): # to find the value of tlm mined tlm_new = aw.tlm_balance tlm_mined = tlm_new - tlm_old - print(f"TLM mined on last claim: {tlm_mined:.4f}") + print(f"TLM mined in last claim: {tlm_mined:.4f}") tlm_old = tlm_new # to find average rate of tlm mining @@ -208,16 +207,62 @@ def main(): avg = tlm_sum/mine_loop_count average = abs(avg) print(f"Average rate for TLM mining: {average:.4f}/claim") - except: - print("\nUnable to show the average rate & the difference between the claims.") - if (cpu_pct > resource_limit) or (ram_pct > resource_limit) or (net_pct > resource_limit): - print("\nResource utilization is above the set threshold of {} %.".format(resource_limit)) - print("Sleeping for {} seconds.".format(resource_sleep)) - for x in range(resource_sleep): + # to show sum of tlm mined + print(f"Total TLM mined in this session: {tlm_sum:.4f}") + except: + print("\nUnable to retrieve the value(s).") + + # check for throttle.txt file + if os.path.exists("throttle.txt"): + + # check for file size & read + if os.stat("throttle.txt").st_size != 0: + tfile = open("throttle.txt", "r") + throttle = tfile.read() + tfile.close() + + if throttle == "N" or throttle == "n": + + # resource utilization throttling + if (cpu_pct > resource_limit) or (ram_pct > resource_limit) or (net_pct > resource_limit): + print("\nResource utilization is above the set threshold of {} %.".format(resource_limit)) + print("Sleeping for {} seconds.".format(resource_sleep)) + for x in range(resource_sleep): + time.sleep(1) + _print_(".") + continue + + elif throttle == "Y" or throttle == "y": + print("\nResource utilization throttling is OFF. Turn ON by changing value to \"N\" in the \"throttle.txt\" file.") + + # delete the file if value found other than Y or N + else: + print("\nAppropriate input not found.") + print("Deleting corrupted \"throttle.txt\".") + os.remove("throttle.txt") + time.sleep(1) + print("File deleted.") + print("Restarting bot.") + time.sleep(1) + return + + # delete the file if found empty throttle.txt file + else: + print("\nDeleting corrupted \"throttle.txt\".") + os.remove("throttle.txt") time.sleep(1) - _print_(".") - continue + print("File deleted.") + print("Restarting bot.") + time.sleep(1) + return + + # create throttle.txt file if not found + else: + ntfile = open("throttle.txt", "w") + ntfile.write(input("\nDo you want to enable the over-utilization of resource(s) [Y/N]: ")) + ntfile.close() + return # wait for mine button to be found print("\nWaiting for \"Mine\" button.") From f04433bae64b4c73b3d8147d9ab0f197a66ed19d Mon Sep 17 00:00:00 2001 From: theDebonair Date: Mon, 13 Jun 2022 13:10:01 +0530 Subject: [PATCH 24/80] Bot resource throttling --- README.md | 1 + awbot.py | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6426c26..8f04bf3 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ python awbot.py ``` ### PS +- ###### "Bot resource(s) throttling" feature disables the check for CPU, NET, RAM usage. This enables the bot to click even when the resources are above 100%. - ###### On the first run you need to login to your wax account, on the succeeding runs you will be logged in automatically as the session cookies will be saved. - ###### Follow the prompts in the command terminal. - ###### You must open the terminal in the same directory where the files are stored. diff --git a/awbot.py b/awbot.py index a549a94..ef0e606 100644 --- a/awbot.py +++ b/awbot.py @@ -222,7 +222,7 @@ def main(): throttle = tfile.read() tfile.close() - if throttle == "N" or throttle == "n": + if throttle == "Y" or throttle == "y": # resource utilization throttling if (cpu_pct > resource_limit) or (ram_pct > resource_limit) or (net_pct > resource_limit): @@ -233,7 +233,7 @@ def main(): _print_(".") continue - elif throttle == "Y" or throttle == "y": + elif throttle == "N" or throttle == "n": print("\nResource utilization throttling is OFF. Turn ON by changing value to \"N\" in the \"throttle.txt\" file.") # delete the file if value found other than Y or N @@ -260,7 +260,7 @@ def main(): # create throttle.txt file if not found else: ntfile = open("throttle.txt", "w") - ntfile.write(input("\nDo you want to enable the over-utilization of resource(s) [Y/N]: ")) + ntfile.write(input("\nDo you want to enable the bot resource(s) throttling [Y/N]: ")) ntfile.close() return From d68a85ef51a5d9e9658fd6277444fc19171b3463 Mon Sep 17 00:00:00 2001 From: theDebonair Date: Mon, 13 Jun 2022 20:27:12 +0530 Subject: [PATCH 25/80] Updated readme --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 8f04bf3..92f5025 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,8 @@ run.ps1 ``` python awbot.py ``` +### Attention +###### Using bot or any kind of automation is not recommended by the Aliens World. I'm not responsible for any kind of your loss(es). USE AT YOUR OWN RISK! ### PS - ###### "Bot resource(s) throttling" feature disables the check for CPU, NET, RAM usage. This enables the bot to click even when the resources are above 100%. From d4e87394040e04b8d85083a03a117a0ae565140c Mon Sep 17 00:00:00 2001 From: theDebonair Date: Tue, 14 Jun 2022 08:54:20 +0530 Subject: [PATCH 26/80] Fix internet check --- awbot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awbot.py b/awbot.py index ef0e606..9d72f02 100644 --- a/awbot.py +++ b/awbot.py @@ -28,7 +28,7 @@ def main(): os.system('cls' if os.name == 'nt' else 'clear') # check internet connection - conn = httplib.HTTPConnection("1.1.1.1", timeout = 5) + conn = httplib.HTTPConnection("https://www.google.com/", timeout = 5) try: print("Internet check.") conn.request("HEAD", "/") From eac2df8d2761651918d583be85c7d22e70a3f866 Mon Sep 17 00:00:00 2001 From: theDebonair Date: Tue, 14 Jun 2022 09:32:29 +0530 Subject: [PATCH 27/80] Fix internet check --- awbot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awbot.py b/awbot.py index 9d72f02..3ae419e 100644 --- a/awbot.py +++ b/awbot.py @@ -28,7 +28,7 @@ def main(): os.system('cls' if os.name == 'nt' else 'clear') # check internet connection - conn = httplib.HTTPConnection("https://www.google.com/", timeout = 5) + conn = httplib.HTTPConnection("8.8.8.8", timeout = 5) try: print("Internet check.") conn.request("HEAD", "/") From 01b271dea837fa63065088858510fcfd54d271bb Mon Sep 17 00:00:00 2001 From: theDebonair Date: Tue, 14 Jun 2022 09:57:18 +0530 Subject: [PATCH 28/80] Fix internet check --- awbot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awbot.py b/awbot.py index 3ae419e..131f57f 100644 --- a/awbot.py +++ b/awbot.py @@ -28,7 +28,7 @@ def main(): os.system('cls' if os.name == 'nt' else 'clear') # check internet connection - conn = httplib.HTTPConnection("8.8.8.8", timeout = 5) + conn = httplib.HTTPConnection("https://www.google.com", timeout = 5) try: print("Internet check.") conn.request("HEAD", "/") From 4fd8ae652e3c4b162ee0c7ab7a7a01543b1ab9f6 Mon Sep 17 00:00:00 2001 From: theDebonair Date: Tue, 14 Jun 2022 12:42:26 +0530 Subject: [PATCH 29/80] Fix internet check --- awbot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awbot.py b/awbot.py index 131f57f..166f4ea 100644 --- a/awbot.py +++ b/awbot.py @@ -28,7 +28,7 @@ def main(): os.system('cls' if os.name == 'nt' else 'clear') # check internet connection - conn = httplib.HTTPConnection("https://www.google.com", timeout = 5) + conn = httplib.HTTPConnection("1.1.1.1", timeout = 10) try: print("Internet check.") conn.request("HEAD", "/") From d93e016a51637d2ac7dad181bdc0cfb0090bffbf Mon Sep 17 00:00:00 2001 From: theDebonair Date: Tue, 14 Jun 2022 13:48:23 +0530 Subject: [PATCH 30/80] Fixed window position, optimized code --- awbot.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/awbot.py b/awbot.py index 166f4ea..cfe680a 100644 --- a/awbot.py +++ b/awbot.py @@ -90,7 +90,6 @@ def main(): chrome_options.add_argument("--ignore-certificate-errors") chrome_options.add_argument("--ignore-certificate-errors-spki-list") chrome_options.add_argument("--ignore-ssl-errors") - chrome_options.add_argument("--window-size=0,180") chrome_options.add_argument("--mute-audio") # when there is already a persistent session, you may activate headless mode @@ -107,7 +106,7 @@ def main(): try: driver = webdriver.Chrome( service=Service(ChromeDriverManager().install()), - options=chrome_options, + options=chrome_options ) except TypeError: print("\nPlease update your selenium package.") @@ -131,6 +130,12 @@ def main(): # save current window handle main_window = driver.current_window_handle + # move the window to the top left of the primary monitor + driver.set_window_position(0, 0) + + # set window size + driver.set_window_size(585, 164) + # make GET request driver.get(url) @@ -163,6 +168,9 @@ def main(): # main bot loop for loop_count in count(1): + # minimize window + driver.minimize_window() + # clear terminal os.system('cls' if os.name == 'nt' else 'clear') try: @@ -307,6 +315,15 @@ def main(): if this_window != main_window: print("\tSwitching to pop-up window.") driver.switch_to.window(this_window) + + # move the window to the top left of the primary monitor + driver.set_window_position(0, 0) + + # set window size + driver.set_window_size(585, 164) + + # minimize window + driver.minimize_window() break # wait for approve button to be visible & click button From fcac52f6c08a205514de782ab96a5a9bbb638cbb Mon Sep 17 00:00:00 2001 From: theDebonair Date: Tue, 14 Jun 2022 13:52:40 +0530 Subject: [PATCH 31/80] Fixed code formatting --- awbot.py | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/awbot.py b/awbot.py index cfe680a..71a7975 100644 --- a/awbot.py +++ b/awbot.py @@ -104,10 +104,7 @@ def main(): # instantiate Chrome driver with given Chrome options try: - driver = webdriver.Chrome( - service=Service(ChromeDriverManager().install()), - options=chrome_options - ) + driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=chrome_options) except TypeError: print("\nPlease update your selenium package.") driver.quit() @@ -117,15 +114,7 @@ def main(): driver.set_page_load_timeout(60) # instantiate stealth - stealth( - driver, - languages=["en-US", "en"], - vendor="Google Inc.", - platform="Win32", - webgl_vendor="Intel Inc.", - renderer="Intel Iris OpenGL Engine", - fix_hairline=True, - ) + stealth(driver, languages=["en-US", "en"], vendor="Google Inc.", platform="Win32", webgl_vendor="Intel Inc.", renderer="Intel Iris OpenGL Engine", fix_hairline=True) # save current window handle main_window = driver.current_window_handle From ef78ae5050a87c3e94e7fcc1300fe36f152a145f Mon Sep 17 00:00:00 2001 From: theDebonair Date: Tue, 14 Jun 2022 16:46:26 +0530 Subject: [PATCH 32/80] Added notification on termination, etc. --- awbot.py | 158 ++++++++++++++++++++++++++++++++--------------- requirements.txt | 1 + 2 files changed, 108 insertions(+), 51 deletions(-) diff --git a/awbot.py b/awbot.py index 71a7975..517d062 100644 --- a/awbot.py +++ b/awbot.py @@ -6,6 +6,8 @@ import pathlib import http.client as httplib from itertools import count +from turtle import title +from plyer import notification from selenium import webdriver from selenium.webdriver.chrome.options import Options from selenium.webdriver.chrome.service import Service @@ -17,12 +19,12 @@ from webdriver_manager.chrome import ChromeDriverManager from awapi import Account +path = os.path.dirname(__file__) def _print_(text: str) -> None: sys.stdout.write(text) sys.stdout.flush() - def main(): # clear terminal os.system('cls' if os.name == 'nt' else 'clear') @@ -34,6 +36,15 @@ def main(): conn.request("HEAD", "/") conn.close() print("Internet available.") + + except KeyboardInterrupt: + print("\nStopping bot.") + + # notification for termination + notification.notify(title = os.path.basename(path) + "\\" + os.path.basename(__file__), message = "Script Terminated.") + driver.quit() + sys.exit(0) + except: conn.close() print("No Internet. Re-checking in 30 seconds.") @@ -45,33 +56,42 @@ def main(): # define game url url = "https://play.alienworlds.io" - # check for account.txt file - if os.path.exists("account.txt"): + try: + # check for account.txt file + if os.path.exists("account.txt"): - # check for file size & read - if os.stat("account.txt").st_size != 0: - afile = open("account.txt", "r") - wallet = afile.read() - afile.close() + # check for file size & read + if os.stat("account.txt").st_size != 0: + afile = open("account.txt", "r") + wallet = afile.read() + afile.close() - # delete the file if found empty account.txt file + # delete the file if found empty account.txt file + else: + print("\nDeleting corrupted \"account.txt\".") + os.remove("account.txt") + time.sleep(1) + print("File deleted.") + print("Restarting bot.") + time.sleep(1) + return + + # create account.txt file if not found else: - print("\nDeleting corrupted \"account.txt\".") - os.remove("account.txt") - time.sleep(1) - print("File deleted.") + anfile = open("account.txt", "w") + anfile.write(input("\nPlease enter your wax wallet address: ")) + anfile.close() print("Restarting bot.") time.sleep(1) return + + except KeyboardInterrupt: + print("\nStopping bot.") - # create account.txt file if not found - else: - anfile = open("account.txt", "w") - anfile.write(input("\nPlease enter your wax wallet address: ")) - anfile.close() - print("Restarting bot.") - time.sleep(1) - return + # notification for termination + notification.notify(title = os.path.basename(path) + "\\" + os.path.basename(__file__), message = "Script Terminated.") + driver.quit() + sys.exit(0) # create AW Account instance aw = Account(wallet) @@ -105,10 +125,27 @@ def main(): # instantiate Chrome driver with given Chrome options try: driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=chrome_options) + except TypeError: print("\nPlease update your selenium package.") + + # notification for termination + notification.notify(title = os.path.basename(path) + "\\" + os.path.basename(__file__), message = "Script Terminated.") driver.quit() sys.exit(0) + + except KeyboardInterrupt: + print("\nStopping bot.") + + # notification for termination + notification.notify(title = os.path.basename(path) + "\\" + os.path.basename(__file__), message = "Script Terminated.") + driver.quit() + sys.exit(0) + + except: + print("\nBot encountered an error. Restarting.") + time.sleep(1) + return # change page load timeout driver.set_page_load_timeout(60) @@ -119,29 +156,41 @@ def main(): # save current window handle main_window = driver.current_window_handle - # move the window to the top left of the primary monitor + # move the main window to the top left of the primary monitor driver.set_window_position(0, 0) - # set window size + # set main window size driver.set_window_size(585, 164) # make GET request driver.get(url) - # check for sign.file file - if os.path.exists("sign.file"): - print("\nStarting bot in 10 seconds. Delete \"sign.file\" in case of re-login.") - for x in range(10): - time.sleep(1) - _print_(".") + try: + # check for sign.file file + if os.path.exists("sign.file"): + print("\nStarting bot in 10 seconds. Delete \"sign.file\" in case of re-login.") + for x in range(10): + time.sleep(1) + _print_(".") - # create sign.file if not found - else: - print("\nPausing bot.") - input("Please sign-in .Then, press any key to continue.") - open("sign.file", "a").close() + # create sign.file if not found + else: + print("\nPausing bot.") + input("Please sign-in .Then, press any key to continue.") + open("sign.file", "a").close() + + print("\nStarting bot, press \"Ctrl + C\" to stop.") + + except KeyboardInterrupt: + print("\nStopping bot.") + + # notification for termination + notification.notify(title = os.path.basename(path) + "\\" + os.path.basename(__file__), message = "Script Terminated.") + driver.quit() + sys.exit(0) - print("\nStarting bot, press \"Ctrl + C\" to stop.") + # minimizes the main window + driver.minimize_window() # initialize mine loop count mine_loop_count = 0 @@ -157,11 +206,9 @@ def main(): # main bot loop for loop_count in count(1): - # minimize window - driver.minimize_window() - # clear terminal os.system('cls' if os.name == 'nt' else 'clear') + try: # fetch cpu usage details cpu_usage = aw.cpu_usage @@ -192,7 +239,6 @@ def main(): # show tlm mined per click if i: try: - # to find the value of tlm mined tlm_new = aw.tlm_balance tlm_mined = tlm_new - tlm_old @@ -269,11 +315,6 @@ def main(): try: mine_btn = driver.find_element(By.XPATH, "//span[contains(text(), 'Mine')]") - except KeyboardInterrupt: - print("\nStopping bot.") - driver.quit() - sys.exit(0) - # if button is not found except NoSuchElementException: time.sleep(1) @@ -305,13 +346,13 @@ def main(): print("\tSwitching to pop-up window.") driver.switch_to.window(this_window) - # move the window to the top left of the primary monitor + # move the pop-up window to the top left of the primary monitor driver.set_window_position(0, 0) - # set window size + # set pop-up window size driver.set_window_size(585, 164) - # minimize window + # minimizes the pop-up window driver.minimize_window() break @@ -333,6 +374,9 @@ def main(): print("\n\tSwitching back to main window.") driver.switch_to.window(main_window) + # minimizes the main window + driver.minimize_window() + # show the number of loops done print(f"\nTotal number of execution(s): {loop_count}") @@ -350,6 +394,9 @@ def main(): except KeyboardInterrupt: print("\nStopping bot.") + + # notification for termination + notification.notify(title = os.path.basename(path) + "\\" + os.path.basename(__file__), message = "Script Terminated.") driver.quit() sys.exit(0) @@ -358,12 +405,21 @@ def main(): print("\nBot encountered an error. Restarting.") return + # notification for termination + notification.notify(title = os.path.basename(path) + "\\" + os.path.basename(__file__), message = "Script Terminated.") + # close the webdriver & exit driver.quit() - + sys.exit(0) while True: - assert sys.version_info >= (3, 6), 'Python 3.6+ required.' + assert sys.version_info >= (3, 6), "Python 3.6+ required." - # call main routine - main() + try: + # call main routine + main() + + except: + # notification for termination + notification.notify(title = os.path.basename(path) + "\\" + os.path.basename(__file__), message = "Script Terminated.") + sys.exit(0) diff --git a/requirements.txt b/requirements.txt index b0abf54..8ae7a29 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,6 +8,7 @@ h11==0.13.0 idna==3.3 lxml==4.9.0 outcome==1.1.0 +plyer==2.0.0 pycparser==2.21 pyOpenSSL==22.0.0 PySocks==1.7.1 From 8b500c40c5b5fb4ddf09c22cafe0a5a745520fbf Mon Sep 17 00:00:00 2001 From: theDebonair Date: Tue, 14 Jun 2022 17:11:19 +0530 Subject: [PATCH 33/80] Updated run.ps1 --- run.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/run.ps1 b/run.ps1 index a4e99c2..00d05a1 100644 --- a/run.ps1 +++ b/run.ps1 @@ -11,5 +11,8 @@ Do { } } While($temp -eq 'False') +# installing/updating dependencies +pip install -r requirements.txt + # to run the bot py awbot.py; \ No newline at end of file From 03e172e8fd1f2ddf25e59ec249cf7a01fb1c9e54 Mon Sep 17 00:00:00 2001 From: theDebonair Date: Tue, 14 Jun 2022 19:47:09 +0530 Subject: [PATCH 34/80] Fixed basic errors --- awbot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/awbot.py b/awbot.py index 517d062..69cc488 100644 --- a/awbot.py +++ b/awbot.py @@ -241,12 +241,12 @@ def main(): try: # to find the value of tlm mined tlm_new = aw.tlm_balance - tlm_mined = tlm_new - tlm_old + tlm_mined = abs(tlm_new) - abs(tlm_old) print(f"TLM mined in last claim: {tlm_mined:.4f}") tlm_old = tlm_new # to find average rate of tlm mining - tlm_sum += tlm_mined + tlm_sum += abs(tlm_mined) avg = tlm_sum/mine_loop_count average = abs(avg) print(f"Average rate for TLM mining: {average:.4f}/claim") From 2ce5483a3d223356a70be2737baebf4b94588f90 Mon Sep 17 00:00:00 2001 From: theDebonair Date: Wed, 15 Jun 2022 17:42:20 +0530 Subject: [PATCH 35/80] Improved approve button error handling, crashes --- awbot.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/awbot.py b/awbot.py index 69cc488..f0f4011 100644 --- a/awbot.py +++ b/awbot.py @@ -25,6 +25,9 @@ def _print_(text: str) -> None: sys.stdout.write(text) sys.stdout.flush() +# initialize crash count +crashes = 0 + def main(): # clear terminal os.system('cls' if os.name == 'nt' else 'clear') @@ -368,7 +371,9 @@ def main(): # if approve button could not be found else: - raise IOError('\n\tUnable to load or find approve button.') + notification.notify(title = os.path.basename(path) + "\\" + os.path.basename(__file__), message = "Unable to load or find approve button.") + input('\n\tUnable to load or find approve button. Delete \"sign.file\" in case of re-login, then press any key to continue.') + return # go control back to main window print("\n\tSwitching back to main window.") @@ -402,7 +407,8 @@ def main(): # if any error occured except: - print("\nBot encountered an error. Restarting.") + crashes += 1 + print(f"\nBot encountered an error. {crashes} crashes since start. Restarting.") return # notification for termination From b14f01576ff598b140b706d87a7363263313fee0 Mon Sep 17 00:00:00 2001 From: theDebonair Date: Wed, 15 Jun 2022 20:18:45 +0530 Subject: [PATCH 36/80] Fixed bugs --- awbot.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/awbot.py b/awbot.py index f0f4011..544e7f6 100644 --- a/awbot.py +++ b/awbot.py @@ -421,11 +421,5 @@ def main(): while True: assert sys.version_info >= (3, 6), "Python 3.6+ required." - try: - # call main routine - main() - - except: - # notification for termination - notification.notify(title = os.path.basename(path) + "\\" + os.path.basename(__file__), message = "Script Terminated.") - sys.exit(0) + # call main routine + main() From ca7c41eefda6092756fd5e2491052158129d3082 Mon Sep 17 00:00:00 2001 From: theDebonair Date: Wed, 15 Jun 2022 21:07:19 +0530 Subject: [PATCH 37/80] Bug fixes --- awbot.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/awbot.py b/awbot.py index 544e7f6..ba141d1 100644 --- a/awbot.py +++ b/awbot.py @@ -412,11 +412,10 @@ def main(): return # notification for termination - notification.notify(title = os.path.basename(path) + "\\" + os.path.basename(__file__), message = "Script Terminated.") + notification.notify(title = os.path.basename(path) + "\\" + os.path.basename(__file__), message = "Script Restarted.") # close the webdriver & exit driver.quit() - sys.exit(0) while True: assert sys.version_info >= (3, 6), "Python 3.6+ required." From acdb1dbfd9b774898a2495d871c609dbaf2f9d47 Mon Sep 17 00:00:00 2001 From: theDebonair Date: Wed, 22 Jun 2022 13:29:44 +0530 Subject: [PATCH 38/80] Miscellaneous changes --- awbot.py | 162 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 89 insertions(+), 73 deletions(-) diff --git a/awbot.py b/awbot.py index ba141d1..8a22351 100644 --- a/awbot.py +++ b/awbot.py @@ -5,8 +5,8 @@ import random import pathlib import http.client as httplib +from datetime import datetime from itertools import count -from turtle import title from plyer import notification from selenium import webdriver from selenium.webdriver.chrome.options import Options @@ -14,20 +14,23 @@ from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as ec -from selenium.common.exceptions import * +from selenium.common.exceptions import NoSuchElementException from selenium_stealth import stealth from webdriver_manager.chrome import ChromeDriverManager from awapi import Account +# save starting time of the script +start = datetime.now() + path = os.path.dirname(__file__) +# variable as condition to exit script +exit = False + def _print_(text: str) -> None: sys.stdout.write(text) sys.stdout.flush() -# initialize crash count -crashes = 0 - def main(): # clear terminal os.system('cls' if os.name == 'nt' else 'clear') @@ -42,11 +45,9 @@ def main(): except KeyboardInterrupt: print("\nStopping bot.") - - # notification for termination - notification.notify(title = os.path.basename(path) + "\\" + os.path.basename(__file__), message = "Script Terminated.") + exit = True driver.quit() - sys.exit(0) + exit() except: conn.close() @@ -90,11 +91,9 @@ def main(): except KeyboardInterrupt: print("\nStopping bot.") - - # notification for termination - notification.notify(title = os.path.basename(path) + "\\" + os.path.basename(__file__), message = "Script Terminated.") + exit = True driver.quit() - sys.exit(0) + exit() # create AW Account instance aw = Account(wallet) @@ -128,45 +127,44 @@ def main(): # instantiate Chrome driver with given Chrome options try: driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=chrome_options) + + # minimizes the main window + driver.minimize_window() except TypeError: print("\nPlease update your selenium package.") - - # notification for termination - notification.notify(title = os.path.basename(path) + "\\" + os.path.basename(__file__), message = "Script Terminated.") + exit = True driver.quit() - sys.exit(0) + exit() except KeyboardInterrupt: print("\nStopping bot.") - - # notification for termination - notification.notify(title = os.path.basename(path) + "\\" + os.path.basename(__file__), message = "Script Terminated.") + exit = True driver.quit() - sys.exit(0) + exit() except: print("\nBot encountered an error. Restarting.") time.sleep(1) return - # change page load timeout - driver.set_page_load_timeout(60) - # instantiate stealth stealth(driver, languages=["en-US", "en"], vendor="Google Inc.", platform="Win32", webgl_vendor="Intel Inc.", renderer="Intel Iris OpenGL Engine", fix_hairline=True) # save current window handle main_window = driver.current_window_handle + + # change page load timeout + driver.set_page_load_timeout(60) - # move the main window to the top left of the primary monitor - driver.set_window_position(0, 0) + # make GET request + driver.get(url) # set main window size driver.set_window_size(585, 164) - # make GET request - driver.get(url) + # move the main window to the top left of the primary monitor + driver.set_window_position(0, 0) try: # check for sign.file file @@ -179,21 +177,17 @@ def main(): # create sign.file if not found else: print("\nPausing bot.") - input("Please sign-in .Then, press any key to continue.") + notification.notify(title = os.path.basename(path) + "\\" + os.path.basename(__file__), message = "Sign-in required.") + input("Please sign-in, then press any key to continue.") open("sign.file", "a").close() print("\nStarting bot, press \"Ctrl + C\" to stop.") except KeyboardInterrupt: print("\nStopping bot.") - - # notification for termination - notification.notify(title = os.path.basename(path) + "\\" + os.path.basename(__file__), message = "Script Terminated.") + exit = True driver.quit() - sys.exit(0) - - # minimizes the main window - driver.minimize_window() + exit() # initialize mine loop count mine_loop_count = 0 @@ -235,27 +229,30 @@ def main(): print("NET: [ {:,} / {:,} B ]\tUsed: {} %".format(net_used, net_max, net_pct)) print("RAM: [ {:,} / {:,} B ]\tUsed: {} %".format(ram_used, ram_max, ram_pct)) + tlm_new = aw.tlm_balance + # show balances print(f"\nWAX Balance: {aw.wax_balance}") - print(f"TLM Balance: {aw.tlm_balance}") + print(f"TLM Balance: {tlm_new}") # show tlm mined per click - if i: + if i and tlm_old < tlm_new: try: + # to find the value of tlm mined - tlm_new = aw.tlm_balance - tlm_mined = abs(tlm_new) - abs(tlm_old) + tlm_mined = tlm_new - tlm_old print(f"TLM mined in last claim: {tlm_mined:.4f}") tlm_old = tlm_new # to find average rate of tlm mining - tlm_sum += abs(tlm_mined) + tlm_sum += tlm_mined avg = tlm_sum/mine_loop_count - average = abs(avg) - print(f"Average rate for TLM mining: {average:.4f}/claim") + print(f"Average rate for TLM mining: {avg:.4f}/claim") # to show sum of tlm mined print(f"Total TLM mined in this session: {tlm_sum:.4f}") + print("This session started at: {start}") + except: print("\nUnable to retrieve the value(s).") @@ -341,38 +338,42 @@ def main(): # wait for pop-up window print("\n\tSearching for pop-up window.") - time.sleep(3) + + # Wait for the new window or tab + WebDriverWait(driver, 60).until(ec.number_of_windows_to_be(2)) # switch control to pop-up window for this_window in driver.window_handles: if this_window != main_window: print("\tSwitching to pop-up window.") driver.switch_to.window(this_window) - - # move the pop-up window to the top left of the primary monitor - driver.set_window_position(0, 0) - - # set pop-up window size - driver.set_window_size(585, 164) # minimizes the pop-up window driver.minimize_window() + + # set pop-up window size + driver.set_window_size(585, 164) + + # move the pop-up window to the top left of the primary monitor + driver.set_window_position(0, 0) break - # wait for approve button to be visible & click button - btn = WebDriverWait(driver, 60).until(ec.visibility_of_element_located((By.XPATH, "//*[contains(text(), 'Approve')]"))) + try: - # if approve button is found - if btn: - print("\n\tFound \"Approve\" button!") - btn.click() - print("\tApproving transaction.") - mine_loop_count += 1 + # wait for approve button to be visible & click button + btn = WebDriverWait(driver, 60).until(ec.visibility_of_element_located((By.XPATH, "//*[contains(text(), 'Approve')]"))) - # if approve button could not be found - else: - notification.notify(title = os.path.basename(path) + "\\" + os.path.basename(__file__), message = "Unable to load or find approve button.") - input('\n\tUnable to load or find approve button. Delete \"sign.file\" in case of re-login, then press any key to continue.') + # if button found then it'll be clicked + if btn: + print("\n\tFound \"Approve\" button!") + btn.click() + print("\tApproving transaction.") + mine_loop_count += 1 + + except: + notification.notify(title = os.path.basename(path) + "\\" + os.path.basename(__file__), message = "Unable to load or find \"Approve\" button.") + input('\n\tUnable to load or find \"Approve\" button. Delete \"sign.file\" in case of re-login, then press any key to continue.') + exit = True return # go control back to main window @@ -388,6 +389,8 @@ def main(): # show the number of loops done print(f"Total number of approval(s): {mine_loop_count}") + i = True + # delay the bot before starting next loop delay = random.randint(delay_min, delay_max) print(f"\nSleeping for {delay} seconds.") @@ -395,24 +398,20 @@ def main(): time.sleep(1) _print_(".") print("Done sleeping.") - i = True except KeyboardInterrupt: print("\nStopping bot.") - - # notification for termination - notification.notify(title = os.path.basename(path) + "\\" + os.path.basename(__file__), message = "Script Terminated.") + exit = True driver.quit() - sys.exit(0) + exit() # if any error occured except: - crashes += 1 - print(f"\nBot encountered an error. {crashes} crashes since start. Restarting.") + print("\nBot encountered an error. Restarting.") return - # notification for termination - notification.notify(title = os.path.basename(path) + "\\" + os.path.basename(__file__), message = "Script Restarted.") + # notification for script restart + notification.notify(title = os.path.basename(path) + "\\" + os.path.basename(__file__), message = "Script restarted.") # close the webdriver & exit driver.quit() @@ -420,5 +419,22 @@ def main(): while True: assert sys.version_info >= (3, 6), "Python 3.6+ required." - # call main routine - main() + try: + if not exit: + + # call main routine + main() + + else: + + # notification for termination + notification.notify(title = os.path.basename(path) + "\\" + os.path.basename(__file__), message = "Script terminated.") + print("\nScript terminated.") + os._exit(0) + + except: + + # notification for termination + notification.notify(title = os.path.basename(path) + "\\" + os.path.basename(__file__), message = "Script unable to restart.") + print("\nScript cannot be restarted due to an unknown error.") + os._exit(0) From f6a95a0d13628cf04efb59a927799a9dc6350289 Mon Sep 17 00:00:00 2001 From: theDebonair Date: Wed, 22 Jun 2022 16:11:57 +0530 Subject: [PATCH 39/80] Updates --- awbot.py | 29 +++++++++++++++-------------- requirements.txt | 1 + 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/awbot.py b/awbot.py index 8a22351..94e8f7d 100644 --- a/awbot.py +++ b/awbot.py @@ -5,7 +5,8 @@ import random import pathlib import http.client as httplib -from datetime import datetime +import datetime +import pytz from itertools import count from plyer import notification from selenium import webdriver @@ -20,7 +21,7 @@ from awapi import Account # save starting time of the script -start = datetime.now() +start = datetime.datetime.now(pytz.timezone('Asia/Kolkata')) path = os.path.dirname(__file__) @@ -127,9 +128,6 @@ def main(): # instantiate Chrome driver with given Chrome options try: driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=chrome_options) - - # minimizes the main window - driver.minimize_window() except TypeError: print("\nPlease update your selenium package.") @@ -159,12 +157,15 @@ def main(): # make GET request driver.get(url) + + # move the main window to the top left of the primary monitor + driver.set_window_position(7680, 0) # set main window size driver.set_window_size(585, 164) - - # move the main window to the top left of the primary monitor - driver.set_window_position(0, 0) + + # minimizes the main window + driver.minimize_window() try: # check for sign.file file @@ -347,15 +348,15 @@ def main(): if this_window != main_window: print("\tSwitching to pop-up window.") driver.switch_to.window(this_window) - - # minimizes the pop-up window - driver.minimize_window() + + # move the pop-up window to the top left of the primary monitor + driver.set_window_position(7680, 0) # set pop-up window size driver.set_window_size(585, 164) - - # move the pop-up window to the top left of the primary monitor - driver.set_window_position(0, 0) + + # minimizes the pop-up window + driver.minimize_window() break try: diff --git a/requirements.txt b/requirements.txt index 8ae7a29..971c656 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,6 +13,7 @@ pycparser==2.21 pyOpenSSL==22.0.0 PySocks==1.7.1 python-dotenv==0.20.0 +pytz==2022.1 requests==2.27.1 selenium==4.2.0 selenium-stealth==1.0.6 From 9c62b70332230c5acc8e14c6d7434e9941cf307e Mon Sep 17 00:00:00 2001 From: theDebonair Date: Thu, 23 Jun 2022 16:05:25 +0530 Subject: [PATCH 40/80] Updated --- awbot.py | 75 +++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 52 insertions(+), 23 deletions(-) diff --git a/awbot.py b/awbot.py index 94e8f7d..d52062e 100644 --- a/awbot.py +++ b/awbot.py @@ -33,6 +33,8 @@ def _print_(text: str) -> None: sys.stdout.flush() def main(): + global exit + # clear terminal os.system('cls' if os.name == 'nt' else 'clear') @@ -47,8 +49,7 @@ def main(): except KeyboardInterrupt: print("\nStopping bot.") exit = True - driver.quit() - exit() + return except: conn.close() @@ -93,8 +94,7 @@ def main(): except KeyboardInterrupt: print("\nStopping bot.") exit = True - driver.quit() - exit() + return # create AW Account instance aw = Account(wallet) @@ -132,14 +132,12 @@ def main(): except TypeError: print("\nPlease update your selenium package.") exit = True - driver.quit() - exit() + return except KeyboardInterrupt: print("\nStopping bot.") exit = True - driver.quit() - exit() + return except: print("\nBot encountered an error. Restarting.") @@ -159,7 +157,7 @@ def main(): driver.get(url) # move the main window to the top left of the primary monitor - driver.set_window_position(7680, 0) + driver.set_window_position(1920, 0) # set main window size driver.set_window_size(585, 164) @@ -188,7 +186,7 @@ def main(): print("\nStopping bot.") exit = True driver.quit() - exit() + return # initialize mine loop count mine_loop_count = 0 @@ -233,8 +231,8 @@ def main(): tlm_new = aw.tlm_balance # show balances - print(f"\nWAX Balance: {aw.wax_balance}") - print(f"TLM Balance: {tlm_new}") + print(f"\nWAX Balance: {aw.wax_balance:.4f}") + print(f"TLM Balance: {tlm_new:.4f}") # show tlm mined per click if i and tlm_old < tlm_new: @@ -289,6 +287,7 @@ def main(): print("File deleted.") print("Restarting bot.") time.sleep(1) + driver.quit() return # delete the file if found empty throttle.txt file @@ -299,6 +298,7 @@ def main(): print("File deleted.") print("Restarting bot.") time.sleep(1) + driver.quit() return # create throttle.txt file if not found @@ -306,6 +306,7 @@ def main(): ntfile = open("throttle.txt", "w") ntfile.write(input("\nDo you want to enable the bot resource(s) throttling [Y/N]: ")) ntfile.close() + driver.quit() return # wait for mine button to be found @@ -350,7 +351,7 @@ def main(): driver.switch_to.window(this_window) # move the pop-up window to the top left of the primary monitor - driver.set_window_position(7680, 0) + driver.set_window_position(1920, 0) # set pop-up window size driver.set_window_size(585, 164) @@ -362,7 +363,7 @@ def main(): try: # wait for approve button to be visible & click button - btn = WebDriverWait(driver, 60).until(ec.visibility_of_element_located((By.XPATH, "//*[contains(text(), 'Approve')]"))) + btn = WebDriverWait(driver, 40).until(ec.visibility_of_element_located((By.XPATH, "//*[contains(text(), 'Approve')]"))) # if button found then it'll be clicked if btn: @@ -372,10 +373,37 @@ def main(): mine_loop_count += 1 except: - notification.notify(title = os.path.basename(path) + "\\" + os.path.basename(__file__), message = "Unable to load or find \"Approve\" button.") - input('\n\tUnable to load or find \"Approve\" button. Delete \"sign.file\" in case of re-login, then press any key to continue.') - exit = True - return + + try: + + # wait for cancel button to be visible & click button + btn_can = WebDriverWait(driver, 10).until(ec.visibility_of_element_located((By.XPATH, "//*[contains(text(), 'Cancel')]"))) + + # if cancel button found then it'll be clicked + if btn_can: + print("\n\tFound \"Cancel\" button!") + btn_can.click() + print("\tCancelling transaction.") + + except: + + try: + + # wait for login button to be visible + btn_login = WebDriverWait(driver, 10).until(ec.visibility_of_element_located((By.XPATH, "//*[contains(text(), 'Login')]"))) + + # if login button found then print message + if btn_login: + notification.notify(title = os.path.basename(path) + "\\" + os.path.basename(__file__), message = "Script paused. Please \"Login\".") + input("\n\tPlease \"Login\", then press any key to restart.") + driver.quit() + return + + except: + notification.notify(title = os.path.basename(path) + "\\" + os.path.basename(__file__), message = "Script paused. Unable to load or find button(s).") + input('\n\tUnable to load or find button(s). Press any key to restart.') + driver.quit() + return # go control back to main window print("\n\tSwitching back to main window.") @@ -404,17 +432,15 @@ def main(): print("\nStopping bot.") exit = True driver.quit() - exit() + return # if any error occured except: print("\nBot encountered an error. Restarting.") + driver.quit() return - # notification for script restart - notification.notify(title = os.path.basename(path) + "\\" + os.path.basename(__file__), message = "Script restarted.") - - # close the webdriver & exit + # close the webdriver driver.quit() while True: @@ -423,6 +449,9 @@ def main(): try: if not exit: + # notification for script restart + notification.notify(title = os.path.basename(path) + "\\" + os.path.basename(__file__), message = "Script restarted.") + # call main routine main() From 882bdf153e4ee79e5e78f72ceedff5482fa5bdae Mon Sep 17 00:00:00 2001 From: theDebonair Date: Thu, 23 Jun 2022 16:25:39 +0530 Subject: [PATCH 41/80] Minor fixes --- awbot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awbot.py b/awbot.py index d52062e..a3c4f28 100644 --- a/awbot.py +++ b/awbot.py @@ -33,7 +33,7 @@ def _print_(text: str) -> None: sys.stdout.flush() def main(): - global exit + global start, path, exit # clear terminal os.system('cls' if os.name == 'nt' else 'clear') From d927c99dac7d8a021213a59c094080b39302f518 Mon Sep 17 00:00:00 2001 From: theDebonair Date: Thu, 23 Jun 2022 19:30:56 +0530 Subject: [PATCH 42/80] Updated awbot, requirements --- awbot.py | 27 +++++++++------------------ requirements.txt | 1 - 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/awbot.py b/awbot.py index a3c4f28..01a5084 100644 --- a/awbot.py +++ b/awbot.py @@ -5,8 +5,6 @@ import random import pathlib import http.client as httplib -import datetime -import pytz from itertools import count from plyer import notification from selenium import webdriver @@ -20,20 +18,17 @@ from webdriver_manager.chrome import ChromeDriverManager from awapi import Account -# save starting time of the script -start = datetime.datetime.now(pytz.timezone('Asia/Kolkata')) - path = os.path.dirname(__file__) # variable as condition to exit script -exit = False +exit_sc = False def _print_(text: str) -> None: sys.stdout.write(text) sys.stdout.flush() def main(): - global start, path, exit + global path, exit_sc # clear terminal os.system('cls' if os.name == 'nt' else 'clear') @@ -48,7 +43,7 @@ def main(): except KeyboardInterrupt: print("\nStopping bot.") - exit = True + exit_sc = True return except: @@ -93,7 +88,7 @@ def main(): except KeyboardInterrupt: print("\nStopping bot.") - exit = True + exit_sc = True return # create AW Account instance @@ -131,12 +126,12 @@ def main(): except TypeError: print("\nPlease update your selenium package.") - exit = True + exit_sc = True return except KeyboardInterrupt: print("\nStopping bot.") - exit = True + exit_sc = True return except: @@ -184,7 +179,7 @@ def main(): except KeyboardInterrupt: print("\nStopping bot.") - exit = True + exit_sc = True driver.quit() return @@ -250,7 +245,6 @@ def main(): # to show sum of tlm mined print(f"Total TLM mined in this session: {tlm_sum:.4f}") - print("This session started at: {start}") except: print("\nUnable to retrieve the value(s).") @@ -430,7 +424,7 @@ def main(): except KeyboardInterrupt: print("\nStopping bot.") - exit = True + exit_sc = True driver.quit() return @@ -447,10 +441,7 @@ def main(): assert sys.version_info >= (3, 6), "Python 3.6+ required." try: - if not exit: - - # notification for script restart - notification.notify(title = os.path.basename(path) + "\\" + os.path.basename(__file__), message = "Script restarted.") + if not exit_sc: # call main routine main() diff --git a/requirements.txt b/requirements.txt index 971c656..8ae7a29 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,7 +13,6 @@ pycparser==2.21 pyOpenSSL==22.0.0 PySocks==1.7.1 python-dotenv==0.20.0 -pytz==2022.1 requests==2.27.1 selenium==4.2.0 selenium-stealth==1.0.6 From bec2d24bdc326810befe3961f9288c888691db4e Mon Sep 17 00:00:00 2001 From: theDebonair Date: Thu, 23 Jun 2022 23:17:41 +0530 Subject: [PATCH 43/80] Stability optimization --- awbot.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/awbot.py b/awbot.py index 01a5084..fe0d798 100644 --- a/awbot.py +++ b/awbot.py @@ -89,7 +89,12 @@ def main(): except KeyboardInterrupt: print("\nStopping bot.") exit_sc = True - return + return + + except: + print("\nBot encountered an error. Restarting.") + time.sleep(1) + return # create AW Account instance aw = Account(wallet) @@ -183,6 +188,11 @@ def main(): driver.quit() return + except: + print("\nBot encountered an error. Restarting.") + time.sleep(1) + return + # initialize mine loop count mine_loop_count = 0 From c3ed0e91f1cd25232527e1a17fd96a0b8df52493 Mon Sep 17 00:00:00 2001 From: theDebonair Date: Fri, 24 Jun 2022 12:28:29 +0530 Subject: [PATCH 44/80] Minor fixes --- awbot.py | 51 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/awbot.py b/awbot.py index fe0d798..49bd877 100644 --- a/awbot.py +++ b/awbot.py @@ -115,9 +115,6 @@ def main(): chrome_options.add_argument("--ignore-ssl-errors") chrome_options.add_argument("--mute-audio") - # when there is already a persistent session, you may activate headless mode - # chrome_options.add_argument("--headless") - # save current browsing session to make it persistent pwd = pathlib.Path().absolute() chrome_options.add_argument(f"--user-data-dir={pwd}\\chrome-data") @@ -155,9 +152,6 @@ def main(): # make GET request driver.get(url) - - # move the main window to the top left of the primary monitor - driver.set_window_position(1920, 0) # set main window size driver.set_window_size(585, 164) @@ -165,6 +159,9 @@ def main(): # minimizes the main window driver.minimize_window() + # move the main window to the top left of the primary monitor + driver.set_window_position(1920, 0) + try: # check for sign.file file if os.path.exists("sign.file"): @@ -345,24 +342,36 @@ def main(): # wait for pop-up window print("\n\tSearching for pop-up window.") - # Wait for the new window or tab - WebDriverWait(driver, 60).until(ec.number_of_windows_to_be(2)) + # to continue below while loop + switch = False - # switch control to pop-up window - for this_window in driver.window_handles: - if this_window != main_window: - print("\tSwitching to pop-up window.") - driver.switch_to.window(this_window) - - # move the pop-up window to the top left of the primary monitor - driver.set_window_position(1920, 0) + while True: + + if switch: + break - # set pop-up window size - driver.set_window_size(585, 164) + if not switch: + this_window = None - # minimizes the pop-up window - driver.minimize_window() - break + # switch control to pop-up window + for this_window in driver.window_handles: + + if this_window != main_window: + print("\tSwitching to pop-up window.") + driver.switch_to.window(this_window) + + # set pop-up window size + driver.set_window_size(585, 164) + + # minimizes the pop-up window + driver.minimize_window() + + # move the pop-up window to the top left of the primary monitor + driver.set_window_position(1920, 0) + + # to exit while loop + switch = True + break try: From 4d810f24c80a39afd50791012008eb93d868c2d0 Mon Sep 17 00:00:00 2001 From: theDebonair Date: Fri, 24 Jun 2022 13:05:23 +0530 Subject: [PATCH 45/80] Script formatting done --- awbot.py | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/awbot.py b/awbot.py index 49bd877..6090c44 100644 --- a/awbot.py +++ b/awbot.py @@ -35,6 +35,7 @@ def main(): # check internet connection conn = httplib.HTTPConnection("1.1.1.1", timeout = 10) + try: print("Internet check.") conn.request("HEAD", "/") @@ -60,7 +61,6 @@ def main(): try: # check for account.txt file if os.path.exists("account.txt"): - # check for file size & read if os.stat("account.txt").st_size != 0: afile = open("account.txt", "r") @@ -226,9 +226,9 @@ def main(): net_used = net_usage['used'] net_pct = int(net_used / net_max * 100) - print("CPU: [ {:,} / {:,} ms ]\tUsed: {} %".format(cpu_used, cpu_max, cpu_pct)) - print("NET: [ {:,} / {:,} B ]\tUsed: {} %".format(net_used, net_max, net_pct)) - print("RAM: [ {:,} / {:,} B ]\tUsed: {} %".format(ram_used, ram_max, ram_pct)) + print("CPU: [ {:,} / {:,} ms ]\t\tUsed: {} %".format(cpu_used, cpu_max, cpu_pct)) + print("NET: [ {:,} / {:,} B ]\t\tUsed: {} %".format(net_used, net_max, net_pct)) + print("RAM: [ {:,} / {:,} B ]\t\tUsed: {} %".format(ram_used, ram_max, ram_pct)) tlm_new = aw.tlm_balance @@ -239,7 +239,6 @@ def main(): # show tlm mined per click if i and tlm_old < tlm_new: try: - # to find the value of tlm mined tlm_mined = tlm_new - tlm_old print(f"TLM mined in last claim: {tlm_mined:.4f}") @@ -266,7 +265,6 @@ def main(): tfile.close() if throttle == "Y" or throttle == "y": - # resource utilization throttling if (cpu_pct > resource_limit) or (ram_pct > resource_limit) or (net_pct > resource_limit): print("\nResource utilization is above the set threshold of {} %.".format(resource_limit)) @@ -345,8 +343,7 @@ def main(): # to continue below while loop switch = False - while True: - + while True: if switch: break @@ -355,7 +352,6 @@ def main(): # switch control to pop-up window for this_window in driver.window_handles: - if this_window != main_window: print("\tSwitching to pop-up window.") driver.switch_to.window(this_window) @@ -374,7 +370,6 @@ def main(): break try: - # wait for approve button to be visible & click button btn = WebDriverWait(driver, 40).until(ec.visibility_of_element_located((By.XPATH, "//*[contains(text(), 'Approve')]"))) @@ -386,9 +381,7 @@ def main(): mine_loop_count += 1 except: - try: - # wait for cancel button to be visible & click button btn_can = WebDriverWait(driver, 10).until(ec.visibility_of_element_located((By.XPATH, "//*[contains(text(), 'Cancel')]"))) @@ -399,9 +392,7 @@ def main(): print("\tCancelling transaction.") except: - try: - # wait for login button to be visible btn_login = WebDriverWait(driver, 10).until(ec.visibility_of_element_located((By.XPATH, "//*[contains(text(), 'Login')]"))) @@ -461,19 +452,16 @@ def main(): try: if not exit_sc: - # call main routine main() else: - # notification for termination notification.notify(title = os.path.basename(path) + "\\" + os.path.basename(__file__), message = "Script terminated.") print("\nScript terminated.") os._exit(0) except: - # notification for termination notification.notify(title = os.path.basename(path) + "\\" + os.path.basename(__file__), message = "Script unable to restart.") print("\nScript cannot be restarted due to an unknown error.") From ac34d4fda3b5ad15aab5f0892abba99a9ad2dfa9 Mon Sep 17 00:00:00 2001 From: theDebonair Date: Fri, 24 Jun 2022 13:32:54 +0530 Subject: [PATCH 46/80] Updates --- README.md | 2 +- awbot.py | 10 +++++----- run.ps1 | 3 --- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 92f5025..17ef6ce 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ git clone https://github.com/theDebonair/awbot.git cd awbot ``` -- ###### Install all the required Python packages (Globally, not in VirtualEnv). +- ###### Install all the required Python packages. ``` pip install -r requirements.txt ``` diff --git a/awbot.py b/awbot.py index 6090c44..e89592c 100644 --- a/awbot.py +++ b/awbot.py @@ -160,7 +160,7 @@ def main(): driver.minimize_window() # move the main window to the top left of the primary monitor - driver.set_window_position(1920, 0) + driver.set_window_position(1921, 0) try: # check for sign.file file @@ -363,7 +363,7 @@ def main(): driver.minimize_window() # move the pop-up window to the top left of the primary monitor - driver.set_window_position(1920, 0) + driver.set_window_position(1921, 0) # to exit while loop switch = True @@ -371,7 +371,7 @@ def main(): try: # wait for approve button to be visible & click button - btn = WebDriverWait(driver, 40).until(ec.visibility_of_element_located((By.XPATH, "//*[contains(text(), 'Approve')]"))) + btn = WebDriverWait(driver, 60).until(ec.visibility_of_element_located((By.XPATH, "//*[contains(text(), 'Approve')]"))) # if button found then it'll be clicked if btn: @@ -383,7 +383,7 @@ def main(): except: try: # wait for cancel button to be visible & click button - btn_can = WebDriverWait(driver, 10).until(ec.visibility_of_element_located((By.XPATH, "//*[contains(text(), 'Cancel')]"))) + btn_can = WebDriverWait(driver, 15).until(ec.visibility_of_element_located((By.XPATH, "//*[contains(text(), 'Cancel')]"))) # if cancel button found then it'll be clicked if btn_can: @@ -394,7 +394,7 @@ def main(): except: try: # wait for login button to be visible - btn_login = WebDriverWait(driver, 10).until(ec.visibility_of_element_located((By.XPATH, "//*[contains(text(), 'Login')]"))) + btn_login = WebDriverWait(driver, 15).until(ec.visibility_of_element_located((By.XPATH, "//*[contains(text(), 'Login')]"))) # if login button found then print message if btn_login: diff --git a/run.ps1 b/run.ps1 index 00d05a1..a4e99c2 100644 --- a/run.ps1 +++ b/run.ps1 @@ -11,8 +11,5 @@ Do { } } While($temp -eq 'False') -# installing/updating dependencies -pip install -r requirements.txt - # to run the bot py awbot.py; \ No newline at end of file From e2d89ba7f81c101285234304b4d498babb84913b Mon Sep 17 00:00:00 2001 From: theDebonair Date: Fri, 24 Jun 2022 13:42:38 +0530 Subject: [PATCH 47/80] Minor fix --- run.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/run.ps1 b/run.ps1 index a4e99c2..7031290 100644 --- a/run.ps1 +++ b/run.ps1 @@ -7,9 +7,9 @@ Do { .\venv\Scripts\activate $temp = 'True' } else { - py -m venv venv # creating venv + python -m venv venv # creating venv } } While($temp -eq 'False') # to run the bot -py awbot.py; \ No newline at end of file +python awbot.py; \ No newline at end of file From 216bc39a6f818eefbf1b1d26b6457f1febcd0faf Mon Sep 17 00:00:00 2001 From: theDebonair Date: Fri, 24 Jun 2022 15:37:47 +0530 Subject: [PATCH 48/80] Update --- README.md | 18 ++---------------- run.ps1 | 15 --------------- 2 files changed, 2 insertions(+), 31 deletions(-) delete mode 100644 run.ps1 diff --git a/README.md b/README.md index 17ef6ce..010a27a 100644 --- a/README.md +++ b/README.md @@ -19,21 +19,12 @@ cd awbot pip install -r requirements.txt ``` -### Recommendations -- ###### Use VirtualEnv for different instances of the bot, -- ###### Use high speed internet for better and error-free functionality. - -### Running Instructions (For Windows users) -- ###### After all the dependencies have been downloaded and installed, simply run "run.ps1" from powershell. -``` -run.ps1 -``` - -### Running Instructions (For non-Windows users) +### Running Instructions - ###### After all the dependencies have been downloaded and installed, simply run "awbot.py". ``` python awbot.py ``` + ### Attention ###### Using bot or any kind of automation is not recommended by the Aliens World. I'm not responsible for any kind of your loss(es). USE AT YOUR OWN RISK! @@ -42,9 +33,4 @@ python awbot.py - ###### On the first run you need to login to your wax account, on the succeeding runs you will be logged in automatically as the session cookies will be saved. - ###### Follow the prompts in the command terminal. - ###### You must open the terminal in the same directory where the files are stored. -- ###### For Windows users, VirtualEnv will be created automatically when following the above instructions. -- ###### For non- Windows users, please create a VirtualEnv. -``` -python -m venv venv -``` - ###### Feel free to make suggestions, report bugs on this project's [discussions](https://github.com/theDebonair/awbot/discussions) tab. diff --git a/run.ps1 b/run.ps1 deleted file mode 100644 index 7031290..0000000 --- a/run.ps1 +++ /dev/null @@ -1,15 +0,0 @@ -$temp = 'False' -$Folder = '.\venv' - -Do { - # checking for venv dir - if (Test-Path -Path $Folder) { - .\venv\Scripts\activate - $temp = 'True' - } else { - python -m venv venv # creating venv - } -} While($temp -eq 'False') - -# to run the bot -python awbot.py; \ No newline at end of file From 38e9cd80c9477bdd9473c95bfc63a99d9f7136ce Mon Sep 17 00:00:00 2001 From: theDebonair Date: Fri, 24 Jun 2022 15:58:40 +0530 Subject: [PATCH 49/80] Code optimized --- awbot.py | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/awbot.py b/awbot.py index e89592c..22f000a 100644 --- a/awbot.py +++ b/awbot.py @@ -125,6 +125,27 @@ def main(): # instantiate Chrome driver with given Chrome options try: driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=chrome_options) + + # instantiate stealth + stealth(driver, languages=["en-US", "en"], vendor="Google Inc.", platform="Win32", webgl_vendor="Intel Inc.", renderer="Intel Iris OpenGL Engine", fix_hairline=True) + + # save current window handle + main_window = driver.current_window_handle + + # change page load timeout + driver.set_page_load_timeout(60) + + # make GET request + driver.get(url) + + # set main window size + driver.set_window_size(585, 164) + + # minimizes the main window + driver.minimize_window() + + # move the main window to the top left of the primary monitor + driver.set_window_position(1921, 0) except TypeError: print("\nPlease update your selenium package.") @@ -141,27 +162,6 @@ def main(): time.sleep(1) return - # instantiate stealth - stealth(driver, languages=["en-US", "en"], vendor="Google Inc.", platform="Win32", webgl_vendor="Intel Inc.", renderer="Intel Iris OpenGL Engine", fix_hairline=True) - - # save current window handle - main_window = driver.current_window_handle - - # change page load timeout - driver.set_page_load_timeout(60) - - # make GET request - driver.get(url) - - # set main window size - driver.set_window_size(585, 164) - - # minimizes the main window - driver.minimize_window() - - # move the main window to the top left of the primary monitor - driver.set_window_position(1921, 0) - try: # check for sign.file file if os.path.exists("sign.file"): From 583c1d06caca1add9d0d8125abe166828d25a542 Mon Sep 17 00:00:00 2001 From: theDebonair Date: Fri, 24 Jun 2022 20:32:06 +0530 Subject: [PATCH 50/80] Final build --- awbot.py | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/awbot.py b/awbot.py index 22f000a..ac3f142 100644 --- a/awbot.py +++ b/awbot.py @@ -71,10 +71,8 @@ def main(): else: print("\nDeleting corrupted \"account.txt\".") os.remove("account.txt") - time.sleep(1) print("File deleted.") print("Restarting bot.") - time.sleep(1) return # create account.txt file if not found @@ -83,7 +81,6 @@ def main(): anfile.write(input("\nPlease enter your wax wallet address: ")) anfile.close() print("Restarting bot.") - time.sleep(1) return except KeyboardInterrupt: @@ -93,7 +90,6 @@ def main(): except: print("\nBot encountered an error. Restarting.") - time.sleep(1) return # create AW Account instance @@ -159,7 +155,6 @@ def main(): except: print("\nBot encountered an error. Restarting.") - time.sleep(1) return try: @@ -187,7 +182,6 @@ def main(): except: print("\nBot encountered an error. Restarting.") - time.sleep(1) return # initialize mine loop count @@ -282,10 +276,8 @@ def main(): print("\nAppropriate input not found.") print("Deleting corrupted \"throttle.txt\".") os.remove("throttle.txt") - time.sleep(1) print("File deleted.") print("Restarting bot.") - time.sleep(1) driver.quit() return @@ -293,10 +285,8 @@ def main(): else: print("\nDeleting corrupted \"throttle.txt\".") os.remove("throttle.txt") - time.sleep(1) print("File deleted.") print("Restarting bot.") - time.sleep(1) driver.quit() return @@ -356,14 +346,20 @@ def main(): print("\tSwitching to pop-up window.") driver.switch_to.window(this_window) - # set pop-up window size - driver.set_window_size(585, 164) + try: + # set pop-up window size + driver.set_window_size(585, 164) - # minimizes the pop-up window - driver.minimize_window() + # minimizes the pop-up window + driver.minimize_window() + + # move the pop-up window to the top left of the primary monitor + driver.set_window_position(1921, 0) - # move the pop-up window to the top left of the primary monitor - driver.set_window_position(1921, 0) + except: + print("\nBot encountered an error. Restarting.") + driver.quit() + return # to exit while loop switch = True From bb3177869c5775b41b6bd3d8789128d9ee7dd77f Mon Sep 17 00:00:00 2001 From: theDebonair Date: Sun, 26 Jun 2022 23:21:12 +0530 Subject: [PATCH 51/80] Fully supported headless mode --- .gitignore | 3 + README.md | 1 + awbot.py | 191 +++++++++++++++++++++++++++++++++++++++-------------- 3 files changed, 144 insertions(+), 51 deletions(-) diff --git a/.gitignore b/.gitignore index 8b38688..a10c60f 100644 --- a/.gitignore +++ b/.gitignore @@ -146,3 +146,6 @@ sign.file # Throttle file check throttle.txt + +# vscode config files +.vscode diff --git a/README.md b/README.md index 010a27a..934b12b 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ python awbot.py ### PS - ###### "Bot resource(s) throttling" feature disables the check for CPU, NET, RAM usage. This enables the bot to click even when the resources are above 100%. +- ###### "Headless mode" is the mode where browser will completely run in the background without disturbing you. When login will be required, headless mode will be turned OFF automatically. - ###### On the first run you need to login to your wax account, on the succeeding runs you will be logged in automatically as the session cookies will be saved. - ###### Follow the prompts in the command terminal. - ###### You must open the terminal in the same directory where the files are stored. diff --git a/awbot.py b/awbot.py index ac3f142..7e8b045 100644 --- a/awbot.py +++ b/awbot.py @@ -58,6 +58,10 @@ def main(): # define game url url = "https://play.alienworlds.io" + # wax signin page + signin = "https://all-access.wax.io/" + + # for account.txt file try: # check for account.txt file if os.path.exists("account.txt"): @@ -90,7 +94,16 @@ def main(): except: print("\nBot encountered an error. Restarting.") - return + return + + # check for sign.file file + if os.path.exists("sign.file"): + headless = True + sign_file = True + + else: + headless = False + sign_file = False # create AW Account instance aw = Account(wallet) @@ -110,20 +123,37 @@ def main(): chrome_options.add_argument("--ignore-certificate-errors-spki-list") chrome_options.add_argument("--ignore-ssl-errors") chrome_options.add_argument("--mute-audio") + chrome_options.add_argument("user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36") + + # headless mode when signed in + if headless: + # to open in hidden browser window + chrome_options.add_argument("--headless") # save current browsing session to make it persistent pwd = pathlib.Path().absolute() chrome_options.add_argument(f"--user-data-dir={pwd}\\chrome-data") + # for older ChromeDriver under version 79.0.3945.16 chrome_options.add_experimental_option("excludeSwitches", ["enable-automation"]) - chrome_options.add_experimental_option("useAutomationExtension", False) + chrome_options.add_experimental_option('useAutomationExtension', False) + + # for ChromeDriver version 79.0.3945.16 or over + chrome_options.add_argument('--disable-blink-features=AutomationControlled') # instantiate Chrome driver with given Chrome options try: driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=chrome_options) # instantiate stealth - stealth(driver, languages=["en-US", "en"], vendor="Google Inc.", platform="Win32", webgl_vendor="Intel Inc.", renderer="Intel Iris OpenGL Engine", fix_hairline=True) + stealth(driver, + languages=["en-US", "en"], + vendor="Google Inc.", + platform="Win32", + webgl_vendor="Intel Inc.", + renderer="Intel Iris OpenGL Engine", + fix_hairline=True, + ) # save current window handle main_window = driver.current_window_handle @@ -132,16 +162,17 @@ def main(): driver.set_page_load_timeout(60) # make GET request - driver.get(url) - - # set main window size - driver.set_window_size(585, 164) - - # minimizes the main window - driver.minimize_window() + if headless: + driver.get(url) - # move the main window to the top left of the primary monitor - driver.set_window_position(1921, 0) + else: + driver.get(signin) + + print("\nSuccessfully loaded \"{}\".".format(driver.title)) + + if not headless: + # move the main window to the top left of the primary monitor + driver.set_window_position(0, 0) except TypeError: print("\nPlease update your selenium package.") @@ -159,9 +190,9 @@ def main(): try: # check for sign.file file - if os.path.exists("sign.file"): - print("\nStarting bot in 10 seconds. Delete \"sign.file\" in case of re-login.") - for x in range(10): + if sign_file: + print("\nStarting bot in 3 seconds. \n\t- Delete \"sign.file\" in case of re-login. \n\t- Press \"Ctrl + C\" to stop") + for x in range(3): time.sleep(1) _print_(".") @@ -171,8 +202,8 @@ def main(): notification.notify(title = os.path.basename(path) + "\\" + os.path.basename(__file__), message = "Sign-in required.") input("Please sign-in, then press any key to continue.") open("sign.file", "a").close() - - print("\nStarting bot, press \"Ctrl + C\" to stop.") + print("Restarting bot.") + return except KeyboardInterrupt: print("\nStopping bot.") @@ -246,6 +277,12 @@ def main(): # to show sum of tlm mined print(f"Total TLM mined in this session: {tlm_sum:.4f}") + except KeyboardInterrupt: + print("\nStopping bot.") + exit_sc = True + driver.quit() + return + except: print("\nUnable to retrieve the value(s).") @@ -311,21 +348,39 @@ def main(): time.sleep(1) _print_(".") - # if button is found + except KeyboardInterrupt: + print("\nStopping bot.") + exit_sc = True + driver.quit() + return + + # if button is found, then click else: print("\nFound \"Mine\" button!") - - # click mine_btn.click() break # wait for claim button print("\nSearching for \"Claim\" button.") - claim_btn = WebDriverWait(driver, 60).until(ec.visibility_of_element_located((By.XPATH, "//span[contains(text(), 'Claim Mine')]"))) - print("Found \"Claim\" button!") + + try: + claim_btn = WebDriverWait(driver, 60).until(ec.visibility_of_element_located((By.XPATH, "//span[contains(text(), 'Claim Mine')]"))) + print("Found \"Claim\" button!") - # click claim button - claim_btn.click() + # click claim button + claim_btn.click() + + except KeyboardInterrupt: + print("\nStopping bot.") + exit_sc = True + driver.quit() + return + + except: + notification.notify(title = os.path.basename(path) + "\\" + os.path.basename(__file__), message = "Script restarting. Unable to load or find \"Claim\" button.") + print('\n\tUnable to load or find \"Claim\" button. Restarting.') + driver.quit() + return # wait for pop-up window print("\n\tSearching for pop-up window.") @@ -337,27 +392,31 @@ def main(): if switch: break - if not switch: + else: this_window = None # switch control to pop-up window for this_window in driver.window_handles: if this_window != main_window: - print("\tSwitching to pop-up window.") - driver.switch_to.window(this_window) - try: - # set pop-up window size - driver.set_window_size(585, 164) - - # minimizes the pop-up window - driver.minimize_window() - - # move the pop-up window to the top left of the primary monitor - driver.set_window_position(1921, 0) + print("\tSwitching to pop-up window.") + driver.switch_to.window(this_window) + print("\tSwitched successfully to \"{}\".".format(driver.title)) + + # full page screenshot + #total_width = driver.execute_script("return document.body.offsetWidth") + #total_height = driver.execute_script("return document.body.scrollHeight") + #driver.set_window_size(total_width, total_height) + #driver.save_screenshot("sc_popup.png") # image will be saved as "sc_popup.png" in the bot's directory + + except KeyboardInterrupt: + print("\n\tStopping bot.") + exit_sc = True + driver.quit() + return except: - print("\nBot encountered an error. Restarting.") + print("\n\tBot encountered an error. Restarting.") driver.quit() return @@ -365,9 +424,10 @@ def main(): switch = True break + # for pop-up window click(s) try: # wait for approve button to be visible & click button - btn = WebDriverWait(driver, 60).until(ec.visibility_of_element_located((By.XPATH, "//*[contains(text(), 'Approve')]"))) + btn = WebDriverWait(driver, 60).until(ec.visibility_of_element_located((By.XPATH, "//div[contains(text(), 'Approve')]"))) # if button found then it'll be clicked if btn: @@ -376,41 +436,64 @@ def main(): print("\tApproving transaction.") mine_loop_count += 1 + except KeyboardInterrupt: + print("\n\tStopping bot.") + exit_sc = True + driver.quit() + return + except: try: # wait for cancel button to be visible & click button - btn_can = WebDriverWait(driver, 15).until(ec.visibility_of_element_located((By.XPATH, "//*[contains(text(), 'Cancel')]"))) + btn_can = WebDriverWait(driver, 15).until(ec.visibility_of_element_located((By.XPATH, "//div[contains(text(), 'Cancel')]"))) # if cancel button found then it'll be clicked if btn_can: print("\n\tFound \"Cancel\" button!") btn_can.click() print("\tCancelling transaction.") + + except KeyboardInterrupt: + print("\n\tStopping bot.") + exit_sc = True + driver.quit() + return except: try: # wait for login button to be visible - btn_login = WebDriverWait(driver, 15).until(ec.visibility_of_element_located((By.XPATH, "//*[contains(text(), 'Login')]"))) + btn_login = WebDriverWait(driver, 15).until(ec.visibility_of_element_located((By.XPATH, "//div[contains(text(), 'Login')]"))) - # if login button found then print message + # if login button found then print message & restart if btn_login: - notification.notify(title = os.path.basename(path) + "\\" + os.path.basename(__file__), message = "Script paused. Please \"Login\".") - input("\n\tPlease \"Login\", then press any key to restart.") + notification.notify(title = os.path.basename(path) + "\\" + os.path.basename(__file__), message = "Please \"Login\".") + os.remove("sign.file") + print("\n\tRestarting bot.") driver.quit() return + except KeyboardInterrupt: + print("\n\tStopping bot.") + exit_sc = True + driver.quit() + return + except: - notification.notify(title = os.path.basename(path) + "\\" + os.path.basename(__file__), message = "Script paused. Unable to load or find button(s).") - input('\n\tUnable to load or find button(s). Press any key to restart.') + notification.notify(title = os.path.basename(path) + "\\" + os.path.basename(__file__), message = "Script restarting. Unable to load or find button(s).") + print('\n\tUnable to load or find button(s). Restarting.') driver.quit() return # go control back to main window print("\n\tSwitching back to main window.") driver.switch_to.window(main_window) + print("\tSwitched successfully to \"{}\".".format(driver.title)) - # minimizes the main window - driver.minimize_window() + # full page screenshot + #total_width = driver.execute_script("return document.body.offsetWidth") + #total_height = driver.execute_script("return document.body.scrollHeight") + #driver.set_window_size(total_width, total_height) + #driver.save_screenshot("sc_main.png") # image will be saved as "sc_main.png" in the bot's directory # show the number of loops done print(f"\nTotal number of execution(s): {loop_count}") @@ -457,8 +540,14 @@ def main(): print("\nScript terminated.") os._exit(0) + except KeyboardInterrupt: + # notification for termination + notification.notify(title = os.path.basename(path) + "\\" + os.path.basename(__file__), message = "Script terminated.") + print("\nScript terminated.") + os._exit(0) + except: - # notification for termination - notification.notify(title = os.path.basename(path) + "\\" + os.path.basename(__file__), message = "Script unable to restart.") - print("\nScript cannot be restarted due to an unknown error.") - os._exit(0) + # notification for termination + notification.notify(title = os.path.basename(path) + "\\" + os.path.basename(__file__), message = "Script unable to restart.") + print("\nScript cannot be restarted due to an unknown error.") + os._exit(0) From a8450a9f3d30475b27fdd0328b6d16ad62d1e935 Mon Sep 17 00:00:00 2001 From: theDebonair Date: Sun, 26 Jun 2022 23:43:23 +0530 Subject: [PATCH 52/80] Added screenshot feature --- .gitignore | 4 ++++ README.md | 1 + awbot.py | 18 ++++++++++-------- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index a10c60f..e975d08 100644 --- a/.gitignore +++ b/.gitignore @@ -149,3 +149,7 @@ throttle.txt # vscode config files .vscode + +# .png files +sc_main.png +sc_popup.png diff --git a/README.md b/README.md index 934b12b..e8bce91 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,7 @@ python awbot.py ### PS - ###### "Bot resource(s) throttling" feature disables the check for CPU, NET, RAM usage. This enables the bot to click even when the resources are above 100%. - ###### "Headless mode" is the mode where browser will completely run in the background without disturbing you. When login will be required, headless mode will be turned OFF automatically. +- ###### "Screenshots" of the last updated pages now available in the bot's directory. - ###### On the first run you need to login to your wax account, on the succeeding runs you will be logged in automatically as the session cookies will be saved. - ###### Follow the prompts in the command terminal. - ###### You must open the terminal in the same directory where the files are stored. diff --git a/awbot.py b/awbot.py index 7e8b045..847f44b 100644 --- a/awbot.py +++ b/awbot.py @@ -402,12 +402,13 @@ def main(): print("\tSwitching to pop-up window.") driver.switch_to.window(this_window) print("\tSwitched successfully to \"{}\".".format(driver.title)) + time.sleep(5) # full page screenshot - #total_width = driver.execute_script("return document.body.offsetWidth") - #total_height = driver.execute_script("return document.body.scrollHeight") - #driver.set_window_size(total_width, total_height) - #driver.save_screenshot("sc_popup.png") # image will be saved as "sc_popup.png" in the bot's directory + total_width = driver.execute_script("return document.body.offsetWidth") + total_height = driver.execute_script("return document.body.scrollHeight") + driver.set_window_size(total_width, total_height) + driver.save_screenshot("sc_popup.png") # image will be saved as "sc_popup.png" in the bot's directory except KeyboardInterrupt: print("\n\tStopping bot.") @@ -488,12 +489,13 @@ def main(): print("\n\tSwitching back to main window.") driver.switch_to.window(main_window) print("\tSwitched successfully to \"{}\".".format(driver.title)) + time.sleep(5) # full page screenshot - #total_width = driver.execute_script("return document.body.offsetWidth") - #total_height = driver.execute_script("return document.body.scrollHeight") - #driver.set_window_size(total_width, total_height) - #driver.save_screenshot("sc_main.png") # image will be saved as "sc_main.png" in the bot's directory + total_width = driver.execute_script("return document.body.offsetWidth") + total_height = driver.execute_script("return document.body.scrollHeight") + driver.set_window_size(total_width, total_height) + driver.save_screenshot("sc_main.png") # image will be saved as "sc_main.png" in the bot's directory # show the number of loops done print(f"\nTotal number of execution(s): {loop_count}") From 8d4f8ffb7012e35bce349d7f129aa8e7269056c2 Mon Sep 17 00:00:00 2001 From: theDebonair Date: Mon, 27 Jun 2022 11:51:29 +0530 Subject: [PATCH 53/80] Minor fixes and improvements --- awbot.py | 49 ++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 38 insertions(+), 11 deletions(-) diff --git a/awbot.py b/awbot.py index 847f44b..a16cbda 100644 --- a/awbot.py +++ b/awbot.py @@ -357,6 +357,13 @@ def main(): # if button is found, then click else: print("\nFound \"Mine\" button!") + + # full page screenshot + total_width = driver.execute_script("return document.body.offsetWidth") + total_height = driver.execute_script("return document.body.scrollHeight") + driver.set_window_size(total_width, total_height) + driver.save_screenshot("sc_main_mine.png") # image will be saved as "sc_main_mine.png" in the bot's directory + mine_btn.click() break @@ -367,6 +374,12 @@ def main(): claim_btn = WebDriverWait(driver, 60).until(ec.visibility_of_element_located((By.XPATH, "//span[contains(text(), 'Claim Mine')]"))) print("Found \"Claim\" button!") + # full page screenshot + total_width = driver.execute_script("return document.body.offsetWidth") + total_height = driver.execute_script("return document.body.scrollHeight") + driver.set_window_size(total_width, total_height) + driver.save_screenshot("sc_main_claim.png") # image will be saved as "sc_main_claim.png" in the bot's directory + # click claim button claim_btn.click() @@ -402,13 +415,6 @@ def main(): print("\tSwitching to pop-up window.") driver.switch_to.window(this_window) print("\tSwitched successfully to \"{}\".".format(driver.title)) - time.sleep(5) - - # full page screenshot - total_width = driver.execute_script("return document.body.offsetWidth") - total_height = driver.execute_script("return document.body.scrollHeight") - driver.set_window_size(total_width, total_height) - driver.save_screenshot("sc_popup.png") # image will be saved as "sc_popup.png" in the bot's directory except KeyboardInterrupt: print("\n\tStopping bot.") @@ -428,11 +434,18 @@ def main(): # for pop-up window click(s) try: # wait for approve button to be visible & click button - btn = WebDriverWait(driver, 60).until(ec.visibility_of_element_located((By.XPATH, "//div[contains(text(), 'Approve')]"))) + btn = WebDriverWait(driver, 60).until(ec.visibility_of_element_located((By.XPATH, "//*[contains(text(), 'Approve')]"))) # if button found then it'll be clicked if btn: print("\n\tFound \"Approve\" button!") + + # full page screenshot + total_width = driver.execute_script("return document.body.offsetWidth") + total_height = driver.execute_script("return document.body.scrollHeight") + driver.set_window_size(total_width, total_height) + driver.save_screenshot("sc_popup_approve.png") # image will be saved as "sc_popup_approve.png" in the bot's directory + btn.click() print("\tApproving transaction.") mine_loop_count += 1 @@ -446,11 +459,18 @@ def main(): except: try: # wait for cancel button to be visible & click button - btn_can = WebDriverWait(driver, 15).until(ec.visibility_of_element_located((By.XPATH, "//div[contains(text(), 'Cancel')]"))) + btn_can = WebDriverWait(driver, 15).until(ec.visibility_of_element_located((By.XPATH, "//*[contains(text(), 'Cancel')]"))) # if cancel button found then it'll be clicked if btn_can: print("\n\tFound \"Cancel\" button!") + + # full page screenshot + total_width = driver.execute_script("return document.body.offsetWidth") + total_height = driver.execute_script("return document.body.scrollHeight") + driver.set_window_size(total_width, total_height) + driver.save_screenshot("sc_popup_can.png") # image will be saved as "sc_popup_can.png" in the bot's directory + btn_can.click() print("\tCancelling transaction.") @@ -463,11 +483,18 @@ def main(): except: try: # wait for login button to be visible - btn_login = WebDriverWait(driver, 15).until(ec.visibility_of_element_located((By.XPATH, "//div[contains(text(), 'Login')]"))) + btn_login = WebDriverWait(driver, 15).until(ec.visibility_of_element_located((By.XPATH, "//*[contains(text(), 'Login')]"))) # if login button found then print message & restart if btn_login: notification.notify(title = os.path.basename(path) + "\\" + os.path.basename(__file__), message = "Please \"Login\".") + + # full page screenshot + total_width = driver.execute_script("return document.body.offsetWidth") + total_height = driver.execute_script("return document.body.scrollHeight") + driver.set_window_size(total_width, total_height) + driver.save_screenshot("sc_popup_login.png") # image will be saved as "sc_popup_login.png" in the bot's directory + os.remove("sign.file") print("\n\tRestarting bot.") driver.quit() @@ -489,7 +516,7 @@ def main(): print("\n\tSwitching back to main window.") driver.switch_to.window(main_window) print("\tSwitched successfully to \"{}\".".format(driver.title)) - time.sleep(5) + time.sleep(3) # full page screenshot total_width = driver.execute_script("return document.body.offsetWidth") From 129ca6750bd2a767de1e420903dfc9f3ede99be5 Mon Sep 17 00:00:00 2001 From: theDebonair Date: Mon, 27 Jun 2022 12:04:02 +0530 Subject: [PATCH 54/80] Updated --- .gitignore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index e975d08..f9c67df 100644 --- a/.gitignore +++ b/.gitignore @@ -151,5 +151,4 @@ throttle.txt .vscode # .png files -sc_main.png -sc_popup.png +*.png From b77c6d5b772f94c9994b4d0292f14a4b1add4a95 Mon Sep 17 00:00:00 2001 From: theDebonair Date: Wed, 29 Jun 2022 20:46:57 +0530 Subject: [PATCH 55/80] Added JS --- awbot.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/awbot.py b/awbot.py index a16cbda..fa76e5d 100644 --- a/awbot.py +++ b/awbot.py @@ -136,10 +136,10 @@ def main(): # for older ChromeDriver under version 79.0.3945.16 chrome_options.add_experimental_option("excludeSwitches", ["enable-automation"]) - chrome_options.add_experimental_option('useAutomationExtension', False) + chrome_options.add_experimental_option("useAutomationExtension", False) # for ChromeDriver version 79.0.3945.16 or over - chrome_options.add_argument('--disable-blink-features=AutomationControlled') + chrome_options.add_argument("--disable-blink-features=AutomationControlled") # instantiate Chrome driver with given Chrome options try: @@ -167,12 +167,9 @@ def main(): else: driver.get(signin) + driver.set_window_position(0, 0) print("\nSuccessfully loaded \"{}\".".format(driver.title)) - - if not headless: - # move the main window to the top left of the primary monitor - driver.set_window_position(0, 0) except TypeError: print("\nPlease update your selenium package.") @@ -198,6 +195,11 @@ def main(): # create sign.file if not found else: + driver.execute_script(""" + var wallet = arguments[0]; + document.title = wallet; + alert(wallet); + """, wallet) print("\nPausing bot.") notification.notify(title = os.path.basename(path) + "\\" + os.path.basename(__file__), message = "Sign-in required.") input("Please sign-in, then press any key to continue.") From e2558131164ef7458c2493c274250e26eed66e65 Mon Sep 17 00:00:00 2001 From: theDebonair Date: Sat, 2 Jul 2022 15:16:33 +0530 Subject: [PATCH 56/80] Minor fixes --- awbot.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/awbot.py b/awbot.py index fa76e5d..8316ab8 100644 --- a/awbot.py +++ b/awbot.py @@ -261,10 +261,11 @@ def main(): # show balances print(f"\nWAX Balance: {aw.wax_balance:.4f}") - print(f"TLM Balance: {tlm_new:.4f}") # show tlm mined per click if i and tlm_old < tlm_new: + print(f"TLM Balance: {tlm_new:.4f}") + try: # to find the value of tlm mined tlm_mined = tlm_new - tlm_old @@ -343,7 +344,7 @@ def main(): while True: # try to find mine button try: - mine_btn = driver.find_element(By.XPATH, "//span[contains(text(), 'Mine')]") + mine_btn = driver.find_element(By.XPATH, "//*[contains(text(), 'Mine')]") # if button is not found except NoSuchElementException: @@ -373,7 +374,7 @@ def main(): print("\nSearching for \"Claim\" button.") try: - claim_btn = WebDriverWait(driver, 60).until(ec.visibility_of_element_located((By.XPATH, "//span[contains(text(), 'Claim Mine')]"))) + claim_btn = WebDriverWait(driver, 60).until(ec.visibility_of_element_located((By.XPATH, "//*[contains(text(), 'Claim Mine')]"))) print("Found \"Claim\" button!") # full page screenshot From 81999033946d68faae6f7e2c4fa0f966ee5f5a48 Mon Sep 17 00:00:00 2001 From: theDebonair Date: Sat, 2 Jul 2022 15:27:11 +0530 Subject: [PATCH 57/80] Minor fix --- awbot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/awbot.py b/awbot.py index 8316ab8..7e2dbd2 100644 --- a/awbot.py +++ b/awbot.py @@ -264,9 +264,9 @@ def main(): # show tlm mined per click if i and tlm_old < tlm_new: - print(f"TLM Balance: {tlm_new:.4f}") - try: + print(f"TLM Balance: {tlm_new:.4f}") + # to find the value of tlm mined tlm_mined = tlm_new - tlm_old print(f"TLM mined in last claim: {tlm_mined:.4f}") From e3a7c6f206c15ab4c3f4577031456ea92631bc1a Mon Sep 17 00:00:00 2001 From: theDebonair Date: Sat, 2 Jul 2022 15:36:11 +0530 Subject: [PATCH 58/80] Minor change --- awbot.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/awbot.py b/awbot.py index 7e2dbd2..56c1cdb 100644 --- a/awbot.py +++ b/awbot.py @@ -108,6 +108,8 @@ def main(): # create AW Account instance aw = Account(wallet) + print("\nWallet address: \"{}\"".format(wallet)) + # define range for loop delay delay_min = 60 # min delay before next loop delay_max = 300 # max delay before next loop From f8d3404e62ee0df6381a2b784f1ee908938dafb9 Mon Sep 17 00:00:00 2001 From: theDebonair Date: Sat, 2 Jul 2022 16:10:37 +0530 Subject: [PATCH 59/80] Optimized --- awbot.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/awbot.py b/awbot.py index 56c1cdb..9b12844 100644 --- a/awbot.py +++ b/awbot.py @@ -395,7 +395,6 @@ def main(): return except: - notification.notify(title = os.path.basename(path) + "\\" + os.path.basename(__file__), message = "Script restarting. Unable to load or find \"Claim\" button.") print('\n\tUnable to load or find \"Claim\" button. Restarting.') driver.quit() return @@ -464,7 +463,7 @@ def main(): except: try: # wait for cancel button to be visible & click button - btn_can = WebDriverWait(driver, 15).until(ec.visibility_of_element_located((By.XPATH, "//*[contains(text(), 'Cancel')]"))) + btn_can = WebDriverWait(driver, 10).until(ec.visibility_of_element_located((By.XPATH, "//*[contains(text(), 'Cancel')]"))) # if cancel button found then it'll be clicked if btn_can: @@ -488,7 +487,7 @@ def main(): except: try: # wait for login button to be visible - btn_login = WebDriverWait(driver, 15).until(ec.visibility_of_element_located((By.XPATH, "//*[contains(text(), 'Login')]"))) + btn_login = WebDriverWait(driver, 10).until(ec.visibility_of_element_located((By.XPATH, "//*[contains(text(), 'Login')]"))) # if login button found then print message & restart if btn_login: @@ -512,7 +511,6 @@ def main(): return except: - notification.notify(title = os.path.basename(path) + "\\" + os.path.basename(__file__), message = "Script restarting. Unable to load or find button(s).") print('\n\tUnable to load or find button(s). Restarting.') driver.quit() return From 634c8aa2eda41175ce32faff860559a6694e6cc4 Mon Sep 17 00:00:00 2001 From: theDebonair Date: Sat, 2 Jul 2022 20:16:05 +0530 Subject: [PATCH 60/80] Improved button detection --- awbot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/awbot.py b/awbot.py index 9b12844..e83686b 100644 --- a/awbot.py +++ b/awbot.py @@ -346,7 +346,7 @@ def main(): while True: # try to find mine button try: - mine_btn = driver.find_element(By.XPATH, "//*[contains(text(), 'Mine')]") + mine_btn = driver.find_element(By.XPATH, "//*[starts-with(text(), 'Mine')]") # if button is not found except NoSuchElementException: @@ -376,7 +376,7 @@ def main(): print("\nSearching for \"Claim\" button.") try: - claim_btn = WebDriverWait(driver, 60).until(ec.visibility_of_element_located((By.XPATH, "//*[contains(text(), 'Claim Mine')]"))) + claim_btn = WebDriverWait(driver, 60).until(ec.visibility_of_element_located((By.XPATH, "//*[starts-with(text(), 'Claim')]"))) print("Found \"Claim\" button!") # full page screenshot From 9e04a0778d342bf17d973492db09edbee0ed42b3 Mon Sep 17 00:00:00 2001 From: theDebonair Date: Sat, 2 Jul 2022 20:31:14 +0530 Subject: [PATCH 61/80] Improved file read --- awbot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/awbot.py b/awbot.py index e83686b..34e2d9f 100644 --- a/awbot.py +++ b/awbot.py @@ -68,7 +68,7 @@ def main(): # check for file size & read if os.stat("account.txt").st_size != 0: afile = open("account.txt", "r") - wallet = afile.read() + wallet = afile.read().splitlines() afile.close() # delete the file if found empty account.txt file @@ -297,7 +297,7 @@ def main(): # check for file size & read if os.stat("throttle.txt").st_size != 0: tfile = open("throttle.txt", "r") - throttle = tfile.read() + throttle = tfile.read().splitlines() tfile.close() if throttle == "Y" or throttle == "y": From fb05f5f69fc4f8398302b6946b1ee5e337a7ab87 Mon Sep 17 00:00:00 2001 From: Harshit Gupta Date: Sun, 3 Jul 2022 13:00:19 +0530 Subject: [PATCH 62/80] Improved files input --- awbot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/awbot.py b/awbot.py index 34e2d9f..834ba55 100644 --- a/awbot.py +++ b/awbot.py @@ -68,7 +68,7 @@ def main(): # check for file size & read if os.stat("account.txt").st_size != 0: afile = open("account.txt", "r") - wallet = afile.read().splitlines() + wallet = afile.read().rstrip("\n") afile.close() # delete the file if found empty account.txt file @@ -297,7 +297,7 @@ def main(): # check for file size & read if os.stat("throttle.txt").st_size != 0: tfile = open("throttle.txt", "r") - throttle = tfile.read().splitlines() + throttle = tfile.read().rstrip("\n") tfile.close() if throttle == "Y" or throttle == "y": From e745a345241db917b2bc1faf9f289d014b4fc948 Mon Sep 17 00:00:00 2001 From: Harshit Gupta Date: Sun, 3 Jul 2022 13:24:54 +0530 Subject: [PATCH 63/80] Fixed mine button not found error --- awbot.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/awbot.py b/awbot.py index 834ba55..1b6abdb 100644 --- a/awbot.py +++ b/awbot.py @@ -341,17 +341,18 @@ def main(): return # wait for mine button to be found - print("\nWaiting for \"Mine\" button.") + print("\nSearching for \"Mine\" button.") while True: # try to find mine button try: - mine_btn = driver.find_element(By.XPATH, "//*[starts-with(text(), 'Mine')]") + mine_btn = WebDriverWait(driver, 60).until(ec.visibility_of_element_located((By.XPATH, "//*[starts-with(text(), 'Mine')]"))) # if button is not found except NoSuchElementException: - time.sleep(1) - _print_(".") + print('\n\tUnable to load or find \"Mine\" button. Restarting.') + driver.quit() + return except KeyboardInterrupt: print("\nStopping bot.") From cc3d14b89eabcb57d54706f3734b5650a25f7234 Mon Sep 17 00:00:00 2001 From: Harshit Gupta Date: Tue, 5 Jul 2022 10:26:37 +0530 Subject: [PATCH 64/80] Minor fixes --- awbot.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/awbot.py b/awbot.py index 1b6abdb..d1c7544 100644 --- a/awbot.py +++ b/awbot.py @@ -23,6 +23,12 @@ # variable as condition to exit script exit_sc = False +# initialize loop count +loop_count = 0 + +# initialize mine loop count +mine_loop_count = 0 + def _print_(text: str) -> None: sys.stdout.write(text) sys.stdout.flush() @@ -219,9 +225,6 @@ def main(): print("\nBot encountered an error. Restarting.") return - # initialize mine loop count - mine_loop_count = 0 - # load tlm balance tlm_old = aw.tlm_balance @@ -232,7 +235,9 @@ def main(): i = False # main bot loop - for loop_count in count(1): + for count in count(1): + loop_count += 1 + # clear terminal os.system('cls' if os.name == 'nt' else 'clear') @@ -264,11 +269,15 @@ def main(): # show balances print(f"\nWAX Balance: {aw.wax_balance:.4f}") + try: + print(f"TLM Balance: {tlm_new:.4f}") + + except: + print("\nUnable to retrieve the TLM value.") + # show tlm mined per click if i and tlm_old < tlm_new: - try: - print(f"TLM Balance: {tlm_new:.4f}") - + try: # to find the value of tlm mined tlm_mined = tlm_new - tlm_old print(f"TLM mined in last claim: {tlm_mined:.4f}") @@ -289,7 +298,7 @@ def main(): return except: - print("\nUnable to retrieve the value(s).") + print("\nUnable to show the value(s).") # check for throttle.txt file if os.path.exists("throttle.txt"): From 002244829f6302cd8d94bf61c261a5c18e758323 Mon Sep 17 00:00:00 2001 From: Harshit Gupta Date: Tue, 5 Jul 2022 10:35:14 +0530 Subject: [PATCH 65/80] Final version --- awbot.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/awbot.py b/awbot.py index d1c7544..ea33448 100644 --- a/awbot.py +++ b/awbot.py @@ -34,7 +34,7 @@ def _print_(text: str) -> None: sys.stdout.flush() def main(): - global path, exit_sc + global path, exit_sc, loop_count, mine_loop_count # clear terminal os.system('cls' if os.name == 'nt' else 'clear') @@ -235,7 +235,7 @@ def main(): i = False # main bot loop - for count in count(1): + for y in count(1): loop_count += 1 # clear terminal @@ -264,23 +264,23 @@ def main(): print("NET: [ {:,} / {:,} B ]\t\tUsed: {} %".format(net_used, net_max, net_pct)) print("RAM: [ {:,} / {:,} B ]\t\tUsed: {} %".format(ram_used, ram_max, ram_pct)) - tlm_new = aw.tlm_balance - # show balances print(f"\nWAX Balance: {aw.wax_balance:.4f}") try: - print(f"TLM Balance: {tlm_new:.4f}") + print(f"TLM Balance: {aw.tlm_balance:.4f}") except: - print("\nUnable to retrieve the TLM value.") + print("Unable to retrieve the TLM value.") + + tlm_new = aw.tlm_balance # show tlm mined per click if i and tlm_old < tlm_new: try: # to find the value of tlm mined tlm_mined = tlm_new - tlm_old - print(f"TLM mined in last claim: {tlm_mined:.4f}") + print(f"\nTLM mined in last claim: {tlm_mined:.4f}") tlm_old = tlm_new # to find average rate of tlm mining From 0942bc71d35c4dd5322dbe6c8939c87b1b30b430 Mon Sep 17 00:00:00 2001 From: Harshit Gupta Date: Tue, 5 Jul 2022 15:53:45 +0530 Subject: [PATCH 66/80] Updated readme --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index e8bce91..c9849bc 100644 --- a/README.md +++ b/README.md @@ -36,3 +36,7 @@ python awbot.py - ###### Follow the prompts in the command terminal. - ###### You must open the terminal in the same directory where the files are stored. - ###### Feel free to make suggestions, report bugs on this project's [discussions](https://github.com/theDebonair/awbot/discussions) tab. + +### Want to buy me a mug of coffee? +WAX: xau3c.c.wam +BNB, ETH: 0xaA98aAE37F98ce7d657f4472e14891266c13e321 \ No newline at end of file From cc2f2161d6f2664560f30eaf6759ba28bcdeb44b Mon Sep 17 00:00:00 2001 From: Harshit Gupta Date: Tue, 5 Jul 2022 15:57:05 +0530 Subject: [PATCH 67/80] Updated --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c9849bc..1d0b673 100644 --- a/README.md +++ b/README.md @@ -38,5 +38,5 @@ python awbot.py - ###### Feel free to make suggestions, report bugs on this project's [discussions](https://github.com/theDebonair/awbot/discussions) tab. ### Want to buy me a mug of coffee? -WAX: xau3c.c.wam -BNB, ETH: 0xaA98aAE37F98ce7d657f4472e14891266c13e321 \ No newline at end of file +- ###### WAX: xau3c.c.wam +- ###### BNB, ETH: 0xaA98aAE37F98ce7d657f4472e14891266c13e321 \ No newline at end of file From 5bcf386e25385ff1a23d72ebaa4a32b565c1adc5 Mon Sep 17 00:00:00 2001 From: Harshit Gupta Date: Tue, 5 Jul 2022 20:41:27 +0530 Subject: [PATCH 68/80] Updated readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1d0b673..56b9404 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,6 @@ python awbot.py - ###### You must open the terminal in the same directory where the files are stored. - ###### Feel free to make suggestions, report bugs on this project's [discussions](https://github.com/theDebonair/awbot/discussions) tab. -### Want to buy me a mug of coffee? +### Want to buy me a lambo? - ###### WAX: xau3c.c.wam - ###### BNB, ETH: 0xaA98aAE37F98ce7d657f4472e14891266c13e321 \ No newline at end of file From 315645e5f68b8bb9858d2760ad3e3a43c84fb0cd Mon Sep 17 00:00:00 2001 From: Harshit Gupta Date: Tue, 5 Jul 2022 20:41:36 +0530 Subject: [PATCH 69/80] Minor fixes --- awbot.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/awbot.py b/awbot.py index ea33448..867a738 100644 --- a/awbot.py +++ b/awbot.py @@ -20,15 +20,15 @@ path = os.path.dirname(__file__) -# variable as condition to exit script -exit_sc = False - # initialize loop count loop_count = 0 # initialize mine loop count mine_loop_count = 0 +# variable as condition to exit script +exit_sc = False + def _print_(text: str) -> None: sys.stdout.write(text) sys.stdout.flush() @@ -241,6 +241,8 @@ def main(): # clear terminal os.system('cls' if os.name == 'nt' else 'clear') + print("\nWallet address: \"{}\"".format(wallet)) + try: # fetch cpu usage details cpu_usage = aw.cpu_usage @@ -260,9 +262,9 @@ def main(): net_used = net_usage['used'] net_pct = int(net_used / net_max * 100) - print("CPU: [ {:,} / {:,} ms ]\t\tUsed: {} %".format(cpu_used, cpu_max, cpu_pct)) - print("NET: [ {:,} / {:,} B ]\t\tUsed: {} %".format(net_used, net_max, net_pct)) - print("RAM: [ {:,} / {:,} B ]\t\tUsed: {} %".format(ram_used, ram_max, ram_pct)) + print("CPU: [ {:,} / {:,} ms ]\t\t\tUsed: {} %".format(cpu_used, cpu_max, cpu_pct)) + print("NET: [ {:,} / {:,} B ]\t\t\tUsed: {} %".format(net_used, net_max, net_pct)) + print("RAM: [ {:,} / {:,} B ]\t\t\tUsed: {} %".format(ram_used, ram_max, ram_pct)) # show balances print(f"\nWAX Balance: {aw.wax_balance:.4f}") From 09688e1e338a93124078a6c544a2cb2536ae2627 Mon Sep 17 00:00:00 2001 From: Harshit Gupta Date: Tue, 5 Jul 2022 21:05:18 +0530 Subject: [PATCH 70/80] Updated readme --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 56b9404..0a1b885 100644 --- a/README.md +++ b/README.md @@ -28,13 +28,17 @@ python awbot.py ### Attention ###### Using bot or any kind of automation is not recommended by the Aliens World. I'm not responsible for any kind of your loss(es). USE AT YOUR OWN RISK! -### PS +### Features - ###### "Bot resource(s) throttling" feature disables the check for CPU, NET, RAM usage. This enables the bot to click even when the resources are above 100%. - ###### "Headless mode" is the mode where browser will completely run in the background without disturbing you. When login will be required, headless mode will be turned OFF automatically. - ###### "Screenshots" of the last updated pages now available in the bot's directory. +- ###### Added a feature to sell the "TLM" tokens. This can be done by creating a file "sell.file" in the bot's directory. + +### PS - ###### On the first run you need to login to your wax account, on the succeeding runs you will be logged in automatically as the session cookies will be saved. - ###### Follow the prompts in the command terminal. - ###### You must open the terminal in the same directory where the files are stored. +- ###### To prevent any errors, click the "Mine" button and "claim" manually very first time of using the bot. Their is some issue with WAX wallet, or you must have some "TLM" tokens in your wallet. - ###### Feel free to make suggestions, report bugs on this project's [discussions](https://github.com/theDebonair/awbot/discussions) tab. ### Want to buy me a lambo? From d1e6e10ce0500070afe83de9c49c80559e3fea27 Mon Sep 17 00:00:00 2001 From: Harshit Gupta Date: Tue, 5 Jul 2022 21:05:35 +0530 Subject: [PATCH 71/80] Added "TLM sell" option --- awbot.py | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/awbot.py b/awbot.py index 867a738..0e6a624 100644 --- a/awbot.py +++ b/awbot.py @@ -1,4 +1,5 @@ #!/usr/bin/env python3 +from ast import And import sys import os import time @@ -67,6 +68,9 @@ def main(): # wax signin page signin = "https://all-access.wax.io/" + # alcor to sell tlm + sell = "https://wax.alcor.exchange/trade/tlm-alien.worlds_wax-eosio.token" + # for account.txt file try: # check for account.txt file @@ -102,11 +106,16 @@ def main(): print("\nBot encountered an error. Restarting.") return - # check for sign.file file - if os.path.exists("sign.file"): + # check for sign.file and sell.file file + if os.path.exists("sell.file"): + print("\n\"sell.file\" found.") + headless = False + sell_file = True + + elif os.path.exists("sign.file"): headless = True sign_file = True - + else: headless = False sign_file = False @@ -174,8 +183,18 @@ def main(): driver.get(url) else: - driver.get(signin) - driver.set_window_position(0, 0) + if sell_file: + driver.get(sell) + driver.set_window_position(0, 0) + input("\nPress any key when selling of \"TLM\" tokens is done.") + os.remove("sell.file") + print("\"sell.file\" deleted.") + print("Restarting bot.") + return + + else: + driver.get(signin) + driver.set_window_position(0, 0) print("\nSuccessfully loaded \"{}\".".format(driver.title)) @@ -241,7 +260,7 @@ def main(): # clear terminal os.system('cls' if os.name == 'nt' else 'clear') - print("\nWallet address: \"{}\"".format(wallet)) + print("Wallet address: \"{}\"".format(wallet)) try: # fetch cpu usage details @@ -262,7 +281,7 @@ def main(): net_used = net_usage['used'] net_pct = int(net_used / net_max * 100) - print("CPU: [ {:,} / {:,} ms ]\t\t\tUsed: {} %".format(cpu_used, cpu_max, cpu_pct)) + print("\nCPU: [ {:,} / {:,} ms ]\t\t\tUsed: {} %".format(cpu_used, cpu_max, cpu_pct)) print("NET: [ {:,} / {:,} B ]\t\t\tUsed: {} %".format(net_used, net_max, net_pct)) print("RAM: [ {:,} / {:,} B ]\t\t\tUsed: {} %".format(ram_used, ram_max, ram_pct)) From 7e4434024c1df987efb355ae7f483c67ffbf6c61 Mon Sep 17 00:00:00 2001 From: Harshit Gupta Date: Wed, 6 Jul 2022 15:27:58 +0530 Subject: [PATCH 72/80] Fixed bugs --- awbot.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/awbot.py b/awbot.py index 0e6a624..7d3d03a 100644 --- a/awbot.py +++ b/awbot.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -from ast import And import sys import os import time @@ -30,12 +29,16 @@ # variable as condition to exit script exit_sc = False +sell_file = False + +sign_file = True + def _print_(text: str) -> None: sys.stdout.write(text) sys.stdout.flush() def main(): - global path, exit_sc, loop_count, mine_loop_count + global path, exit_sc, loop_count, mine_loop_count, sell_file, sign_file # clear terminal os.system('cls' if os.name == 'nt' else 'clear') From 1756a8cb861c478d81c9323f84030f12fde18dbd Mon Sep 17 00:00:00 2001 From: Harshit Gupta Date: Fri, 8 Jul 2022 13:49:02 +0530 Subject: [PATCH 73/80] Minor fix --- awbot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awbot.py b/awbot.py index 7d3d03a..9e6a933 100644 --- a/awbot.py +++ b/awbot.py @@ -344,7 +344,7 @@ def main(): continue elif throttle == "N" or throttle == "n": - print("\nResource utilization throttling is OFF. Turn ON by changing value to \"N\" in the \"throttle.txt\" file.") + print("\nResource utilization throttling is OFF. Turn ON by changing value to \"Y\" in the \"throttle.txt\" file.") # delete the file if value found other than Y or N else: From 9c1c85afa8f58b92cf61bd70eaa59c4bdeb7675f Mon Sep 17 00:00:00 2001 From: Harshit Gupta Date: Sun, 10 Jul 2022 23:57:17 +0530 Subject: [PATCH 74/80] Minor fix --- awbot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awbot.py b/awbot.py index 9e6a933..27e7536 100644 --- a/awbot.py +++ b/awbot.py @@ -395,7 +395,7 @@ def main(): # if button is found, then click else: - print("\nFound \"Mine\" button!") + print("Found \"Mine\" button!") # full page screenshot total_width = driver.execute_script("return document.body.offsetWidth") From b823c2e662e737a6c46588003f2ce73efd62227e Mon Sep 17 00:00:00 2001 From: Harshit Gupta Date: Fri, 22 Jul 2022 12:02:40 +0530 Subject: [PATCH 75/80] Updated searching mechanism --- awbot.py | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/awbot.py b/awbot.py index 27e7536..5ab7c9f 100644 --- a/awbot.py +++ b/awbot.py @@ -126,7 +126,7 @@ def main(): # create AW Account instance aw = Account(wallet) - print("\nWallet address: \"{}\"".format(wallet)) + print(f"\nWallet address: \"{wallet}\"") # define range for loop delay delay_min = 60 # min delay before next loop @@ -199,7 +199,7 @@ def main(): driver.get(signin) driver.set_window_position(0, 0) - print("\nSuccessfully loaded \"{}\".".format(driver.title)) + print(f"\nSuccessfully loaded \"{driver.title}\".") except TypeError: print("\nPlease update your selenium package.") @@ -263,7 +263,7 @@ def main(): # clear terminal os.system('cls' if os.name == 'nt' else 'clear') - print("Wallet address: \"{}\"".format(wallet)) + print(f"Wallet address: \"{wallet}\"") try: # fetch cpu usage details @@ -336,8 +336,8 @@ def main(): if throttle == "Y" or throttle == "y": # resource utilization throttling if (cpu_pct > resource_limit) or (ram_pct > resource_limit) or (net_pct > resource_limit): - print("\nResource utilization is above the set threshold of {} %.".format(resource_limit)) - print("Sleeping for {} seconds.".format(resource_sleep)) + print(f"\nResource utilization is above the set threshold of {resource_limit} %.") + print(f"Sleeping for {resource_sleep} seconds.") for x in range(resource_sleep): time.sleep(1) _print_(".") @@ -381,18 +381,17 @@ def main(): try: mine_btn = WebDriverWait(driver, 60).until(ec.visibility_of_element_located((By.XPATH, "//*[starts-with(text(), 'Mine')]"))) - # if button is not found - except NoSuchElementException: - print('\n\tUnable to load or find \"Mine\" button. Restarting.') - driver.quit() - return - except KeyboardInterrupt: print("\nStopping bot.") exit_sc = True driver.quit() return + # if button is not found + except: + print('\n\tUnable to load or find \"Mine\" button.') + break + # if button is found, then click else: print("Found \"Mine\" button!") @@ -452,7 +451,7 @@ def main(): try: print("\tSwitching to pop-up window.") driver.switch_to.window(this_window) - print("\tSwitched successfully to \"{}\".".format(driver.title)) + print(f"\tSwitched successfully to \"{driver.title}\".") except KeyboardInterrupt: print("\n\tStopping bot.") @@ -552,7 +551,7 @@ def main(): # go control back to main window print("\n\tSwitching back to main window.") driver.switch_to.window(main_window) - print("\tSwitched successfully to \"{}\".".format(driver.title)) + print(f"\tSwitched successfully to \"{driver.title}\".") time.sleep(3) # full page screenshot From 3a7fab45b3dc18a0e30ed2417c2067e06609c825 Mon Sep 17 00:00:00 2001 From: Harshit Gupta Date: Sat, 13 Aug 2022 11:42:07 +0530 Subject: [PATCH 76/80] Some optimizations --- awbot.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/awbot.py b/awbot.py index 5ab7c9f..e147121 100644 --- a/awbot.py +++ b/awbot.py @@ -136,13 +136,25 @@ def main(): resource_limit = 100 # skip mining if resources are above the set limit resource_sleep = 30 # sleep for given time if there is not enough resources - # set Chrome options chrome_options = Options() + + # set Page load strategy + chrome_options.page_load_strategy = "eager" + + # set Chrome options + chrome_options.add_argument("--no-sandbox") + chrome_options.add_argument("--disable-extensions") + chrome_options.add_argument("--disable-crash-reporter") + chrome_options.add_argument("--disable-gpu") + chrome_options.add_argument("--disable-dev-shm-usage") + chrome_options.add_argument("--disable-in-process-stack-traces") + chrome_options.add_argument("--disable-logging") chrome_options.add_argument("--log-level=3") chrome_options.add_argument("--ignore-certificate-errors") chrome_options.add_argument("--ignore-certificate-errors-spki-list") chrome_options.add_argument("--ignore-ssl-errors") chrome_options.add_argument("--mute-audio") + chrome_options.add_argument("--output=/dev/null") chrome_options.add_argument("user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36") # headless mode when signed in @@ -163,8 +175,8 @@ def main(): # instantiate Chrome driver with given Chrome options try: - driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=chrome_options) - + driver = webdriver.Chrome(service = Service(ChromeDriverManager().install()), options = chrome_options) + # instantiate stealth stealth(driver, languages=["en-US", "en"], @@ -524,8 +536,6 @@ def main(): # if login button found then print message & restart if btn_login: - notification.notify(title = os.path.basename(path) + "\\" + os.path.basename(__file__), message = "Please \"Login\".") - # full page screenshot total_width = driver.execute_script("return document.body.offsetWidth") total_height = driver.execute_script("return document.body.scrollHeight") From 08975b10062e5dd51e9a993e0d174582b5afd5ff Mon Sep 17 00:00:00 2001 From: Harshit Gupta Date: Wed, 24 Aug 2022 13:03:14 +0530 Subject: [PATCH 77/80] Updated readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0a1b885..ce7bcfe 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ python awbot.py ### Features - ###### "Bot resource(s) throttling" feature disables the check for CPU, NET, RAM usage. This enables the bot to click even when the resources are above 100%. - ###### "Headless mode" is the mode where browser will completely run in the background without disturbing you. When login will be required, headless mode will be turned OFF automatically. -- ###### "Screenshots" of the last updated pages now available in the bot's directory. +- ###### "Screenshot" of the last opened pages. - ###### Added a feature to sell the "TLM" tokens. This can be done by creating a file "sell.file" in the bot's directory. ### PS From 5c05eb8484cdab6e5b7af30ddd41f961f71d237a Mon Sep 17 00:00:00 2001 From: Harshit Gupta Date: Wed, 24 Aug 2022 13:05:26 +0530 Subject: [PATCH 78/80] Error with WDM fixed --- awbot.py | 76 +++++++++++++++++++++++++++----------------------------- 1 file changed, 36 insertions(+), 40 deletions(-) diff --git a/awbot.py b/awbot.py index e147121..d5176a9 100644 --- a/awbot.py +++ b/awbot.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python3 import sys import os import time @@ -13,7 +12,6 @@ from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as ec -from selenium.common.exceptions import NoSuchElementException from selenium_stealth import stealth from webdriver_manager.chrome import ChromeDriverManager from awapi import Account @@ -41,7 +39,7 @@ def main(): global path, exit_sc, loop_count, mine_loop_count, sell_file, sign_file # clear terminal - os.system('cls' if os.name == 'nt' else 'clear') + os.system("cls" if os.name == "nt" else "clear") # check internet connection conn = httplib.HTTPConnection("1.1.1.1", timeout = 10) @@ -142,19 +140,14 @@ def main(): chrome_options.page_load_strategy = "eager" # set Chrome options - chrome_options.add_argument("--no-sandbox") chrome_options.add_argument("--disable-extensions") chrome_options.add_argument("--disable-crash-reporter") - chrome_options.add_argument("--disable-gpu") - chrome_options.add_argument("--disable-dev-shm-usage") chrome_options.add_argument("--disable-in-process-stack-traces") - chrome_options.add_argument("--disable-logging") chrome_options.add_argument("--log-level=3") chrome_options.add_argument("--ignore-certificate-errors") chrome_options.add_argument("--ignore-certificate-errors-spki-list") chrome_options.add_argument("--ignore-ssl-errors") chrome_options.add_argument("--mute-audio") - chrome_options.add_argument("--output=/dev/null") chrome_options.add_argument("user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36") # headless mode when signed in @@ -173,9 +166,12 @@ def main(): # for ChromeDriver version 79.0.3945.16 or over chrome_options.add_argument("--disable-blink-features=AutomationControlled") + # check for latest chromedriver + driver_service = Service(ChromeDriverManager().install()) + # instantiate Chrome driver with given Chrome options try: - driver = webdriver.Chrome(service = Service(ChromeDriverManager().install()), options = chrome_options) + driver = webdriver.Chrome(service = driver_service, options = chrome_options) # instantiate stealth stealth(driver, @@ -273,27 +269,27 @@ def main(): loop_count += 1 # clear terminal - os.system('cls' if os.name == 'nt' else 'clear') + os.system("cls" if os.name == "nt" else "clear") print(f"Wallet address: \"{wallet}\"") try: # fetch cpu usage details cpu_usage = aw.cpu_usage - cpu_max = cpu_usage['max'] - cpu_used = cpu_usage['used'] + cpu_max = cpu_usage["max"] + cpu_used = cpu_usage["used"] cpu_pct = int(cpu_used / cpu_max * 100) # fetch ram usage details ram_usage = aw.ram_usage - ram_max = ram_usage['max'] - ram_used = ram_usage['used'] + ram_max = ram_usage["max"] + ram_used = ram_usage["used"] ram_pct = int(ram_used / ram_max * 100) # fetch net usage details net_usage = aw.net_usage - net_max = net_usage['max'] - net_used = net_usage['used'] + net_max = net_usage["max"] + net_used = net_usage["used"] net_pct = int(net_used / net_max * 100) print("\nCPU: [ {:,} / {:,} ms ]\t\t\tUsed: {} %".format(cpu_used, cpu_max, cpu_pct)) @@ -409,10 +405,10 @@ def main(): print("Found \"Mine\" button!") # full page screenshot - total_width = driver.execute_script("return document.body.offsetWidth") - total_height = driver.execute_script("return document.body.scrollHeight") - driver.set_window_size(total_width, total_height) - driver.save_screenshot("sc_main_mine.png") # image will be saved as "sc_main_mine.png" in the bot's directory + # total_width = driver.execute_script("return document.body.offsetWidth") + # total_height = driver.execute_script("return document.body.scrollHeight") + # driver.set_window_size(total_width, total_height) + # driver.save_screenshot("sc_main_mine.png") # image will be saved as "sc_main_mine.png" in the bot's directory mine_btn.click() break @@ -425,10 +421,10 @@ def main(): print("Found \"Claim\" button!") # full page screenshot - total_width = driver.execute_script("return document.body.offsetWidth") - total_height = driver.execute_script("return document.body.scrollHeight") - driver.set_window_size(total_width, total_height) - driver.save_screenshot("sc_main_claim.png") # image will be saved as "sc_main_claim.png" in the bot's directory + # total_width = driver.execute_script("return document.body.offsetWidth") + # total_height = driver.execute_script("return document.body.scrollHeight") + # driver.set_window_size(total_width, total_height) + # driver.save_screenshot("sc_main_claim.png") # image will be saved as "sc_main_claim.png" in the bot's directory # click claim button claim_btn.click() @@ -490,10 +486,10 @@ def main(): print("\n\tFound \"Approve\" button!") # full page screenshot - total_width = driver.execute_script("return document.body.offsetWidth") - total_height = driver.execute_script("return document.body.scrollHeight") - driver.set_window_size(total_width, total_height) - driver.save_screenshot("sc_popup_approve.png") # image will be saved as "sc_popup_approve.png" in the bot's directory + # total_width = driver.execute_script("return document.body.offsetWidth") + # total_height = driver.execute_script("return document.body.scrollHeight") + # driver.set_window_size(total_width, total_height) + # driver.save_screenshot("sc_popup_approve.png") # image will be saved as "sc_popup_approve.png" in the bot's directory btn.click() print("\tApproving transaction.") @@ -515,10 +511,10 @@ def main(): print("\n\tFound \"Cancel\" button!") # full page screenshot - total_width = driver.execute_script("return document.body.offsetWidth") - total_height = driver.execute_script("return document.body.scrollHeight") - driver.set_window_size(total_width, total_height) - driver.save_screenshot("sc_popup_can.png") # image will be saved as "sc_popup_can.png" in the bot's directory + # total_width = driver.execute_script("return document.body.offsetWidth") + # total_height = driver.execute_script("return document.body.scrollHeight") + # driver.set_window_size(total_width, total_height) + # driver.save_screenshot("sc_popup_can.png") # image will be saved as "sc_popup_can.png" in the bot's directory btn_can.click() print("\tCancelling transaction.") @@ -537,10 +533,10 @@ def main(): # if login button found then print message & restart if btn_login: # full page screenshot - total_width = driver.execute_script("return document.body.offsetWidth") - total_height = driver.execute_script("return document.body.scrollHeight") - driver.set_window_size(total_width, total_height) - driver.save_screenshot("sc_popup_login.png") # image will be saved as "sc_popup_login.png" in the bot's directory + # total_width = driver.execute_script("return document.body.offsetWidth") + # total_height = driver.execute_script("return document.body.scrollHeight") + # driver.set_window_size(total_width, total_height) + # driver.save_screenshot("sc_popup_login.png") # image will be saved as "sc_popup_login.png" in the bot's directory os.remove("sign.file") print("\n\tRestarting bot.") @@ -565,10 +561,10 @@ def main(): time.sleep(3) # full page screenshot - total_width = driver.execute_script("return document.body.offsetWidth") - total_height = driver.execute_script("return document.body.scrollHeight") - driver.set_window_size(total_width, total_height) - driver.save_screenshot("sc_main.png") # image will be saved as "sc_main.png" in the bot's directory + # total_width = driver.execute_script("return document.body.offsetWidth") + # total_height = driver.execute_script("return document.body.scrollHeight") + # driver.set_window_size(total_width, total_height) + # driver.save_screenshot("sc_main.png") # image will be saved as "sc_main.png" in the bot's directory # show the number of loops done print(f"\nTotal number of execution(s): {loop_count}") From 5cef96e2c45887bd0bd0e3d2d79c9df56b2860f0 Mon Sep 17 00:00:00 2001 From: Harshit Gupta Date: Wed, 24 Aug 2022 13:08:41 +0530 Subject: [PATCH 79/80] Added inst. for Screenshot --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index ce7bcfe..f6f9a1f 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,7 @@ python awbot.py - ###### Follow the prompts in the command terminal. - ###### You must open the terminal in the same directory where the files are stored. - ###### To prevent any errors, click the "Mine" button and "claim" manually very first time of using the bot. Their is some issue with WAX wallet, or you must have some "TLM" tokens in your wallet. +- ###### To take screenshot, you've to uncomment 4 lines under the comment ```# full page screenshot``` within the bot. - ###### Feel free to make suggestions, report bugs on this project's [discussions](https://github.com/theDebonair/awbot/discussions) tab. ### Want to buy me a lambo? From 925b8d46f4eac7afc764dfda959cb7edefb02a34 Mon Sep 17 00:00:00 2001 From: Harshit Gupta Date: Sat, 1 Oct 2022 23:59:51 +0530 Subject: [PATCH 80/80] Added "Start Now", "Nothing to be mined" detection --- awbot.py | 77 +++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 57 insertions(+), 20 deletions(-) diff --git a/awbot.py b/awbot.py index d5176a9..61b7033 100644 --- a/awbot.py +++ b/awbot.py @@ -135,18 +135,13 @@ def main(): resource_sleep = 30 # sleep for given time if there is not enough resources chrome_options = Options() - - # set Page load strategy - chrome_options.page_load_strategy = "eager" # set Chrome options - chrome_options.add_argument("--disable-extensions") - chrome_options.add_argument("--disable-crash-reporter") - chrome_options.add_argument("--disable-in-process-stack-traces") chrome_options.add_argument("--log-level=3") chrome_options.add_argument("--ignore-certificate-errors") chrome_options.add_argument("--ignore-certificate-errors-spki-list") chrome_options.add_argument("--ignore-ssl-errors") + chrome_options.add_argument("--disable-blink-features=AutomationControlled") chrome_options.add_argument("--mute-audio") chrome_options.add_argument("user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36") @@ -159,15 +154,8 @@ def main(): pwd = pathlib.Path().absolute() chrome_options.add_argument(f"--user-data-dir={pwd}\\chrome-data") - # for older ChromeDriver under version 79.0.3945.16 - chrome_options.add_experimental_option("excludeSwitches", ["enable-automation"]) - chrome_options.add_experimental_option("useAutomationExtension", False) - - # for ChromeDriver version 79.0.3945.16 or over - chrome_options.add_argument("--disable-blink-features=AutomationControlled") - # check for latest chromedriver - driver_service = Service(ChromeDriverManager().install()) + driver_service = Service() # instantiate Chrome driver with given Chrome options try: @@ -380,6 +368,38 @@ def main(): ntfile.close() driver.quit() return + + # wait for mine button to be found + print("\nSearching for \"Start Now\" button.") + + while True: + # try to search for "start now" button + try: + start_btn = WebDriverWait(driver, 5).until(ec.visibility_of_element_located((By.XPATH, "//*[starts-with(text(), 'Start')]"))) + + except KeyboardInterrupt: + print("\nStopping bot.") + exit_sc = True + driver.quit() + return + + # if button is not found + except: + print('\n\tUnable to load or find \"Start Now\" button.') + break + + # if button is found, then click + else: + print("Found \"Start Now\" button!") + + # full page screenshot + # total_width = driver.execute_script("return document.body.offsetWidth") + # total_height = driver.execute_script("return document.body.scrollHeight") + # driver.set_window_size(total_width, total_height) + # driver.save_screenshot("sc_main_mine.png") # image will be saved as "sc_main_mine.png" in the bot's directory + + start_btn.click() + break # wait for mine button to be found print("\nSearching for \"Mine\" button.") @@ -387,7 +407,7 @@ def main(): while True: # try to find mine button try: - mine_btn = WebDriverWait(driver, 60).until(ec.visibility_of_element_located((By.XPATH, "//*[starts-with(text(), 'Mine')]"))) + mine_btn = WebDriverWait(driver, 30).until(ec.visibility_of_element_located((By.XPATH, "//*[starts-with(text(), 'Mine')]"))) except KeyboardInterrupt: print("\nStopping bot.") @@ -417,7 +437,7 @@ def main(): print("\nSearching for \"Claim\" button.") try: - claim_btn = WebDriverWait(driver, 60).until(ec.visibility_of_element_located((By.XPATH, "//*[starts-with(text(), 'Claim')]"))) + claim_btn = WebDriverWait(driver, 15).until(ec.visibility_of_element_located((By.XPATH, "//*[starts-with(text(), 'Claim')]"))) print("Found \"Claim\" button!") # full page screenshot @@ -479,7 +499,7 @@ def main(): # for pop-up window click(s) try: # wait for approve button to be visible & click button - btn = WebDriverWait(driver, 60).until(ec.visibility_of_element_located((By.XPATH, "//*[contains(text(), 'Approve')]"))) + btn = WebDriverWait(driver, 30).until(ec.visibility_of_element_located((By.XPATH, "//*[contains(text(), 'Approve')]"))) # if button found then it'll be clicked if btn: @@ -504,7 +524,7 @@ def main(): except: try: # wait for cancel button to be visible & click button - btn_can = WebDriverWait(driver, 10).until(ec.visibility_of_element_located((By.XPATH, "//*[contains(text(), 'Cancel')]"))) + btn_can = WebDriverWait(driver, 5).until(ec.visibility_of_element_located((By.XPATH, "//*[contains(text(), 'Cancel')]"))) # if cancel button found then it'll be clicked if btn_can: @@ -528,7 +548,7 @@ def main(): except: try: # wait for login button to be visible - btn_login = WebDriverWait(driver, 10).until(ec.visibility_of_element_located((By.XPATH, "//*[contains(text(), 'Login')]"))) + btn_login = WebDriverWait(driver, 5).until(ec.visibility_of_element_located((By.XPATH, "//*[contains(text(), 'Login')]"))) # if login button found then print message & restart if btn_login: @@ -558,7 +578,24 @@ def main(): print("\n\tSwitching back to main window.") driver.switch_to.window(main_window) print(f"\tSwitched successfully to \"{driver.title}\".") - time.sleep(3) + + try: + WebDriverWait(driver, 5).until(ec.visibility_of_element_located((By.XPATH, "//*[contains(text(), 'Nothing')]"))) + notification.notify(title = os.path.basename(path) + "\\" + os.path.basename(__file__), message = "Nothing to be mined!") + print("\n\tNothing to be mined!") + time.sleep(5) + + except KeyboardInterrupt: + print("\nStopping bot.") + exit_sc = True + driver.quit() + return + + except: + pass + + else: + continue # full page screenshot # total_width = driver.execute_script("return document.body.offsetWidth")