diff --git a/bot.py b/bot.py index 24bf16d..ca8e03c 100644 --- a/bot.py +++ b/bot.py @@ -29,7 +29,15 @@ bot = telebot.TeleBot(TOKEN) # Creamos el objeto de nuestro bot. @bot.message_handler(commands=['ayuda']) - +@bot.message_handler(commands=['info']) # Indicamos que lo siguiente va a controlar el comando '/info' +@bot.message_handler(commands=['saldo']) # Indicamos que lo siguiente va a controlar el comando '/info' + +## Mensajes de Lectura Inline +@bot.message_handler(func=lambda message: message.text == "hola") +@bot.message_handler(func=lambda message: message.text == "Que es esto") +@bot.message_handler(func=lambda message: message.text == "Como lo uso") +@bot.message_handler(func=lambda message: message.text == "Esto es una beta") + bot.set_update_listener(listener) # Así, le decimos al bot que utilice como función escuchadora nuestra función 'listener' declarada arriba. diff --git a/funciones.py b/funciones.py index 00930c5..209cdfd 100644 --- a/funciones.py +++ b/funciones.py @@ -7,7 +7,7 @@ # # Date: October - 2019 -#Listener +# Listener def listener(messages): @@ -24,4 +24,47 @@ def listener(messages): f.write(mensaje + "\n") # Escribimos la linea de log en el fichero. f.close() # Cerramos el fichero para que se guarde. - print mensaje # Imprimimos el mensaje en la terminal, que nunca viene mal : \ No newline at end of file + print mensaje # Imprimimos el mensaje en la terminal, que nunca + +#### COMANDOS DISPONIBLES + +# Ayuda +def command_ayuda(m): + cid = m.chat.id # Guardamos el ID de la conversación para poder responder. + bot.send_chat_action(cid, 'typing') # Enviando ... + time.sleep(1) #La respuesta del bot tarda 1 segundo en ejecutarse + bot.send_message( cid, AYUDA) # Con la función 'send_message()' del bot, enviamos al ID almacenado el texto que queremos. + +# Info +def command_info(m): # Definimos una función que resuleva lo que necesitemos. + cid = m.chat.id # Guardamos el ID de la conversación para poder responder. + + if cid == GRUPO: + bot.send_message( GRUPO, 'mensaje A') # Con la función 'send_message()' del bot, enviamos al ID almacenado el texto que queremos. + + else : + bot.send_message( cid, 'mensaje B') + +# Saldo +def command_saldo(m): + cid = m.chat.id # Guardamos el ID de la conversación para poder responder. + time.sleep(1) + bot.send_message(m.chat.id, "Esta funcion estara disponible en el siguiente release") + + +### MENSAJES INLINE +def command_text_hola(m): + time.sleep(1) + bot.send_message(m.chat.id, "Hola a ti tambien") + +def command_text_Que_es_esto(m): + time.sleep(1) + bot.send_message(m.chat.id, "Es uno de los nuevos metodos de comunicacion del USBCEIC") + +def command_text_Como_lo_uso(m): + time.sleep(1) + bot.send_message(m.chat.id, "EScribe el comando /ayuda para ver las opciones disponibles y de que se trata el bot") + +def command_text_Esto_es_una_beta(m): + time.sleep(1) + bot.send_message(m.chat.id, "Si, efectivamente, es una beta que estara disponible hasta el siguiente release") \ No newline at end of file