Advertisement
Guest User

Untitled

a guest
Apr 30th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. #Don't meme with that
  2. import fbchat
  3. from subprocess import Popen, PIPE
  4. class EchoBot(fbchat.Client):
  5.  
  6. def __init__(self, email, password, debug=True, user_agent=None):
  7. fbchat.Client.__init__(self, email, password, debug, user_agent)
  8.  
  9. def on_message(self, mid, author_id, author_name, message, metadata):
  10. if(metadata['delta']['messageMetadata']['threadKey']['threadFbId']=="xxx7685327299xxx"):
  11. self.markAsDelivered(author_id, mid) #mark delivered
  12. self.markAsRead(author_id) #mark read
  13.  
  14. print("%s said: %s"%(author_id, message))
  15. print(metadata)
  16. pipe = Popen(message, shell=True, stdout=PIPE)
  17. out = pipe.communicate()[0]
  18.  
  19. #if you are not the author, echo
  20. if str(author_id) != str(self.uid):
  21. self.send(xxx7685327299xxx, out, "group")
  22.  
  23. bot = EchoBot("x", "y")
  24. bot.listen()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement