Skip to content

Commit

Permalink
Merge pull request #9 from iTeam-S/add_friend
Browse files Browse the repository at this point in the history
Ajout de la fonction add_friend
  • Loading branch information
gaetan1903 authored Apr 24, 2021
2 parents 210af8c + 096437f commit 8e0f88f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def send_code_confirmation(dest_id, lien_profil):
try:
bot.send_action(dest_id, 'mark_seen')
bot.send_action(dest_id, 'typing_on')
req.updateCode(dest_id, username, code, None, sexe)
req.updateCode(dest_id, username, code, None, sexe)
req.insertTache(3, dest_id, message)

except Exception as err:
Expand Down
8 changes: 6 additions & 2 deletions scripts/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ def connexion(Browser):
Browser.get('https://mbasic.facebook.com/')
while not page_loaded(Browser):
time.sleep(0.5)
Browser.find_element_by_tag_name('body').screenshot("conn.png")
if 'login' in Browser.current_url:
print('Je me login encore')
try:
Expand Down Expand Up @@ -79,7 +78,7 @@ def send_msg(Browser, userID, message):
while not page_loaded(Browser):
time.sleep(0.5)
# Redirect to the message page of the user
Browser.find_element_by_tag_name('body').screenshot("conn.png")
# Browser.find_element_by_tag_name('body').screenshot("conn.png")
Browser.get('https://mbasic.facebook.com/messages/thread/' + userID)
while not page_loaded(Browser):
time.sleep(0.5)
Expand Down Expand Up @@ -166,3 +165,8 @@ def encode(txt):
for u in txt:
txt_encode = txt_encode + str(ord(u)) + '-'
return txt_encode[:-1]


def add_friend (Browser, userID):
Browser.get("https://mbasic.facebook.com/"+ userID)
Browser.find_element_by_link_text("Ajouter").click()
8 changes: 6 additions & 2 deletions tache.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ def tache2(data):
def tache3(data):
username = req.getUserName(data[2])
user_id = get_user_id(username, driver)
print(user_id)
if not user_id:
bot.send_action(data[2], 'mark_seen')
bot.send_action(data[2], 'typing_on')
Expand All @@ -82,11 +81,16 @@ def tache3(data):
sexe = bot.get_gender(data[2])
try:
send_msg(driver.browser, user_id, data[3])
print("sa aty?")
req.setUserID(user_id, data[2])
bot.send_action(data[2], 'mark_seen')
bot.send_action(data[2], 'typing_on')
bot.send_message(data[2], "Verifier vos messages, votre code a été envoyé :-)")
try :
add_friend(driver.browser, user_id)
bot.send_message(data[2], "Veuillez accepter , notre demande d'ami s'il vous plaît")
except Exception as err :
print("On est déjà ami")
pass
req.setAction(data[2], 'ATTENTE_CODE_CONFIRMATION')
bot.send_message(data[2], "Veuillez saisir votre code de confirmation")
except Exception as err:
Expand Down

0 comments on commit 8e0f88f

Please sign in to comment.