Advertisement
Guest User

LifeBot code

a guest
May 28th, 2016
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 9.93 KB | None | 0 0
  1. # -*- coding: utf-8  -*-
  2.  
  3. # Autor: Simon Kempf
  4. # Traducción al español: Dimichi Cháchara
  5. # IMPORTANTE : SkyGen no se hace responsable del uso del bot o el abuso del mismo.
  6.  
  7. # Lee ésto si haces una modificación o editas el bot :
  8. # 1) Copia los comandos que has creado en la antigua versión a la nueva versión.
  9. # 2) Si has editado un comando, debes suprimir el código de la nueva versión cambiándolo al de la nueva versión.
  10.  
  11. import socket, time, urllib, webbrowser #Imports, no modificar si no sabes Python.
  12.  
  13. chan = "##dfsdfsdf"
  14. #Canal a donde irá el bot
  15. user_bot = "Cepita"
  16. #nick del bot
  17. ver = "Variante de LifeBot - Todos los derechos reservados Dimichi Cháchara y Simon Kempf"
  18. #Versión del bot
  19. host = "irc.freenode.net"
  20. #Red IRC
  21. port = 6667
  22. #Puerto de la red IRC
  23. trust = []
  24. #Los usuarios que pueden usar comandos especiales.
  25.  
  26. #No modifiques ésto si no sabes Python.
  27. #Version de LifeBot :
  28. ver_LifeBot = "1.4"
  29. lang_LifeBot = "es"
  30. print(ver)
  31. #Contraseña :
  32. password = raw_input("123456")
  33. #Conexión de IRC :
  34. identify = True
  35. IRC = irc.freenode.net()
  36. IRC.connect((host, port))
  37. IRC.send("NICK %s\r\n" % user_bot)
  38. IRC.send("USER MasterBot %s bla :%s\r\n" % (host, user_bot))
  39. #Bucle de connnexion :
  40. while True:
  41.     rep = IRC.recv(2048)
  42.     rep2 = rep.split()
  43.     print(rep)
  44. #
  45.     try:
  46.         if ":End of /MOTD command." in rep and identify == False:
  47.             IRC.send("PRIVMSG NickServ :identify %s\r\n" % password)
  48.             IRC.send("JOIN %s\r\n" % chan)
  49.             identify = True
  50. #Respuesta al ping de la red IRC :
  51.         if rep2[0] == "PING":
  52.             IRC.send("PONG %s\r\n" % rep2[1])
  53. #Respuesta a las invitaciones del bot :
  54.         if rep2[1] == "INVITE":
  55.             IRC.send("JOIN %s\r\n" % rep2[3])
  56.     except IndexError:
  57.         rep2 = ["", "", "", "", "", "", "", "", "", ""]
  58. #
  59.     user = rep2[0].split("!")
  60.     user[0] = user[0].strip(":")
  61.     trusted = user[0] in trust
  62.  
  63.     if rep2[1] == "PRIVMSG":
  64.         try:
  65.                 if rep2[2].startswith("#") == False:
  66.                     rep2[2] = user[0]
  67. #Fin de la partie.
  68.  
  69.  
  70. #Début de la sintaxis.
  71.                 if rep2[3].lower() == ":!commandtest":
  72.                     IRC.send("PRIVMSG %s :%s\r\n" % (rep2[2], "Texte à envoyer."))
  73. #Fin de la sintaxis.
  74. #Sigue la sintaxis de arriba cuando quieras agregar un comando. ¿Necesitas ayuda? ¡Consulta en ##SkyGen!
  75.  
  76.                 if rep2[3].lower() == ":!ban" and trusted: #Aquí, un comando que banea al usuario de un canal, on a une commande qui bannit l'utilisateur d'un chan
  77.                     try:
  78.                         IRC.send("MODE %s +b %s\r\n" % (rep2[4], rep2[5])) #Si escribes !ban ##machin bidule, el bot banea al usuario bidule del canal ##machin (el bot debe ser op del canal para que el comando funcione)
  79.                     except IndexError: #si on ne met pas le chan (exemple, si on tape !ban bidule)
  80.                         IRC.send("MODE %s +b %s\r\n" % (rep2[2], rep2[4])) #El bot banea al usuario del canal donde el comando se ejecuta (el bot debe ser op del canal para que el comando funcione)
  81.  
  82.                 if rep2[3].lower() == ":!bing":
  83.                     IRC.send("PRIVMSG %s :%s\r\n" % (rep2[2], "http://www.bing.com/search?q=" + "+".join(rep2[4:])))
  84.  
  85.                 if (rep2[3].lower() == ":!chanserv" or rep2[3].lower() == ":!cs")  and trusted: #Comando que envía un mensaje a ChanServ.
  86.                     IRC.send("PRIVMSG ChanServ :%s\r\n" % " ".join(rep2[4:]))
  87.                    
  88.                 if (rep2[3].lower() == ":!nickserv" or rep2[3].lower() == ":!ns")  and trusted: #Comando que envía un mensaje a NickServ.
  89.                     IRC.send("PRIVMSG NickServ :%s\r\n" % " ".join(rep2[4:]))
  90.  
  91.                 if rep2[3].lower() == ":!deop" and trusted: #Comando que quita el status de op al usuario
  92.                     try:
  93.                         IRC.send("MODE %s -o %s\r\n" % (rep2[4], rep2[5]))
  94.                     except IndexError:
  95.                         IRC.send("MODE %s -o %s\r\n" % (rep2[2], rep2[4]))
  96.  
  97.                 if rep2[3].lower() == ":!devoice" and trusted:
  98.                     try:
  99.                         IRC.send("MODE %s -v %s\r\n" % (rep2[4], rep2[5]))
  100.                     except IndexError:
  101.                         IRC.send("MODE %s -v %s\r\n" % (rep2[2], rep2[4]))
  102.  
  103.                 if rep2[3].lower() == ":!flood":
  104.                     IRC.send("PRIVMSG %s :%s\r\n" % (rep2[2], "Está prohibido floodear con pena de ban indefinido."))
  105.  
  106.                 if rep2[3].lower() == ":!google":
  107.                     IRC.send("PRIVMSG %s :%s\r\n" % (rep2[2], "https://www.google.com/#q=" + "+".join(rep2[4:])))
  108.  
  109.                 if rep2[3].lower() == ":!help" or rep2[3].lower() == ":!ayuda":
  110.                     IRC.send("PRIVMSG %s :%s\r\n" % (rep2[2], "http://skygenrepo.weebly.com/LifeBot.html" + lang_LifeBot + "/LifeBot"))
  111.  
  112.                 if rep2[3].lower() == ":!ip":
  113.                     IRC.send("PRIVMSG %s :%s\r\n" % (rep2[2], "https://whatismyipaddress.com/ip/" + rep2[4]))
  114.  
  115.                 if rep2[3].lower() == ":!join":
  116.                     IRC.send("JOIN %s\r\n" % rep2[4])
  117.  
  118.                 if rep2[3].lower() == ":!kick" and trusted:
  119.                     if " ".join(rep2[5:]) != "":
  120.                         IRC.send("KICK %s %s :%s\r\n" % (rep2[2], rep2[4], " ".join(rep2[5:])))
  121.                     else:
  122.                         IRC.send("KICK %s %s\r\n" % (rep2[2], rep2[4]))
  123.  
  124.                 if rep2[3].lower() == ":!kickban" and trusted:
  125.                     IRC.send("MODE %s +b %s\r\n" % (rep2[2], rep2[4]))
  126.                     if " ".join(rep2[5:]) != "":
  127.                         IRC.send("KICK %s %s :%s\r\n" % (rep2[2], rep2[4], " ".join(rep2[5:])))
  128.                     else:
  129.                         IRC.send("KICK %s %s\r\n" % (rep2[2], rep2[4]))
  130.  
  131.                 if rep2[3].lower() == ":!love":
  132.                     IRC.send("PRIVMSG %s :%s\r\n" % (rep2[2], "Yo también te amo"))
  133.                     IRC.send("PRIVMSG %s :%s\r\n" % (rep2[2], "Pero a veces... te odio."))
  134.  
  135.                 if rep2[3].lower() == ":!mode" and trusted:
  136.                     try:
  137.                         IRC.send("MODE %s %s %s\r\n" % (rep2[4], rep2[5], rep2[6]))
  138.                     except IndexError:
  139.                         IRC.send("MODE %s %s %s\r\n" % (rep2[2], rep2[4], rep2[5]))
  140.  
  141.                 if rep2[3].lower() == ":!modechan" and trusted:
  142.                     try:
  143.                         IRC.send("MODE %s %s\r\n" % (rep2[4], rep2[5]))
  144.                     except IndexError:
  145.                         IRC.send("MODE %s %s\r\n" % (rep2[2], rep2[4]))
  146.  
  147.                 if rep2[3].lower() == ":!news" or rep2[3].lower() == ":!wikinews":
  148.                     IRC.send("PRIVMSG %s :%s\r\n" % (rep2[2], "http://" + rep2[4] + ".wikinews.org/wiki/" + "_".join(rep2[5:])))
  149.                    
  150.                 if rep2[3].lower() == ":!voyage" or rep2[3].lower() == ":!wikivoyage":
  151.                     IRC.send("PRIVMSG %s :%s\r\n" % (rep2[2], "http://" + rep2[4] + ".wikivoyage.org/wiki/" + "_".join(rep2[5:])))
  152.  
  153.                 if rep2[3].lower() == ":!nick" and trusted: #Aquí, un comando que cambia el nick del bot en IRC
  154.                     IRC.send("NICK %s\r\n" % rep2[4])
  155.  
  156.                 if rep2[3].lower() == ":!op" and trusted:
  157.                     try:
  158.                         IRC.send("MODE %s +o %s\r\n" % (rep2[4], rep2[5]))
  159.                     except IndexError:
  160.                         IRC.send("MODE %s +o %s\r\n" % (rep2[2], rep2[4]))
  161.  
  162.                 if rep2[3].lower() == ":!part" or rep2[3].lower() == ":!quit":
  163.                     IRC.send("PART %s\r\n" % rep2[4])
  164.  
  165.                 if rep2[3].lower() == ":!plagio":
  166.                     IRC.send("PRIVMSG %s :%s\r\n" % (rep2[2], "http://plagiarisma.net/es/"))
  167.  
  168.                 if rep2[3].lower() == ":!quiet" and trusted:
  169.                     try:
  170.                         IRC.send("MODE %s +q %s\r\n" % (rep2[4], rep2[5]))
  171.                     except IndexError:
  172.                         IRC.send("MODE %s +q %s\r\n" % (rep2[2], rep2[4]))
  173.  
  174.                 if rep2[3].lower() == ":!unban" and trusted:
  175.                     try:
  176.                         IRC.send("MODE %s -b %s\r\n" % (rep2[4], rep2[5]))
  177.                     except IndexError:
  178.                         IRC.send("MODE %s -b %s\r\n" % (rep2[2], rep2[4]))
  179.  
  180.                 if rep2[3].lower() == ":!unquiet" and trusted:
  181.                     try:
  182.                         IRC.send("MODE %s -q %s\r\n" % (rep2[4], rep2[5]))
  183.                     except IndexError:
  184.                         IRC.send("MODE %s -q %s\r\n" % (rep2[2], rep2[4]))
  185.  
  186.                 if rep2[3].lower() == ":!version" or rep2[3].lower() == ":!ver":
  187.                     IRC.send("PRIVMSG %s :%s\r\n" % (rep2[2], ver + " Versión de LifeBot : " + ver_LifeBot + " " + lang_LifeBot))
  188.  
  189.                 if rep2[3].lower() == ":!viki" or rep2[3].lower() == ":!vikidia" or rep2[3].lower() == ":!vk":
  190.                     IRC.send("PRIVMSG %s :%s\r\n" % (rep2[2], "http://" + rep2[4] + ".vikidia.org/wiki/" + "_".join(rep2[5:])))
  191.  
  192.                 if rep2[3].lower() == ":!voice" and trusted:
  193.                     try:
  194.                         IRC.send("MODE %s +v %s\r\n" % (rep2[4], rep2[5]))
  195.                     except IndexError:
  196.                         IRC.send("MODE %s +v %s\r\n" % (rep2[2], rep2[4]))
  197.  
  198.                 if rep2[3].lower() == ":!wp" or rep2[3].lower() == ":!wikipedia":
  199.                     IRC.send("PRIVMSG %s :%s\r\n" % (rep2[2], "http://" + rep2[4] + ".wikipedia.org/wiki/" + "_".join(rep2[5:])))
  200.  
  201.  
  202. #No editar nada después de esta línea si no tienes conocimientos de Python.
  203.                 if user_bot.lower() + " es bonito" in " ".join(rep2[3:]).lower() or "el bot es bonito" + user_bot.lower() in " ".join(rep2[3:]).lower():
  204.                     IRC.send("PRIVMSG %s :%s\r\n" % (rep2[2], "¡Gracias!, tú también eres bonito :)"))
  205.  
  206.         except IndexError:
  207.             IRC.send("PRIVMSG %s :%s\r\n" % (rep2[2], "Faltan parámetros."))
  208.  
  209. #¡No olvides probar y guardar las modificaciones!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement