def on_ctcp(self, c, e): """Default handler for ctcp events. Replies to VERSION and PING requests and relays DCC requests to the on_dccchat method. """ if e.arguments()[0] == "VERSION": c.ctcp_reply(nm_to_n(e.source()), "VERSION " + self.get_version()) elif e.arguments()[0] == "PING": if len(e.arguments()) > 1: c.ctcp_reply(nm_to_n(e.source()), "PING " + e.arguments()[1]) elif e.arguments()[0] == "DCC" and e.arguments()[1].split( " ", 1)[0] == "CHAT": self.on_dccchat(c, e)
def on_ctcp(self, c, e): """Default handler for ctcp events. Replies to VERSION and PING requests and relays DCC requests to the on_dccchat method. """ if e.arguments()[0] == "VERSION": c.ctcp_reply(nm_to_n(e.source()), "VERSION " + self.get_version()) elif e.arguments()[0] == "PING": if len(e.arguments()) > 1: c.ctcp_reply(nm_to_n(e.source()), "PING " + e.arguments()[1]) elif e.arguments()[0] == "DCC" and e.arguments()[1].split(" ", 1)[0] == "CHAT": self.on_dccchat(c, e)
def on_pubmsg(self, serv, ev): handle = irclib.nm_to_n(ev.source()) canal = ev.target() message = ev.arguments()[0] utils.logs(message) if handle in self.admin: if '!reload' in message: custom_message = utils.extract_message(message, '!reload') self.check_reload(serv, canal, handle, custom_message) if '!enable' in message: custom_message = utils.extract_message(message, '!enable') self.enable(serv, canal, handle, custom_message, True) if '!disable' in message: custom_message = utils.extract_message(message, '!disable') self.enable(serv, canal, handle, custom_message, False) for mod, value in self.mods.items(): if value['cmd'] == message or re.match(r'^' + value['cmd'] + " ", message) is not None: if not self.check_flood(serv, canal, handle): if self.mods[mod]['enabled']: custom_message = utils.extract_message(message, value['cmd']) self.mods[mod]['instance'].execute(serv, canal, handle, custom_message) else: serv.privmsg(canal, "Disabled")
def _on_nick(self, c, e): """[Internal]""" before = nm_to_n(e.source()) after = e.target() for ch in self.channels.values(): if ch.has_user(before): ch.change_nick(before, after)
def _on_join(self, c, e): """[Internal]""" ch = e.target() nick = nm_to_n(e.source()) if nick == c.get_nickname(): self.channels[ch] = Channel() self.channels[ch].add_user(nick)
def on_pubmsg(self, serv, ev): handle = irclib.nm_to_n(ev.source()) canal = ev.target() message = ev.arguments()[0] utils.logs(handle, message) if message.lower() == "test": words = ["abilité", "able", "acelle", "acé", "acée", "acées", "age", "ages", "ai", "aient", "ais", "ait", "ament", "amentaire", "amentaires", "aments", "ant", "as", "asse", "assent", "asses", "assiez", "assions", "ateur", "ateurs", "atrice", "atrices", "âmes", "ât", "âtes", "e", "ent", "er", "era", "erai", "eraient", "erais", "erait", "eras", "erez", "eriez", "erions", "erons", "eront", "eur", "eurs", "èrent", "iculaire", "icule", "icules", "iez", "imonial", "imoniale", "imoniales", "imoniaux", "ions", "ologie", "on", "ons", "ostérone"] wnb = len(words) add = words[randint(0,wnb-1)] serv.privmsg(canal, add) if re.match(r'^wtf_*', handle.lower()) is None: self.mods[ModStat]['instance'].update_counts(handle) if handle in self.admin: if '!reload' in message: custom_message = utils.extract_message(message, '!reload') self.check_reload(serv, canal, handle, custom_message) if '!enable' in message: custom_message = utils.extract_message(message, '!enable') self.enable(serv, canal, handle, custom_message, True) if '!disable' in message: custom_message = utils.extract_message(message, '!disable') self.enable(serv, canal, handle, custom_message, False) for mod, value in self.mods.items(): if value['cmd'] == message or re.match(r'^' + value['cmd'] + " ", message) is not None: if not self.check_flood(serv, canal, handle): if self.mods[mod]['enabled']: custom_message = utils.extract_message(message, value['cmd']) self.mods[mod]['instance'].execute(serv, canal, handle, custom_message) else: serv.privmsg(canal, "Disabled")
def public(self, serv, ev): auteur = irclib.nm_to_n(ev.source()) canal = ev.target() message = ev.arguments()[0] if "!apero" in message: logs("Requested Apero", auteur) try: serv.privmsg(canal, Mod.apero()) logs("Command answered") except: serv.privmsg(canal, "Je n'ai pas pu récupérer correctement l'info, mais vous pouvez la trouver sur ce site: http://estcequecestlapero.fr") logs("Command unsuccessful", author=auteur, info="WARN") elif "!weekend" in message: logs("Requested Weekend from: '" + auteur) serv.privmsg(canal, Mod.weekend()) elif "!help" in message: logs("Requested Help from: '" + auteur) serv.privmsg(canal, "!help !reload !apero !weekend") elif robNick in message: if "stop" in message: logs("Received message '" + message + "' from '" + auteur + "' on '" + canal + "'") self.on_close(serv, canal, auteur) elif "bonjour" in message: logs("Received Bonjour from: '" + auteur) serv.privmsg(canal, "bonjour " + auteur ) elif "!reload" in message and auteur in admin: logs("Requested reload") serv.privmsg(canal, "rechargement de mes facultés") else: logs("Received '" + message + "' from: '" + auteur) serv.privmsg(canal, "je n'ai pas compris!") else: logs(message, auteur)
def _on_part(self, c, e): """[Internal]""" nick = nm_to_n(e.source()) channel = e.target() if nick == c.get_nickname(): del self.channels[channel] else: self.channels[channel].remove_user(nick)
def on_pubmsg(self, serv, ev): auteur = irclib.nm_to_n(ev.source()) canal = ev.target() message = ev.arguments()[0] print message if "!reload" in message and auteur in admin: reload(Mod) reload(Interact) serv.privmsg(canal, "I g0t m0r3 P0w4!") else: Interact.public(self, serv, ev)
def on_privmsg(self, serv, ev): handle = irclib.nm_to_n(ev.source()) canal = ev.target() message = ev.arguments()[0] for mod, value in self.mods.items(): if value['cmd'] == message or re.match(r'^' + value['cmd'] + " ", message) is not None: if not self.check_flood(serv, canal, handle): custom_message = utils.extract_message(message, value['cmd']) self.mods[mod]['instance'].execute(serv, canal, handle, custom_message)
def on_privmsg(self, serv, ev): auteur = irclib.nm_to_n(ev.source()) message = ev.arguments()[0] print(auteur + " >> " + message) if auteur in admin: serv.privmsg(canal, message) logs("Message '" + message + "' transfered to '" + canal + "'") elif auteur == "BotInfo" or auteur == "BotRSS" : serv.privmsg(canal, message) else: serv.privmsg(auteur, "bonjour, merci de m'envoyer des messages privés") logs("Message '" + message + "' received and answered", auteur, "\33[01;31mmsg\33[0m")
def on_privmsg(self, serv, ev): auteur = irclib.nm_to_n(ev.source()) message = ev.arguments()[0] print(auteur + " >> " + message) if auteur in admin: serv.privmsg(canal, message) logs("Message '" + message + "' transfered to '" + canal + "'") #if "stop" in message: # self.on_close(serv, canal, auteur) else: public(serv, ev) serv.privmsg(auteur, "bonjour, merci de m'envoyer des messages privés") logs("Message '" + message + "' received and answered", auteur)
def public(client, serv, ev): auteur = irclib.nm_to_n(ev.source()) canal = ev.target() message = ev.arguments()[0] parse = message.split(' ') if "!apero" in message: logs("Requested Apero", auteur) try: serv.privmsg(canal, Mod.apero()) logs("Command answered") except: serv.privmsg(canal, "Parsing error http://estcequecestbientotlapero.fr") logs("Command unsuccessful", author=auteur, info="WARN") elif "!weekend" in message: try: logs("requested Weekend", auteur) serv.privmsg(canal, Mod.weekend()) except: logs("Failure!", info="Debug") serv.privmsg(canal, "marche pas :(") elif message == "!ctfs": liste = Mod.ctf() for elt in liste: serv.privmsg(canal, elt) elif "!help" == message: logs("Requested Help from: '" + auteur) serv.privmsg(canal, "!help !ctf !ctfs !reload !apero !weekend !pastis") elif message in "!pastis": serv.kick(canal, auteur, "tu me prends pour un serveur?") elif "!nick" in message: msg = message.split(" ") if len(msg) >= 2: serv.nick(msg[1]) else: serv.privmsg(canal, "il faut un nom!") elif "!ctf" == message.split(" ")[0]: logs("Requested ctf score") try: serv.privmsg(canal, Mod.score(message.split(" ")[1])) except: serv.privmsg(canal, Mod.score()) elif message == "!café": serv.privmsg(canal, "dis donc, tu me prends pour un esclave?") elif message == "!biere": serv.privmsg(canal, "Et un openbar, un!") elif robNick in message: if "stop" in message: if auteur in admin: logs("Received message '" + message + "' from '" + auteur + "' on '" + canal + "'") client.on_close(serv, canal, auteur) else: serv.privmsg( canal, "Méchant " + auteur + " tu voulais me faire partir?") logs("sent stop signal!", auteur, "\33[01;31mWARN\33[0m") elif "bonjour" in message: logs("Received Bonjour from: '" + auteur) serv.privmsg(canal, "bonjour " + auteur) else: logs("Received '" + message + "' from: '" + auteur) else: parse = message.strip().split(' ') print parse if parse[0] in [ '!score', '!s', '!last', '!lastflag', '!chall', '!challenges' ]: if len(parse) >= 2: serv.privmsg("BotRSS", message) serv.privmsg("BotInfo", message) else: serv.privmsg("BotInfo", parse[0] + " " + auteur) elif "!choosechall" == parse[0]: nick = auteur if len(parse) >= 2: nick = parse[1] serv.privmsg(canal, Mod.choosechall(nick)) elif len(parse) == 3 and parse[0] == "kick" and parse[2] == "please": serv.privmsg(canal, "Yes Master!") if parse[1] in admin: serv.kick(canal, auteur, "Héhé, DTC") else: serv.kick(canal, parse[1], "haha")
def _on_quit(self, c, e): """[Internal]""" nick = nm_to_n(e.source()) for ch in self.channels.values(): if ch.has_user(nick): ch.remove_user(nick)
def public(client, serv, ev): auteur = irclib.nm_to_n(ev.source()) canal = ev.target() message = ev.arguments()[0] parse = message.split(' ') if "!apero" in message: logs("Requested Apero", auteur) try: serv.privmsg(canal, Mod.apero()) logs("Command answered") except: serv.privmsg(canal, "Parsing error http://estcequecestbientotlapero.fr") logs("Command unsuccessful", author=auteur, info="WARN") elif "!weekend" in message: try: logs("requested Weekend", auteur) serv.privmsg(canal, Mod.weekend()) except: logs("Failure!", info="Debug") serv.privmsg(canal, "marche pas :(") elif message == "!ctfs": liste = Mod.ctf() for elt in liste: serv.privmsg(canal, elt) elif "!help" == message: logs("Requested Help from: '" + auteur) serv.privmsg(canal, "!help !ctf !ctfs !reload !apero !weekend !pastis") elif message in "!pastis": serv.kick(canal, auteur, "tu me prends pour un serveur?") elif "!nick" in message: msg = message.split(" ") if len(msg) >= 2: serv.nick(msg[1]) else: serv.privmsg(canal, "il faut un nom!") elif "!ctf" == message.split(" ")[0]: logs("Requested ctf score") try: serv.privmsg(canal, Mod.score(message.split(" ")[1])) except: serv.privmsg(canal, Mod.score()) elif message == "!café": serv.privmsg(canal, "dis donc, tu me prends pour un esclave?") elif message == "!biere": serv.privmsg(canal, "Et un openbar, un!") elif robNick in message: if "stop" in message: if auteur in admin: logs("Received message '" + message + "' from '" + auteur + "' on '" + canal + "'") client.on_close(serv, canal, auteur) else: serv.privmsg(canal, "Méchant " + auteur + " tu voulais me faire partir?") logs("sent stop signal!", auteur, "\33[01;31mWARN\33[0m") elif "bonjour" in message: logs("Received Bonjour from: '" + auteur) serv.privmsg(canal, "bonjour " + auteur) else: logs("Received '" + message + "' from: '" + auteur) else: parse = message.strip().split(' ') print parse if parse[0] in ['!score','!s','!last','!lastflag', '!chall', '!challenges']: if len(parse) >= 2: serv.privmsg("BotRSS", message) serv.privmsg("BotInfo", message) else: serv.privmsg("BotInfo", parse[0] + " " + auteur) elif "!choosechall" == parse[0]: nick = auteur if len(parse) >= 2: nick = parse[1] serv.privmsg(canal, Mod.choosechall(nick)) elif len(parse) == 3 and parse[0] == "kick" and parse[2] == "please": serv.privmsg(canal, "Yes Master!") if parse[1] in admin: serv.kick(canal, auteur, "Héhé, DTC") else: serv.kick(canal, parse[1], "haha")
def on_join(self, serv, ev): handle = irclib.nm_to_n(ev.source()) canal = ev.target()