-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
32 lines (24 loc) · 1.13 KB
/
main.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
from fbchat import Client, log
import twilio.rest
from getpass import getpass
to="+917376335104" # Your mobile number assosiated to twilio on which you'll get messages
from_="+1415******" # Twilio number
SID = "ACed16c3e*************" # Twilio Sid number
Tocken = "dbb7c5f5b**********" # Twilio tocken number
username = str(raw_input("Facebook_Username: ")) # For facebook username
password = getpass() # For Facebook password
# for sending the Message
def sendMessage(SID, Tocken, to ,from_ ,body):
client = twilio.rest.Client(SID, Tocken)
client.messages.create(to= to, from_ = from_, body= body)
class EchoBot(Client):
def onMessage(self, author_id, message, thread_id, thread_type, **kwargs):
# If you're sending message to someone on fb then it will not gonna send a message to you on phone
if author_id != self.uid:
user = client.fetchUserInfo(author_id)[author_id]
Sender = user.name
body = ":\nMessage from " + Sender + "\nmessage is - " + message
sendMessage(SID, Tocken, to ,from_ , body)
print "Message send on your mobile number"
client = EchoBot(username, password)
client.listen()