def subs(g): key = g.group(0)[1:] if key in mapping: return mapping[key] elif key == "insult": return generate_vulgarity().lower() elif key == "INSULT": return generate_vulgarity().upper() else: return "\\" + key
def trigger(self, server, msg): nick = server.lower(msg.address.nick) if nick in self.history: self.history[nick] = [ i for i in self.history[nick] if time.time() - i[0] < 150 ] self.history[nick].append( (time.time(), time.time() - self.history[nick][-1][0] if self.history[nick] else 0)) self.history[nick] = self.history[nick][-4:] else: self.history[nick] = [(time.time(), 0)] if (sum(i[0] for i in self.history[nick]) / len(self.history[nick]) < 1.5 or (len(self.history[nick]) - 1 and sum( abs(self.history[nick][i][-1] - self.history[nick][i - 1][-1]) for i in range(1, len(self.history[nick]))) / len(self.history[nick]) < 2)): server.printer.message( "hey %s, f**k off and let others have a go" % generate_vulgarity().lower(), msg.address.nick, "NOTICE") else: self.num += 1 open(self.addfile, 'w').write(str(self.num)) return "2Thanks %s, 3the number has been increased to %s."\ % (msg.address.nick, self.num)
def trigger(self, server, msg): nick = server.lower(msg.address.nick) if nick in self.history: self.history[nick] = [i for i in self.history[nick] if time.time() - i[0] < 150] self.history[nick].append((time.time(), time.time() - self.history[nick][-1][0] if self.history[nick] else 0)) self.history[nick] = self.history[nick][-4:] else: self.history[nick] = [(time.time(), 0)] if (sum(i[0] for i in self.history[nick]) / len(self.history[nick]) < 1.5 or (len(self.history[nick]) - 1 and sum(abs(self.history[nick][i][-1] - self.history[nick][i-1][-1]) for i in range(1, len(self.history[nick]))) / len(self.history[nick]) < 2)): server.printer.message("hey %s, f**k off and let others have a go" % generate_vulgarity().lower(), msg.address.nick, "NOTICE") else: self.num += 1 open(self.addfile, 'w').write(str(self.num)) return "2Thanks %s, 3the number has been increased to %s."\ % (msg.address.nick, self.num)
def subtract(self, server, msg): msged = msg.context if msged in self.msged and time.time() - self.msged[msged] < 600: return "WHAT DID I F*****G SAY, %s?" % generate_vulgarity() self.msged[msged] = time.time() return "YOU CAN ONLY ADD, %s." % generate_vulgarity()