Advertisement
Guest User

Untitled

a guest
Jul 10th, 2016
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.61 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, ne pas modifier sauf si vous connaîssez Python.
  12.  
  13. chan = "##Lanaima-social"
  14. #Canal a donde irá el bot
  15. user_bot = "Dorami-Bot"
  16. #nick del bot
  17. ver = "LifeBot 1.5 - 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.  
  27. #Versión de LifeBot:
  28. ver_LifeBot = "1.5.0"
  29. lang_LifeBot = "es"
  30. print(ver)
  31. #Contraseña:
  32. password = raw_input("Si el bot va a usar una cuenta de NickServ, escribe aquí la contraseña y pulsa Intro. Si no la tiene, solamente pulsa Intro: ")
  33. #Conexión a IRC:
  34. identify = False
  35. IRC = socket.socket()
  36. IRC.connect((host, port))
  37. IRC.send("NICK %s\r\n" % user_bot)
  38. IRC.send("USER LifeBot %s bla :%s\r\n" % (host, user_bot))
  39. #Bucle de conexión:
  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 los datos básicos de bot.
  68. #Inicio de comandos privados.
  69. if rep2[3].lower() == ":!identify":
  70. try:
  71. IRC.send("PRIVMSG NickServ :identify %s %s\r\n" % (rep2[4], rep2[5]))
  72. except IndexError:
  73. IRC.send("PRIVMSG NickServ :identify %s\r\n" % rep2[4])
  74. #Fin de comandos funcionales únicamente en mensaje privado.
  75. else: #No agregar nada aquí.
  76. #Inicio de comandos no funcionales en mensaje privado.
  77. #Inicio de la sintaxis.
  78. if rep2[3].lower() == ":!prueba":
  79. IRC.send("PRIVMSG %s :%s\r\n" % (rep2[2], "Texto a enviar"))
  80. #Fin de la sintaxis.
  81. #Sigue la sintaxis de arriba cuando quieras agregar un nuevo comando. ¿Necesitas ayuda? Consulta en ##SkyGen
  82.  
  83. if rep2[3].lower() == ":!ban" and trusted: #Aquí, un comando
  84. try:
  85. 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 estar en el canal y debe ser operador del canal para que este comando funcione)
  86. except IndexError: #Si no pusiste el nombre del canal (ejemplo, si pones !ban bidule)
  87. IRC.send("MODE %s +b %s\r\n" % (rep2[2], rep2[4])) #El bot banea al usuario del canal donde se puso el comando (el bot debe ser operador del canal para que este comando funcione)
  88.  
  89. if rep2[3].lower() == ":!bing":
  90. IRC.send("PRIVMSG %s :%s\r\n" % (rep2[2], "http://www.bing.com/search?q=" + "+".join(rep2[4:])))
  91.  
  92. if (rep2[3].lower() == ":!chanserv" or rep2[3].lower() == ":!cs") and trusted: #Este comando envía un mensaje a ChanServ. Ver los comandos ChanServ.
  93. IRC.send("PRIVMSG ChanServ :%s\r\n" % " ".join(rep2[4:]))
  94.  
  95. if (rep2[3].lower() == ":!chanserv_access" or rep2[3].lower() == ":!cs_access") and trusted:
  96. try:
  97. IRC.send("PRIVMSG ChanServ :access %s add %s %s\r\n" % (rep2[4], rep2[5], rep2[6]))
  98. except IndexError:
  99. IRC.send("PRIVMSG ChanServ :access %s add %s %s\r\n" % (rep2[2], rep2[4], rep2[5]))
  100.  
  101. if (rep2[3].lower() == ":!chanserv_access_del" or rep2[3].lower() == ":!cs_access_del") and trusted:
  102. try:
  103. IRC.send("PRIVMSG ChanServ :access %s del %s\r\n" % (rep2[4], rep2[5]))
  104. except IndexError:
  105. IRC.send("PRIVMSG ChanServ :access %s del %s\r\n" % (rep2[2], rep2[4]))
  106.  
  107. if (rep2[3].lower() == ":!chanserv_akick" or rep2[3].lower() == ":!cs_akick") and trusted: #Comando para akickear
  108. try:
  109. IRC.send("PRIVMSG ChanServ :akick %s add %s\r\n" % (rep2[4], rep2[5]))
  110. except IndexError:
  111. IRC.send("PRIVMSG ChanServ :akick %s add %s\r\n" % (rep2[2], rep2[4]))
  112.  
  113. if (rep2[3].lower() == ":!chanserv_akick_del" or rep2[3].lower() == ":!cs_akick_del") and trusted: #Este comando es para eliminar los akicks a un usuario.
  114. try:
  115. IRC.send("PRIVMSG ChanServ :akick %s del %s\r\n" % (rep2[4], rep2[5]))
  116. except IndexError:
  117. IRC.send("PRIVMSG ChanServ :akick %s del %s\r\n" % (rep2[2], rep2[4]))
  118.  
  119. if (rep2[3].lower() == ":!chanserv_flags" or rep2[3].lower() == ":!cs_flags") and trusted:
  120. try:
  121. IRC.send("PRIVMSG ChanServ :flags %s %s %s\r\n" % (rep2[4], rep2[5], rep2[6]))
  122. except IndexError:
  123. IRC.send("PRIVMSG ChanServ :flags %s %s %s\r\n" % (rep2[2], rep2[4], rep2[5]))
  124.  
  125. if rep2[3].lower() == ":!deop" and trusted: #Aquí un comando que quita el status de op al usuario.
  126. try:
  127. IRC.send("MODE %s -o %s\r\n" % (rep2[4], rep2[5]))
  128. except IndexError:
  129. IRC.send("MODE %s -o %s\r\n" % (rep2[2], rep2[4]))
  130.  
  131. if rep2[3].lower() == ":!devoice" and trusted:
  132. try:
  133. IRC.send("MODE %s -v %s\r\n" % (rep2[4], rep2[5]))
  134. except IndexError:
  135. IRC.send("MODE %s -v %s\r\n" % (rep2[2], rep2[4]))
  136.  
  137. if rep2[3].lower() == ":!flood":
  138. IRC.send("PRIVMSG %s :%s\r\n" % (rep2[2], "El flood está prohibido bajo pena de ban."))
  139. #Entre estos dos comentarios puedes ver un comando simple.
  140.  
  141. if rep2[3].lower() == ":!google":
  142. IRC.send("PRIVMSG %s :%s\r\n" % (rep2[2], "https://www.google.com.pe/#q=" + "+".join(rep2[4:])))
  143.  
  144. if rep2[3].lower() == ":!help" or rep2[3].lower() == ":!ayuda":
  145. IRC.send("PRIVMSG %s :%s\r\n" % (rep2[2], "http://skygenrepo.weebly.com/lifebot.html" + lang_LifeBot + "/LifeBot/"))
  146.  
  147. if rep2[3].lower() == ":!ip":
  148. IRC.send("PRIVMSG %s :%s\r\n" % (rep2[2], "https://whatismyipaddress.com/ip/" + rep2[4]))
  149.  
  150. if rep2[3].lower() == ":!join":
  151. IRC.send("JOIN %s\r\n" % rep2[4])
  152.  
  153. if rep2[3].lower() == ":!kick" and trusted:
  154. if " ".join(rep2[5:]) != "":
  155. IRC.send("KICK %s %s :%s\r\n" % (rep2[2], rep2[4], " ".join(rep2[5:])))
  156. else:
  157. IRC.send("KICK %s %s\r\n" % (rep2[2], rep2[4]))
  158.  
  159. if rep2[3].lower() == ":!kickban" and trusted:
  160. IRC.send("MODE %s +b %s\r\n" % (rep2[2], rep2[4]))
  161. if " ".join(rep2[5:]) != "":
  162. IRC.send("KICK %s %s :%s\r\n" % (rep2[2], rep2[4], " ".join(rep2[5:])))
  163. else:
  164. IRC.send("KICK %s %s\r\n" % (rep2[2], rep2[4]))
  165.  
  166. if rep2[3].lower() == ":!love":
  167. IRC.send("PRIVMSG %s :%s\r\n" % (rep2[2], "Yo no te amo..."))
  168. IRC.send("PRIVMSG %s :%s\r\n" % (rep2[2], "...pero te amo, a veces."))
  169. # ¿Has visto cómo se puede hacer para que el bot responda en dos frases separadas? Sino, mira en el código fuente de !love (ver arriba).
  170.  
  171. if rep2[3].lower() == ":!mode" and trusted:
  172. try:
  173. IRC.send("MODE %s %s %s\r\n" % (rep2[4], rep2[5], rep2[6]))
  174. except IndexError:
  175. IRC.send("MODE %s %s %s\r\n" % (rep2[2], rep2[4], rep2[5]))
  176.  
  177. if rep2[3].lower() == ":!modechan" and trusted:
  178. try:
  179. IRC.send("MODE %s %s\r\n" % (rep2[4], rep2[5]))
  180. except IndexError:
  181. IRC.send("MODE %s %s\r\n" % (rep2[2], rep2[4]))
  182.  
  183. if rep2[3].lower() == ":!news" or rep2[3].lower() == ":!wikinews":
  184. IRC.send("PRIVMSG %s :%s\r\n" % (rep2[2], "http://" + rep2[4] + ".wikinews.org/wiki/" + "_".join(rep2[5:])))
  185.  
  186. if rep2[3].lower() == ":!nick" and trusted: #Aquí, un comando que cambia el nick del bot
  187. IRC.send("NICK %s\r\n" % rep2[4])
  188.  
  189. if rep2[3].lower() == ":!op" and trusted:
  190. try:
  191. IRC.send("MODE %s +o %s\r\n" % (rep2[4], rep2[5]))
  192. except IndexError:
  193. IRC.send("MODE %s +o %s\r\n" % (rep2[2], rep2[4]))
  194.  
  195. if rep2[3].lower() == ":!part" or rep2[3].lower() == ":!quit":
  196. IRC.send("PART %s\r\n" % rep2[4])
  197.  
  198. if rep2[3].lower() == ":!plagio":
  199. IRC.send("PRIVMSG %s :%s\r\n" % (rep2[2], "http://plagiarisma.net/es/"))
  200.  
  201. if rep2[3].lower() == ":!quiet" and trusted:
  202. try:
  203. IRC.send("MODE %s +q %s\r\n" % (rep2[4], rep2[5]))
  204. except IndexError:
  205. IRC.send("MODE %s +q %s\r\n" % (rep2[2], rep2[4]))
  206.  
  207. if rep2[3].lower() == ":!unban" and trusted:
  208. try:
  209. IRC.send("MODE %s -b %s\r\n" % (rep2[4], rep2[5]))
  210. except IndexError:
  211. IRC.send("MODE %s -b %s\r\n" % (rep2[2], rep2[4]))
  212.  
  213. if rep2[3].lower() == ":!unquiet" and trusted:
  214. try:
  215. IRC.send("MODE %s -q %s\r\n" % (rep2[4], rep2[5]))
  216. except IndexError:
  217. IRC.send("MODE %s -q %s\r\n" % (rep2[2], rep2[4]))
  218.  
  219. if rep2[3].lower() == ":!version" or rep2[3].lower() == ":!ver":
  220. IRC.send("PRIVMSG %s :%s\r\n" % (rep2[2], ver + " Versión de LifeBot: " + ver_LifeBot + " " + lang_LifeBot))
  221.  
  222. if rep2[3].lower() == ":!viki" or rep2[3].lower() == ":!vikidia" or rep2[3].lower() == ":!vk":
  223. IRC.send("PRIVMSG %s :%s\r\n" % (rep2[2], "http://" + rep2[4] + ".vikidia.org/wiki/" + "_".join(rep2[5:])))
  224.  
  225. if rep2[3].lower() == ":!voice" and trusted:
  226. try:
  227. IRC.send("MODE %s +v %s\r\n" % (rep2[4], rep2[5]))
  228. except IndexError:
  229. IRC.send("MODE %s +v %s\r\n" % (rep2[2], rep2[4]))
  230.  
  231. if rep2[3].lower() == ":!wp" or rep2[3].lower() == ":!wikipedia":
  232. IRC.send("PRIVMSG %s :%s\r\n" % (rep2[2], "http://" + rep2[4] + ".wikipedia.org/wiki/" + "_".join(rep2[5:])))
  233. #Fin de los comandos que no funcionan en mensaje privado.
  234. #Inicio de comandos que funcionan en mensaje privado y en el canal.
  235. if user_bot.lower() + " es bonito" in " ".join(rep2[3:]).lower() or "eres bonito " + user_bot.lower() in " ".join(rep2[3:]).lower(): #Aquí el bot responderá a tus frases. Por ejemplo, si dices "LifeBot es bonito" ou "Eres bonito LifeBot", el bot responderá "¡Muchas gracias!, tú también eres muy bonito".
  236. IRC.send("PRIVMSG %s :%s\r\n" % (rep2[2], "¡Muchas gracias! Tú también eres muy bonito."))
  237. #Fin de comandos que funcionan en mensaje privado y en el canal.
  238. #No modificar después de esta línea, a no ser que tengas conocimientos de Python.
  239. except IndexError:
  240. IRC.send("PRIVMSG %s :%s\r\n" % (rep2[2], "Error: Faltan parámetros."))
  241.  
  242. #No olvides de presionar "Guardar". En caso de que esté bien tu bot, ¡comenta y pasa el código de tu variante en ##SkyGen!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement