Skip to content
This repository has been archived by the owner on Mar 2, 2024. It is now read-only.

Commit

Permalink
Improved stability
Browse files Browse the repository at this point in the history
  • Loading branch information
stanfortonski committed Oct 9, 2021
1 parent 3ff3e1e commit f6b796e
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 46 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ In your `config.json` file have to change following things:
- If `chance_to_like` is 100 It will give only likes.
- Default is 90.
4. To set wait time between give next like or dislike you have to change `max_wait_time_between_action_in_sec` for maximal time delay and
`min_wait_time_between_action_in_sec` for minimal time delay. Default `max_wait_time_between_action_in_sec` is 10 and `min_wait_time_between_action_in_sec` is 4.
`min_wait_time_between_action_in_sec` for minimal time delay. Default `min_wait_time_between_action_in_sec` is 2 and `max_wait_time_between_action_in_sec` is 5.
5. This option `amount_of_login_attempts` sets the number of attempts after which if you don't log in It will error occurs. Default is 15.
6. This option `amount_of_avoid_errors` sets the number of attempts that after program will show error message and exit. Default is 5.
7. If you want to save Instagram nick from description set `allow_to_save_ig` to true. Default is true.
8. Choose path to your file with Instagram nicknames so change `ig_file_path`. Default is "logs/instagram.txt".
9. If you want to save Snapchat nick from description set `allow_to_save_snap` to True. Default is true.
Expand Down
7 changes: 3 additions & 4 deletions app-finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
igFinder = InstagramFinder(driver)
snapFinder = SnapchatFinder(driver)

print('=== Tinder Finder Only Start ===')
print('=== Tinder Finder ===')
login.logIn()
if login.isLogged():
print('=== Instagram/Snapchat Finding ===')
Expand All @@ -27,8 +27,7 @@
if igFinder.getTotalSaves() != 0 and igFinder.getTotalSaves() % 10 == 0:
print(igFinder, snapFinder)
fn.waitRandomTime()
except NoSuchElementException as e:
print(f'Error: {e}\nReport me: https://github.com/stanfortonski/Tinder-Bot')
break
except:
fn.waitRandomTime()
else:
print('Error: Failed to login to Tinder. Check your data or try later.')
22 changes: 5 additions & 17 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,22 @@
from tinder.finder.snapchatfinder import SnapchatFinder
from selenium.common.exceptions import NoSuchElementException
from tinder.config import Config
from time import sleep

driver = getDriver()
login = TinderLogin(driver)
bot = TinderBot(driver)
igFinder = InstagramFinder(driver)
snapFinder = SnapchatFinder(driver)
errors = 0

print('=== TinderBot Start ===')
login.logIn()
if login.isLogged():
print('=== Tinder Perform ===')
while True:
try:
bot.perform()
igFinder.findAndSaveInstagramNick()
snapFinder.findAndSaveSnapchatNick()
if bot.getTotalActions() % 10 == 0:
print(bot, igFinder, snapFinder)
errors = 0
except NoSuchElementException as e:
errors += 1
if errors >= Config['amount_of_avoid_errors']:
print(f'Error: {e}\nReport me: https://github.com/stanfortonski/Tinder-Bot')
break
else:
driver.get('https://tinder.com/app/recs')
sleep(5)
bot.perform()
igFinder.findAndSaveInstagramNick()
snapFinder.findAndSaveSnapchatNick()
if bot.getTotalActions() % 10 == 0:
print(bot, igFinder, snapFinder)
else:
print('Error: Failed to login to Tinder. Check your data or try later.')
5 changes: 2 additions & 3 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@
"login_method": "facebook",
"chance_to_like": 90,
"amount_of_login_attempts": 15,
"amount_of_avoid_errors": 5,
"max_wait_time_between_action_in_sec": 10,
"min_wait_time_between_action_in_sec": 4,
"max_wait_time_between_action_in_sec": 5,
"min_wait_time_between_action_in_sec": 2,
"allow_to_save_ig": true,
"ig_file_path": "logs/instagram.txt",
"allow_to_save_snap": true,
Expand Down
6 changes: 3 additions & 3 deletions driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
def getDriver():
geoEnable = webdriver.FirefoxOptions()
geoEnable.set_preference('geo.enabled', True)
geoEnable.set_preference('geo.provider.use_corelocation', True);
geoEnable.set_preference('geo.prompt.testing', True);
geoEnable.set_preference('geo.prompt.testing.allow', True);
geoEnable.set_preference('geo.provider.use_corelocation', True)
geoEnable.set_preference('geo.prompt.testing', True)
geoEnable.set_preference('geo.prompt.testing.allow', True)
return webdriver.Firefox(options=geoEnable)
7 changes: 3 additions & 4 deletions tests/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@
"login_method": "facebook",
"chance_to_like": 90,
"amount_of_login_attempts": 15,
"amount_of_avoid_errors": 5,
"max_wait_time_between_action_in_sec": 5,
"min_wait_time_between_action_in_sec": 4,
"min_wait_time_between_action_in_sec": 2,
"allow_to_save_ig": true,
"ig_file_path": "instagram.txt",
"ig_file_path": "logs/instagram.txt",
"allow_to_save_snap": true,
"snap_file_path": "snap.txt"
"snap_file_path": "logs/snap.txt"
}
2 changes: 1 addition & 1 deletion tests/instagramfinder_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def setUp(self):
def changeNameScript(self, name):
while True:
try:
self.driver.execute_script('document.querySelector("#content > div > div:nth-child(1) > div > main > div:nth-child(1) > div > div > div:nth-child(1) > div > div:nth-child(1) > div:nth-child(3) > div:nth-child(6) > div > div:nth-child(2) > div > div > span").innerHTML = "'+name+'"');
self.driver.execute_script('document.querySelector("#content > div > div:nth-child(1) > div > main > div:nth-child(1) > div > div > div:nth-child(1) > div > div:nth-child(1) > div:nth-child(3) > div:nth-child(6) > div > div:nth-child(2) > div > div > span").innerHTML = "'+name+'"')
break
except:
self.driver.get('https://tinder.com/app/recs')
Expand Down
2 changes: 1 addition & 1 deletion tests/snapchatfinder_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def setUp(self):
def changeNameScript(self, name):
while True:
try:
self.driver.execute_script('document.querySelector("#content > div > div:nth-child(1) > div > main > div:nth-child(1) > div > div > div:nth-child(1) > div > div:nth-child(1) > div:nth-child(3) > div:nth-child(6) > div > div:nth-child(2) > div > div > span").innerHTML = "'+name+'"');
self.driver.execute_script('document.querySelector("#content > div > div:nth-child(1) > div > main > div:nth-child(1) > div > div > div:nth-child(1) > div > div:nth-child(1) > div:nth-child(3) > div:nth-child(6) > div > div:nth-child(2) > div > div > span").innerHTML = "'+name+'"')
break
except:
self.driver.get('https://tinder.com/app/recs')
Expand Down
26 changes: 15 additions & 11 deletions tinder/tinderbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,18 @@ def __init__(self, driver):

def perform(self, wait=True):
if 'app/recs' in self.driver.current_url:
self.__doOutOfLikesPopup()
fn.waitForPeople(self.driver)
chanceToLike = randrange(1, 100)
if chanceToLike <= Config['chance_to_like']:
self.like()
else:
self.dislike()
if wait:
try:
self.__doOutOfLikesPopup()
fn.waitForPeople(self.driver)
chanceToLike = randrange(1, 100)
if chanceToLike <= Config['chance_to_like']:
self.like()
else:
self.dislike()
if wait:
fn.waitRandomTime()
except:
self.driver.get('https://tinder.com/app/recs')
fn.waitRandomTime()

def __doOutOfLikesPopup(self):
Expand Down Expand Up @@ -72,17 +76,17 @@ def dislike(self):
def solveProblems(self):
try:
self.driver.find_element_by_xpath('/html/body/div[2]/div/div/div/div[3]/button[2]').click()
except NoSuchElementException:
except (ElementClickInterceptedException, NoSuchElementException):
pass

try:
self.driver.find_element_by_xpath('/html/body/div[2]/div/div/button[2]').click()
except NoSuchElementException:
except (ElementClickInterceptedException, NoSuchElementException):
pass

try:
self.driver.find_element_by_xpath('/html/body/div[1]/div/div[1]/div/main/div[2]/div/div/div[1]/div/div[4]/button').click()
except NoSuchElementException:
except (ElementClickInterceptedException, NoSuchElementException):
pass

def __str__(self):
Expand Down

0 comments on commit f6b796e

Please sign in to comment.