def getFM(): seq = 0 print("Facebook running...") while not quit: msg = fm.pull(seq) #print msg if msg == "502": print("Connection error, trying again...") continue if msg.get('reason') == 110: print("110 - refresh") fm.reset() fm.login() seq = msg.get('seq', 0) messages = utils.FMParse(msg) commandList = ['girl', 'fun'] if not messages: continue for sender, receiver, message, thread_url, is_thread in messages: if is_thread: print("Thread: %s - %s" % (receiver, thread_url)) allow_thread = cfg.get('FM').get('allow_bot') command = utils.getBotCommand(message) print allow_thread print(thread_url in allow_thread) print(command) if command != None and command in commandList and thread_url in allow_thread: msg = utils.getBotAnswer(command) print(msg) print(thread_url) if is_thread: direct = False else: direct = True r = fm.post(thread_url, msg.encode('utf-8'), direct=direct) print r if r == 404: fm.reset() fm.login() r = fm.post(thread_url, msg.encode('utf-8'), direct=direct) if not utils.doFillter(strFilter, message.encode('utf-8')): continue print("sending email") utils.sendMsgEmail("FM", sender, receiver, message, emailAddress) print("sent email") utils.printMsg("FM", sender, receiver, message)
def getSkype(): print("Skype running...") while not quit: logTime = str(datetime.now()) print(logTime + "pulling...") data = s.pull() print(logTime + "pulled") if data == "500": print(logTime + "Skype reset token, trying again...") s.resetToken() s.login() s.createRegistrationToken() print s.subcribe() continue if data == "404": print(logTime + "404") s.resetToken() s.login() s.createRegistrationToken() s.subcribe() continue if data == "502": print(logTime + "Skype connection error, trying again...") continue if data == "400": print("400") continue print data messages = utils.skypeParse(data) commandList = ['girl', 'fun'] if not messages: continue for sender, receiver, message, thread_url in messages: print(message) command = utils.getBotCommand(message) print(command) if command != None and command in commandList: msg = utils.getBotAnswer(command) print(msg) print(thread_url) s.post(thread_url, msg.encode('utf-8')) continue