-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfacebook_bot.py
83 lines (67 loc) · 2.22 KB
/
facebook_bot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import speech_recognition as sr
from selenium import webdriver
import time,pyttsx3
engine=pyttsx3.init('sapi5')
voice=engine.getProperty('voices')
engine.setProperty('voices',voice[len(voice)-2].id)
speed=200
engine.setProperty('rate', speed)
def speak(text):
print('BOT : '+text)
engine.say(text)
engine.runAndWait()
jump=500
req=None
curr=0
def start_taking_voice_command():
global curr,req
text=''
r=sr.Recognizer()
with sr.Microphone() as source:
audio=r.listen(source)
try:
text=r.recognize_google(audio)
except:
speak('Try again...')
if text!='':
if 'scroll' in text:
speak('Scrolling')
driver.execute_script('window.scrollTo(0,{})'.format(curr+jump))
curr+=jump
elif 'friend requests' in text or 'friend request' in text:
speak('opening requests')
req=driver.find_element_by_id('fbRequestsJewel')
req.click()
elif 'messages' in text or 'message' in text:
speak('opening messages')
req=driver.find_element_by_id('u_0_e')
req.click()
elif 'notifications' in text or 'notification' in text:
speak('showing notifications')
req=driver.find_element_by_id('fbNotificationsJewel')
req.click()
elif 'close' in text:
speak('closing')
req.click()
elif 'like' in text:
req=driver.find_element_by_class_name(' _6a-y _3l2t _18vj')
req.click()
if __name__=='__main__':
driver=webdriver.Chrome(executable_path='C:\\Users\\tusha\\Downloads\\chromedriver.exe')
driver.get('https://www.facebook.com')
'''email=input('E-mail : ')
password=input('Password : ')'''
email='[email protected]'
password='#pokemon911'
e_mail_box=driver.find_element_by_id('email')
pass_box=driver.find_element_by_id('pass')
e_mail_box.send_keys(email)
pass_box.send_keys(password)
speak('LOGGING IN...')
speak('Please Wait for 5 seconds...')
login_button=driver.find_element_by_id('loginbutton')
login_button.click()
time.sleep(5)
speak('Logged in...')
while True:
start_taking_voice_command()