Advertisement
flypip

FlyBot (Facebook Bot)

Oct 6th, 2013
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.99 KB | None | 0 0
  1. import sleekxmpp
  2. import logging
  3. import sys
  4. #import dnspython
  5.  
  6. def session_start(event):
  7.     chatbot.send_presence()
  8.     print 'Session started'
  9.     chatbot.get_roster()
  10.  
  11. def message(msg):
  12.     if msg['type'] in ('chat','normal'):
  13.         print "msg recieved"
  14.         msg1 = msg['body']
  15.         print msg1
  16.         if msg1 == "close":
  17.            sys.exit(0)
  18.      
  19.         print 'reply: ' + reply +'\n'
  20.         msg.reply("Flybot: "+reply).send()
  21.  
  22. jid = 'XXXXXX@chat.facebook.com'//XXXX remplacer
  23. password = 'XXXXXXX'//XXXX remplacer
  24. addr = ('chat.facebook.com', 5222)
  25. ipaddr = ('XXX.XXX.XXX.XXX',5222)//XXXX remplacer
  26.  
  27. chatbot = sleekxmpp.ClientXMPP(jid,password)
  28. chatbot.add_event_handler("session_start", session_start)
  29. chatbot.add_event_handler("message", message)
  30.  
  31. chatbot.auto_reconnect = True
  32.  
  33. #logging.basicConfig(level=logging.DEBUG,
  34. #                       format='%(levelname)-8s %(message)s')
  35.  
  36. cb = cleverbot.Session()
  37.  
  38. chatbot.connect(addr)
  39. chatbot.process(block=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement