Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ajout de la fonction add_friend #9

Merged
merged 1 commit into from
Apr 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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