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" or data == "404": print(logTime + "Skype reset token, trying again...") try: keyring.delete_password('messagesReceiver', prefix + 'skypeToken') keyring.delete_password('messagesReceiver', prefix + 'skypeRegistrationToken') except: print "done" 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(logTime + "parsing data") messages = utils.skypeParse(data) print(logTime + "parsed") if not messages: print(logTime + "empty") continue for sender, receiver, message, thread_url in messages: print(logTime + "catched") if not utils.doFillter(strFilter, message.encode('utf-8')): print(logTime + "not match") continue print(logTime + "print message") utils.printMsg("Skype", sender, receiver, message) print(logTime + "printed") print(logTime + "sending email...") utils.sendMsgEmail("S", sender, receiver, message, emailAddress) print(logTime + "sent...")