Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
47 changes: 45 additions & 2 deletions funciones.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#
# Date: October - 2019

#Listener
# Listener

def listener(messages):

Expand All @@ -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 :
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")