Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- # Autor: Simon Kempf
- # Traducción al español: Dimichi Cháchara
- # IMPORTANTE : SkyGen no se hace responsable del uso del bot o el abuso del mismo.
- # Lee ésto si haces una modificación o editas el bot :
- # 1) Copia los comandos que has creado en la antigua versión a la nueva versión.
- # 2) Si has editado un comando, debes suprimir el código de la nueva versión cambiándolo al de la nueva versión.
- import socket, time, urllib, webbrowser #Imports, ne pas modifier sauf si vous connaîssez Python.
- chan = "##Lanaima-social"
- #Canal a donde irá el bot
- user_bot = "Dorami-Bot"
- #nick del bot
- ver = "LifeBot 1.5 - Todos los derechos reservados: Dimichi Cháchara y Simon Kempf"
- #Versión del bot
- host = "irc.freenode.net"
- #Red IRC
- port = 6667
- #Puerto de la red IRC
- trust = []
- #Los usuarios que pueden usar comandos especiales.
- #Versión de LifeBot:
- ver_LifeBot = "1.5.0"
- lang_LifeBot = "es"
- print(ver)
- #Contraseña:
- 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: ")
- #Conexión a IRC:
- identify = False
- IRC = socket.socket()
- IRC.connect((host, port))
- IRC.send("NICK %s\r\n" % user_bot)
- IRC.send("USER LifeBot %s bla :%s\r\n" % (host, user_bot))
- #Bucle de conexión:
- while True:
- rep = IRC.recv(2048)
- rep2 = rep.split()
- print(rep)
- #
- try:
- if ":End of /MOTD command." in rep and identify == False:
- IRC.send("PRIVMSG NickServ :identify %s\r\n" % password)
- IRC.send("JOIN %s\r\n" % chan)
- identify = True
- #Respuesta al ping de la red IRC:
- if rep2[0] == "PING":
- IRC.send("PONG %s\r\n" % rep2[1])
- #Respuesta a las invitaciones del bot:
- if rep2[1] == "INVITE":
- IRC.send("JOIN %s\r\n" % rep2[3])
- except IndexError:
- rep2 = ["", "", "", "", "", "", "", "", "", ""]
- #
- user = rep2[0].split("!")
- user[0] = user[0].strip(":")
- trusted = user[0] in trust
- if rep2[1] == "PRIVMSG":
- try:
- if rep2[2].startswith("#") == False:
- rep2[2] = user[0]
- #Fin de los datos básicos de bot.
- #Inicio de comandos privados.
- if rep2[3].lower() == ":!identify":
- try:
- IRC.send("PRIVMSG NickServ :identify %s %s\r\n" % (rep2[4], rep2[5]))
- except IndexError:
- IRC.send("PRIVMSG NickServ :identify %s\r\n" % rep2[4])
- #Fin de comandos funcionales únicamente en mensaje privado.
- else: #No agregar nada aquí.
- #Inicio de comandos no funcionales en mensaje privado.
- #Inicio de la sintaxis.
- if rep2[3].lower() == ":!prueba":
- IRC.send("PRIVMSG %s :%s\r\n" % (rep2[2], "Texto a enviar"))
- #Fin de la sintaxis.
- #Sigue la sintaxis de arriba cuando quieras agregar un nuevo comando. ¿Necesitas ayuda? Consulta en ##SkyGen
- if rep2[3].lower() == ":!ban" and trusted: #Aquí, un comando
- try:
- 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)
- except IndexError: #Si no pusiste el nombre del canal (ejemplo, si pones !ban bidule)
- 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)
- if rep2[3].lower() == ":!bing":
- IRC.send("PRIVMSG %s :%s\r\n" % (rep2[2], "http://www.bing.com/search?q=" + "+".join(rep2[4:])))
- if (rep2[3].lower() == ":!chanserv" or rep2[3].lower() == ":!cs") and trusted: #Este comando envía un mensaje a ChanServ. Ver los comandos ChanServ.
- IRC.send("PRIVMSG ChanServ :%s\r\n" % " ".join(rep2[4:]))
- if (rep2[3].lower() == ":!chanserv_access" or rep2[3].lower() == ":!cs_access") and trusted:
- try:
- IRC.send("PRIVMSG ChanServ :access %s add %s %s\r\n" % (rep2[4], rep2[5], rep2[6]))
- except IndexError:
- IRC.send("PRIVMSG ChanServ :access %s add %s %s\r\n" % (rep2[2], rep2[4], rep2[5]))
- if (rep2[3].lower() == ":!chanserv_access_del" or rep2[3].lower() == ":!cs_access_del") and trusted:
- try:
- IRC.send("PRIVMSG ChanServ :access %s del %s\r\n" % (rep2[4], rep2[5]))
- except IndexError:
- IRC.send("PRIVMSG ChanServ :access %s del %s\r\n" % (rep2[2], rep2[4]))
- if (rep2[3].lower() == ":!chanserv_akick" or rep2[3].lower() == ":!cs_akick") and trusted: #Comando para akickear
- try:
- IRC.send("PRIVMSG ChanServ :akick %s add %s\r\n" % (rep2[4], rep2[5]))
- except IndexError:
- IRC.send("PRIVMSG ChanServ :akick %s add %s\r\n" % (rep2[2], rep2[4]))
- 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.
- try:
- IRC.send("PRIVMSG ChanServ :akick %s del %s\r\n" % (rep2[4], rep2[5]))
- except IndexError:
- IRC.send("PRIVMSG ChanServ :akick %s del %s\r\n" % (rep2[2], rep2[4]))
- if (rep2[3].lower() == ":!chanserv_flags" or rep2[3].lower() == ":!cs_flags") and trusted:
- try:
- IRC.send("PRIVMSG ChanServ :flags %s %s %s\r\n" % (rep2[4], rep2[5], rep2[6]))
- except IndexError:
- IRC.send("PRIVMSG ChanServ :flags %s %s %s\r\n" % (rep2[2], rep2[4], rep2[5]))
- if rep2[3].lower() == ":!deop" and trusted: #Aquí un comando que quita el status de op al usuario.
- try:
- IRC.send("MODE %s -o %s\r\n" % (rep2[4], rep2[5]))
- except IndexError:
- IRC.send("MODE %s -o %s\r\n" % (rep2[2], rep2[4]))
- if rep2[3].lower() == ":!devoice" and trusted:
- try:
- IRC.send("MODE %s -v %s\r\n" % (rep2[4], rep2[5]))
- except IndexError:
- IRC.send("MODE %s -v %s\r\n" % (rep2[2], rep2[4]))
- if rep2[3].lower() == ":!flood":
- IRC.send("PRIVMSG %s :%s\r\n" % (rep2[2], "El flood está prohibido bajo pena de ban."))
- #Entre estos dos comentarios puedes ver un comando simple.
- if rep2[3].lower() == ":!google":
- IRC.send("PRIVMSG %s :%s\r\n" % (rep2[2], "https://www.google.com.pe/#q=" + "+".join(rep2[4:])))
- if rep2[3].lower() == ":!help" or rep2[3].lower() == ":!ayuda":
- IRC.send("PRIVMSG %s :%s\r\n" % (rep2[2], "http://skygenrepo.weebly.com/lifebot.html" + lang_LifeBot + "/LifeBot/"))
- if rep2[3].lower() == ":!ip":
- IRC.send("PRIVMSG %s :%s\r\n" % (rep2[2], "https://whatismyipaddress.com/ip/" + rep2[4]))
- if rep2[3].lower() == ":!join":
- IRC.send("JOIN %s\r\n" % rep2[4])
- if rep2[3].lower() == ":!kick" and trusted:
- if " ".join(rep2[5:]) != "":
- IRC.send("KICK %s %s :%s\r\n" % (rep2[2], rep2[4], " ".join(rep2[5:])))
- else:
- IRC.send("KICK %s %s\r\n" % (rep2[2], rep2[4]))
- if rep2[3].lower() == ":!kickban" and trusted:
- IRC.send("MODE %s +b %s\r\n" % (rep2[2], rep2[4]))
- if " ".join(rep2[5:]) != "":
- IRC.send("KICK %s %s :%s\r\n" % (rep2[2], rep2[4], " ".join(rep2[5:])))
- else:
- IRC.send("KICK %s %s\r\n" % (rep2[2], rep2[4]))
- if rep2[3].lower() == ":!love":
- IRC.send("PRIVMSG %s :%s\r\n" % (rep2[2], "Yo no te amo..."))
- IRC.send("PRIVMSG %s :%s\r\n" % (rep2[2], "...pero te amo, a veces."))
- # ¿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).
- if rep2[3].lower() == ":!mode" and trusted:
- try:
- IRC.send("MODE %s %s %s\r\n" % (rep2[4], rep2[5], rep2[6]))
- except IndexError:
- IRC.send("MODE %s %s %s\r\n" % (rep2[2], rep2[4], rep2[5]))
- if rep2[3].lower() == ":!modechan" and trusted:
- try:
- IRC.send("MODE %s %s\r\n" % (rep2[4], rep2[5]))
- except IndexError:
- IRC.send("MODE %s %s\r\n" % (rep2[2], rep2[4]))
- if rep2[3].lower() == ":!news" or rep2[3].lower() == ":!wikinews":
- IRC.send("PRIVMSG %s :%s\r\n" % (rep2[2], "http://" + rep2[4] + ".wikinews.org/wiki/" + "_".join(rep2[5:])))
- if rep2[3].lower() == ":!nick" and trusted: #Aquí, un comando que cambia el nick del bot
- IRC.send("NICK %s\r\n" % rep2[4])
- if rep2[3].lower() == ":!op" and trusted:
- try:
- IRC.send("MODE %s +o %s\r\n" % (rep2[4], rep2[5]))
- except IndexError:
- IRC.send("MODE %s +o %s\r\n" % (rep2[2], rep2[4]))
- if rep2[3].lower() == ":!part" or rep2[3].lower() == ":!quit":
- IRC.send("PART %s\r\n" % rep2[4])
- if rep2[3].lower() == ":!plagio":
- IRC.send("PRIVMSG %s :%s\r\n" % (rep2[2], "http://plagiarisma.net/es/"))
- if rep2[3].lower() == ":!quiet" and trusted:
- try:
- IRC.send("MODE %s +q %s\r\n" % (rep2[4], rep2[5]))
- except IndexError:
- IRC.send("MODE %s +q %s\r\n" % (rep2[2], rep2[4]))
- if rep2[3].lower() == ":!unban" and trusted:
- try:
- IRC.send("MODE %s -b %s\r\n" % (rep2[4], rep2[5]))
- except IndexError:
- IRC.send("MODE %s -b %s\r\n" % (rep2[2], rep2[4]))
- if rep2[3].lower() == ":!unquiet" and trusted:
- try:
- IRC.send("MODE %s -q %s\r\n" % (rep2[4], rep2[5]))
- except IndexError:
- IRC.send("MODE %s -q %s\r\n" % (rep2[2], rep2[4]))
- if rep2[3].lower() == ":!version" or rep2[3].lower() == ":!ver":
- IRC.send("PRIVMSG %s :%s\r\n" % (rep2[2], ver + " Versión de LifeBot: " + ver_LifeBot + " " + lang_LifeBot))
- if rep2[3].lower() == ":!viki" or rep2[3].lower() == ":!vikidia" or rep2[3].lower() == ":!vk":
- IRC.send("PRIVMSG %s :%s\r\n" % (rep2[2], "http://" + rep2[4] + ".vikidia.org/wiki/" + "_".join(rep2[5:])))
- if rep2[3].lower() == ":!voice" and trusted:
- try:
- IRC.send("MODE %s +v %s\r\n" % (rep2[4], rep2[5]))
- except IndexError:
- IRC.send("MODE %s +v %s\r\n" % (rep2[2], rep2[4]))
- if rep2[3].lower() == ":!wp" or rep2[3].lower() == ":!wikipedia":
- IRC.send("PRIVMSG %s :%s\r\n" % (rep2[2], "http://" + rep2[4] + ".wikipedia.org/wiki/" + "_".join(rep2[5:])))
- #Fin de los comandos que no funcionan en mensaje privado.
- #Inicio de comandos que funcionan en mensaje privado y en el canal.
- 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".
- IRC.send("PRIVMSG %s :%s\r\n" % (rep2[2], "¡Muchas gracias! Tú también eres muy bonito."))
- #Fin de comandos que funcionan en mensaje privado y en el canal.
- #No modificar después de esta línea, a no ser que tengas conocimientos de Python.
- except IndexError:
- IRC.send("PRIVMSG %s :%s\r\n" % (rep2[2], "Error: Faltan parámetros."))
- #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