def abusecheck(self, send, nick, target, limit, cmd): """ Rate-limits commands. | If a nick uses commands with the limit attr set, record the time | at which they were used. | If the command is used more than :data:`limit` times in a | minute, ignore the nick. """ if nick not in self.abuselist: self.abuselist[nick] = {} if cmd not in self.abuselist[nick]: self.abuselist[nick][cmd] = [time.time()] else: self.abuselist[nick][cmd].append(time.time()) count = 0 for x in self.abuselist[nick][cmd]: # 60 seconds - arbitrary cuttoff if (time.time() - x) < 60: count = count + 1 if count > limit: text = "%s: don't abuse scores" if cmd == 'scores' else "%s: stop abusing the bot" msg = textutils.gen_creffett(text % nick) send(msg, target=target) self.ignore(send, nick) self.do_kick(send, target, nick, msg, False) return True
def do_kick(self, send, target, nick, msg, slogan=True): """ Kick users. | If kick is disabled, don't do anything. | If the bot is not a op, rage at a op. | Kick the user. """ if not self.kick_enabled: return if target not in self.channels: send("%s: you're lucky, private message kicking hasn't been implemented yet." % nick) return ops = list(self.channels[target].opers()) botnick = self.config['core']['nick'] if botnick not in ops: ops = ['someone'] if not ops else ops send(textutils.gen_creffett("%s: /op the bot" % choice(ops)), target=target) elif random() < 0.01 and msg == "shutting caps lock off": if nick in ops: send("%s: HUEHUEHUE GIBE CAPSLOCK PLS I REPORT U" % nick, target=target) else: self.connection.kick(target, nick, "HUEHUEHUE GIBE CAPSLOCK PLS I REPORT U") else: msg = textutils.gen_slogan(msg).upper() if slogan else msg if nick in ops: send("%s: %s" % (nick, msg), target=target) else: self.connection.kick(target, nick, msg)
def do_kick(self, send, target, nick, msg, slogan=True): """ Kick users. | If kick is disabled, don't do anything. | If the bot is not a op, rage at a op. | Kick the user. """ if not self.kick_enabled: return if target not in self.channels: send( "%s: you're lucky, private message kicking hasn't been implemented yet." % nick) return ops = list(self.channels[target].opers()) botnick = self.config['core']['nick'] if not ops: ops = ['someone'] if nick not in ops: if botnick not in ops and botnick != 'someone': send(textutils.gen_creffett("%s: /op the bot" % choice(ops)), target=target) elif random() < 0.01 and msg == "shutting caps lock off": self.connection.kick(target, nick, "HUEHUEHUE GIBE CAPSLOCK PLS I REPORT U") else: msg = textutils.gen_slogan(msg).upper() if slogan else msg self.connection.kick(target, nick, msg)
def cmd(send, msg, args): """RAGE!!! Syntax: !rage <text> """ if args['name'] == 'creffett': if not args['nick'].startswith('creffett') and args['nick'] != args['botnick']: send("You're not creffett!") args['ignore'](args['nick']) if args['target'] != 'private': args['do_kick'](args['target'], args['nick'], 'creffett impersonation') return if not msg: send("Rage about what?") return # c.send_raw("MODE %s -c" % CHANNEL) send(gen_creffett(msg)) # c.send_raw("MODE %s +c" % CHANNEL) send('</rage>')