def disconnect_bot(): """ Quit and disconnect the bot. """ print "Exiting." chatbotini.connection_log("Sesion terminada\n\n\n", "gtalk") sys.exit(0)
def disconnect_bot(): """ Quit and disconnect the bot. :rtype : Bool """ print "Exiting." chatbotini.connection_log("Session terminated\n\n\n", "gtalk") sys.exit(0)
def step_on(conn): """ Keeps the connection alive. """ try: conn.Process(1) except KeyboardInterrupt: chatbotini.connection_log("Interrupcion de teclado (Ctrl+C)\n", "gtalk") disconnect_bot() return 1
def step_on(conn): """ Keeps the connection alive. :rtype : Bool """ try: conn.Process(1) except KeyboardInterrupt: chatbotini.connection_log( "Keyboard Interrupt (Ctrl+C)\n", "gtalk") disconnect_bot() return True
def quit(self, code=0): """ Signs out from MSN. """ print "Closing" chatbotini.connection_log("Sesion terminada\n\n\n", "msn") try: try: MSN.disconnect() except: pass except: pass sys.exit(code)
if __name__ == "__main__": # TODO: split into functions # classes start USE_FUNCTION = Use_Function() SERVER_DISCONNECT = Server_Disconnect() MSN.cb.out = SERVER_DISCONNECT.cb_disconnect MSN.cb.msg = SERVER_DISCONNECT.cb_messages MSN.cb.joi = SERVER_DISCONNECT.cb_join MSN.cb.err = SERVER_DISCONNECT.cb_errors MSN.cb.add = SERVER_DISCONNECT.cb_adding print "\n\n* ChatBot MSN Client *\n" chatbotini.connection_log("Iniciando sesion\n", "msn") # First, the configuration print "Loading config... " CONFIG = USE_FUNCTION.get_configure() CONFIG["profile"] = None # Set the mandatory values MSN.email = CONFIG["email"] MSN.pwd = CONFIG["password"] if not "history size" in CONFIG: CONFIG["history size"] = 10 else:
"""insert into preguntas values(?,?,?,?,?)""", data) conn.commit() conn_cursor.close() conn.close() if __name__ == "__main__": print "\n\n* ChatBot Gtalk Client *\n" config = chatbotini.Config() conn = xmpp.Client(config.gtalk.server, debug=[]) show = xmpp.Presence() # Show: dnd, away, ax SHOW.setShow("ax") CON_RES = CONN.connect(server=("talk.google.com", 5223)) chatbotini.connection_log("Initializing session\n", "gtalk") chatbotini.connection_log( "Connecting to server (talk.google.com)\n", "gtalk") if not CON_RES: print "No se puede conectar al servidor %s!" % chatbotini.SERVER chatbotini.connection_log( "Unable to connect to jabber server (%s)\n" % ( config.gtalk.server), "gtalk") chatbotini.connection_log("Ending\n\n\n", "gtalk") sys.exit(1) if CON_RES != "tls": print( "Advertencia: no se puede estabilizar conexion segura - TLS fallo") AUTHKEY = CONN.auth(chatbotini.LOGINGTALK.split("@")[0], chatbotini.LOGINPASSWORD,
#print data conn = sqlite3.connect("show_unanswered.bd") conn_cursor = conn.cursor() conn_cursor.execute( """insert into preguntas values(?,?,?,?,?)""", data) conn.commit() conn_cursor.close() conn.close() print "\n\n* ChatBot Gtalk Client *\n" CONN = xmpp.Client(chatbotini.SERVER, debug=[]) SHOW = xmpp.Presence() # Show: dnd, away, ax SHOW.setShow("ax") CONRES = CONN.connect(server=("talk.google.com", 5223)) chatbotini.connection_log("Iniciando sesion\n", "gtalk") chatbotini.connection_log("Conectando al servidor (talk.google.com)\n", "gtalk") if not CONRES: print "No se puede conectar al servidor %s!" % chatbotini.SERVER chatbotini.connection_log( "No ha sido posible conectar al servidor jabber (%s)\n" % ( chatbotini.SERVER), "gtalk") chatbotini.connection_log("Terminando\n\n\n", "gtalk") sys.exit(1) if CONRES != "tls": print """Advertencia: no se puede estabilizar conexion segura - TLS fallo""" AUTHRES = CONN.auth(chatbotini.LOGINGTALK.split("@")[0],