Advertisement
Guest User

Untitled

a guest
Sep 4th, 2015
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Comando start
  2. @bot.message_handler(commands=['start'])
  3. def command_start(m):
  4.     cid = m.chat.id
  5.     consulta = "select id from usuarios where id=%d"%(cid)
  6.     cursor.execute(consulta)
  7.     resultado = cursor.fetchone()
  8.     if resultado == None: # Con esta sentencia, hacemos que solo se ejecute lo de abajo cuando un usuario hace uso del bot por primera vez.
  9.         consulta="insert into usuarios values(%d)"%(cid)
  10.         cursor.execute(consulta)
  11.         bot.send_message( cid, "Bienvenido a @League_of_Legends_bot\nWelcome to @League_of_Legends_bot\n______________________\nEste es un bot en español desarrollado por @Edurolp\nThis is a bot in Spanish designed by @Edurolp\n______________________\nEspero que te guste ^^\nI hope you like it ^^")
  12.         command_help(m) # Forzamos mensaje de bienvenida al usar el bot por primera vez.
  13.         print "-> [" + str(cid) + "]: Comando /start utilizado"
  14.         alias = "@" + str(m.from_user.username)
  15.         bot.send_message( admin, "Nuevo usuario\n\nNombre: " + str(m.from_user.first_name) + "\nAlias: " + alias + "\nID: " + str(cid))
  16.  
  17. #Comando stop
  18. @bot.message_handler(commands=['stop'])
  19. def command_stop(m):
  20.     cid = m.chat.id
  21.     bot.send_message( cid, "😭😭😭Adios...😭😭😭\nRecuerda, si usas cualquier comando del bot, volverás a quedar suscrito")
  22.     consulta = "delete from usuarios where id=(%d)"%(cid)
  23.     cursor.execute(consulta)
  24.     bot.send_message( admin, "El usuario <" + str(cid) + "> ha dejado de usar el bot.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement