def _slot(self, lastItem): irc = lastItem.irc msg = lastItem.msg channel = lastItem.channel prefix = lastItem.prefix nick = prefix.split('!')[0] kind = lastItem.kind try: ircdb.users.getUser(msg.prefix) # May raise KeyError capability = self.registryValue('exempt') if capability: if ircdb.checkCapability(msg.prefix, capability): return except KeyError: pass punishment = self.registryValue('%s.punishment' % kind, channel) reason = _('%s flood detected') % kind if punishment == 'kick': msg = ircmsgs.kick(channel, nick, reason) irc.queueMsg(msg) elif punishment == 'ban': msg = ircmsgs.ban(channel, prefix) irc.queueMsg(msg) elif punishment == 'kban': msg = ircmsgs.kick(channel, nick, reason) irc.queueMsg(msg) msg = ircmsgs.ban(channel, prefix) irc.queueMsg(msg) elif punishment.startswith('mode'): msg = ircmsgs.mode(channel, punishment[len('mode'):]) irc.queueMsg(msg) elif punishment.startswith('command '): tokens = callbacks.tokenize(punishment[len('command '):]) self.Proxy(irc, msg, tokens)
def detonate(self, irc): self.active = False self.thrown = False if self.showCorrectWire: self.irc.sendMsg(ircmsgs.privmsg(self.channel, 'Should\'ve gone for the {} wire!'.format(self.goodWire))) if self.showArt: self.irc.sendMsg(ircmsgs.privmsg(self.channel, '\x031,1.....\x0315,1_.\x0314,1-^^---....,\x0315,1,-_\x031,1.......')) self.irc.sendMsg(ircmsgs.privmsg(self.channel, '\x031,1.\x0315,1_--\x0314,1,.\';,`.,\';,.;;`;,.\x0315,1--_\x031,1...')) self.irc.sendMsg(ircmsgs.privmsg(self.channel, '\x0315,1<,.\x0314,1;\'`".,;`..,;`*.,\';`.\x0315,1;\'>)\x031,1.')) self.irc.sendMsg(ircmsgs.privmsg(self.channel, '\x0315,1I.:;\x0314,1.,`;~,`.;\'`,.;\'`,..\x0315,1\';`I\x031,1.')) self.irc.sendMsg(ircmsgs.privmsg(self.channel, '\x031,1.\x0315,1\\_.\x0314,1`\'`..`\';.,`\';,`\';,\x0315,1_../\x031,1..')) self.irc.sendMsg(ircmsgs.privmsg(self.channel, '\x031,1....\x0315,1```\x0314,1--. . , ; .--\x0315,1\'\'\'\x031,1.....')) self.irc.sendMsg(ircmsgs.privmsg(self.channel, '\x031,1..........\x034,1I\x031,1.\x038,1I\x037,1I\x031,1.\x038,1I\x034,1I\x031,1...........')) self.irc.sendMsg(ircmsgs.privmsg(self.channel, '\x031,1..........\x034,1I\x031,1.\x037,1I\x038,1I\x031,1.\x037,1I\x034,1I\x031,1...........')) self.irc.sendMsg(ircmsgs.privmsg(self.channel, '\x031,1.......,\x034,1-=\x034,1II\x037,1..I\x034,1.I=-,\x031,1........')) self.irc.sendMsg(ircmsgs.privmsg(self.channel, '\x031,1.......\x034,1`-=\x037,1#$\x038,1%&\x037,1%$#\x034,1=-\'\x031,1........')) else: self.irc.sendMsg(ircmsgs.privmsg(self.channel, 'KABOOM!')) if self.showCorrectWire: self.irc.queueMsg(ircmsgs.kick(self.channel, self.victim, 'BOOM! You should\'ve gone for the {} wire!'.format(self.goodWire))) else: self.irc.queueMsg(ircmsgs.kick(self.channel, self.victim, 'BOOM!')) def reinvite(): if self.victim not in irc.state.channels[self.channel].users: self.irc.queueMsg(ircmsgs.invite(self.victim, self.channel)) if not self.responded: schedule.addEvent(reinvite, time.time() + 5)
def _gegen(self, irc, msg, target): if self._is_voting_enabled(irc, msg, reply=True) and self._check_privileges(irc, msg, reply=True): channel = msg.args[0] users = irc.state.channels[channel].users voting_id = self._calculate_id(target, channel) if target == msg.nick or target == irc.nick: if self._can_be_kicked(irc, channel, msg.nick): irc.queueMsg(ircmsgs.kick(channel, msg.nick, "Snibeti snab XDD")) self._user_left(irc, msg.nick, channel) return if voting_id in self.running_votes: voting = self.running_votes[voting_id] if voting.add_vote(msg.nick): voting_count = voting.count_votes(users) if voting_count >= voting.threshold: if target in irc.state.channels[channel].ops: irc.queueMsg(ircmsgs.notice(channel, "Einen Versuch war's wert! :--D")) for nick in voting.votes: if self._can_be_kicked(irc, channel, nick): irc.queueMsg(ircmsgs.kick(channel, nick, "Bis zum nächsten mal!")) self._user_left(irc, nick, channel) else: self._remove_kebab(irc, channel, target) del self.running_votes[voting_id] else: irc.reply("Stimme gegen %s registriert. Braucht noch %d weitere Stimme(n)." % ( target, voting.threshold - voting_count)) else: voting_count = voting.count_votes(users) irc.reply("Du hast bereits gegen %s gestimmt! Braucht noch %d weitere Stimme(n)." % ( target, voting.threshold - voting_count)) else: active_users = self._calculate_active_user(irc, msg) if target not in active_users: irc.reply("%s ist inaktiv. Antrag abgelehnt." % target) return voting_threshold = self._calculate_voting_threshold(irc, msg, active_users) voting = Voting(channel, target, msg.nick, voting_threshold) voting.add_vote(msg.nick) self.running_votes[voting_id] = voting def clean_up(): if voting_id in self.running_votes: message = "Abstimmung gegen %s ist erfolglos ausgelaufen." % self.running_votes[voting_id].target irc.queueMsg(ircmsgs.notice(channel, message)) del self.running_votes[voting_id] schedule.addEvent(clean_up, time.time() + int(self.registryValue("voting_timeout"))) irc.reply("Abstimmung gegen %s gestartet. Braucht noch %d weitere Stimme(n)." % ( target, voting.threshold - 1))
def _slot(self, lastItem): irc = lastItem.irc msg = lastItem.msg channel = lastItem.channel prefix = lastItem.prefix nick = prefix.split('!')[0] kind = lastItem.kind if not ircutils.isChannel(channel): return if not self.registryValue('enable', channel): return try: ircdb.users.getUser(msg.prefix) # May raise KeyError capability = self.registryValue('exempt') if capability: if ircdb.checkCapability(msg.prefix, ','.join([channel, capability])): self.log.info('Not punishing %s: they are immune.' % prefix) return except KeyError: pass punishment = self.registryValue('%s.punishment' % kind, channel) reason = _('%s flood detected') % kind if punishment == 'kick': self._eventCatcher(irc, msg, 'kicked', kicked_prefix=prefix) if kind == 'kicked': reason = _('You exceeded your kick quota.') banmaskstyle = conf.supybot.protocols.irc.banmask banmask = banmaskstyle.makeBanmask(prefix) if punishment == 'kick': msg = ircmsgs.kick(channel, nick, reason) irc.queueMsg(msg) elif punishment == 'ban': msg = ircmsgs.ban(channel, banmask) irc.queueMsg(msg) elif punishment == 'kban': msg = ircmsgs.ban(channel, banmask) irc.queueMsg(msg) msg = ircmsgs.kick(channel, nick, reason) irc.queueMsg(msg) elif punishment.startswith('mode'): msg = ircmsgs.mode(channel, punishment[len('mode'):]) irc.queueMsg(msg) elif punishment.startswith('umode'): msg = ircmsgs.mode(channel, (punishment[len('umode'):], nick)) irc.queueMsg(msg) elif punishment.startswith('command '): tokens = callbacks.tokenize(punishment[len('command '):]) self.Proxy(irc, msg, tokens)
def inFilter(self, irc, msg): self.filtering = True # We need to check for bad words here rather than in doPrivmsg because # messages don't get to doPrivmsg is the user is ignored. if msg.command == 'PRIVMSG': self.updateRegexp() s = ircutils.stripFormatting(msg.args[1]) channel = msg.args[0] if ircutils.isChannel(channel) and self.registryValue( 'kickban', channel): if self.regexp.search(s): if irc.nick in irc.state.channels[channel].ops: message = self.registryValue('kickban.message', channel) bannedHostmask = irc.state.nickToHostmask(msg.nick) banmaskstyle = conf.supybot.protocols.irc.banmask banmask = banmaskstyle.makeBanmask(bannedHostmask) irc.queueMsg(ircmsgs.ban(channel, banmask)) irc.queueMsg(ircmsgs.kick(channel, msg.nick, message)) expiry = self.registryValue('kickban.banexpire', channel) if expiry > 0: def f(): if channel in irc.state.channels and \ banmask in irc.state.channels[channel].bans: irc.queueMsg( ircmsgs.unban(channel, banmask)) schedule.addEvent(f, time.time() + expiry) else: self.log.warning( 'Should kickban %s from %s, but not opped.', msg.nick, channel) else: if ircutils.isChannel(channel) and self.registryValue( 'kick', channel): if self.regexp.search(s): if irc.nick in irc.state.channels[channel].ops: message = self.registryValue( 'kick.message', channel) irc.queueMsg( ircmsgs.kick(channel, msg.nick, message)) else: self.log.warning( 'Should kick %s from %s, but not opped.', msg.nick, channel) return msg
def doPrivmsg(self, irc, msg): channel, text = msg.args text = text.lower() if '#' in channel: #print self.regex #irc.reply('testing %s against %s' % (text, self._regexString)) if self.regex.match(text): try: hostmask = irc.state.nickToHostmask(msg.nick) except KeyError: return (nick, user, host) = ircutils.splitHostmask(hostmask) user = self._fnUser.sub('*', user) banmask = ircutils.joinHostmask('*', user, msg.host) if ircutils.hostmaskPatternEqual(banmask, irc.prefix): return irc.queueMsg(ban(channel, banmask, 'For swearing. 5 minute timeout')) irc.queueMsg(kick(channel, msg.nick, 'For swearing')) def unBan(): if channel in irc.state.channels and \ banmask in irc.state.channels[channel].bans: irc.queueMsg(unban(channel, banmask)) schedule.addEvent(unBan, time.time()+300) elif 'f*g' in text.split(): try: hostmask = irc.state.nickToHostmask(msg.nick) except KeyError: return (nick, user, host) = ircutils.splitHostmask(hostmask) irc.reply('No thanks %s I don\'t smoke' % user) return msg
def inFilter(self, irc, msg): self.filtering = True # We need to check for bad words here rather than in doPrivmsg because # messages don't get to doPrivmsg if the user is ignored. if msg.command == 'PRIVMSG': channel = msg.args[0] self.updateRegexp(channel) s = ircutils.stripFormatting(msg.args[1]) if ircutils.isChannel(channel) and self.registryValue('kick', channel): if self.words and self.regexp.search(s): c = irc.state.channels[channel] cap = ircdb.makeChannelCapability(channel, 'op') if c.isHalfopPlus(irc.nick): if c.isHalfopPlus(msg.nick) or \ ircdb.checkCapability(msg.prefix, cap): self.log.debug("Not kicking %s from %s, because " "they are halfop+ or can't be " "kicked.", msg.nick, channel) else: message = self.registryValue('kick.message', channel) irc.queueMsg(ircmsgs.kick(channel, msg.nick, message)) else: self.log.warning('Should kick %s from %s, but not opped.', msg.nick, channel) return msg
def roulette(self, irc, msg, args, spin): """[spin] Fires the revolver. If the bullet was in the chamber, you're dead. Tell me to spin the chambers and I will. """ if spin: self._rouletteBullet = random.randrange(0, 6) irc.reply(_('*SPIN* Are you feeling lucky?'), prefixNick=False) return channel = msg.args[0] if self._rouletteChamber == self._rouletteBullet: self._rouletteBullet = random.randrange(0, 6) self._rouletteChamber = random.randrange(0, 6) if irc.nick in irc.state.channels[channel].ops or \ irc.nick in irc.state.channels[channel].halfops: irc.queueMsg(ircmsgs.kick(channel, msg.nick, 'BANG!')) else: irc.reply(_('*BANG* Hey, who put a blank in here?!'), prefixNick=False) irc.reply(_('reloads and spins the chambers.'), action=True) else: irc.reply(_('*click*')) self._rouletteChamber += 1 self._rouletteChamber %= 6
def saveLast(self,irc,msg,match): r".+" channel = msg.args[0] try: self.buffer[channel] except: self.buffer[channel]=[] # Stuff for multikick if channel in self.kickuser: for each in self.kickuser[channel]: if each in msg.nick.lower() and not self.kickuser[channel][each]['num'] <= 0: irc.queueMsg(ircmsgs.ban(msg.args[0], msg.nick)) irc.queueMsg(ircmsgs.kick(msg.args[0], msg.nick, "{}".format(self.kickuser[channel][each]['msg'].replace('#n',str(self.kickuser[channel][each]['num']))))) self.kickuser[channel][each]['num']-=1 def un(): irc.queueMsg(ircmsgs.unban(msg.args[0],msg.nick)) schedule.addEvent(un,time.time()+random.randint(10,60)) # 30,120 # END line = match.group(0).replace('\x01ACTION','*').strip('\x01') if msg.nick.lower() in self.annoyUser: def fu(): irc.queueMsg(ircmsgs.IrcMsg('NOTICE {} :\x02\x03{},{}{}'.format(msg.nick,random.randint(0,15),random.randint(0,15),line))) schedule.addEvent(fu,time.time()+random.randint(2,60)) if re.match(r"^u[/].*[/].*[/].*$", match.group(0)) or re.match(r"^s[/].*[/].*$", match.group(0)): return 1 self.buffer[channel].insert(0,[msg.nick,line]) if len(self.buffer[channel]) > self.buffsize: self.buffer[channel].pop(self.buffsize) return 1
def inFilter(self, irc, msg): self.filtering = True # We need to check for bad words here rather than in doPrivmsg because # messages don't get to doPrivmsg if the user is ignored. if msg.command == 'PRIVMSG' and self.words(): channel = msg.args[0] self.updateRegexp(channel) s = ircutils.stripFormatting(msg.args[1]) if irc.isChannel(channel) and self.registryValue('kick', channel): if self.regexp.search(s): c = irc.state.channels[channel] cap = ircdb.makeChannelCapability(channel, 'op') if c.isHalfopPlus(irc.nick): if c.isHalfopPlus(msg.nick) or \ ircdb.checkCapability(msg.prefix, cap): self.log.debug( "Not kicking %s from %s, because " "they are halfop+ or can't be " "kicked.", msg.nick, channel) else: message = self.registryValue( 'kick.message', channel) irc.queueMsg( ircmsgs.kick(channel, msg.nick, message)) else: self.log.warning( 'Should kick %s from %s, but not opped.', msg.nick, channel) return msg
def detonate(self, irc): self.active = False #if self.showCorrectWire: # self.irc.reply('Should\'ve gone for the %s wire!' % self.goodWire) self.irc.sendMsg( ircmsgs.privmsg(self.channel, ' .___ ')) self.irc.sendMsg( ircmsgs.privmsg(self.channel, ' (,) O/```````````````````````````````````')) self.irc.sendMsg( ircmsgs.privmsg(self.channel, 'c [| >->o ')) self.irc.sendMsg( ircmsgs.privmsg(self.channel, ' \___________________________________')) self.active = False self.thrown = False self.irc.queueMsg( ircmsgs.kick(self.channel, self.victim, 'shoop da woop')) def reinvite(): if not self.victim in irc.state.channels[self.channel].users: self.irc.queueMsg(ircmsgs.invite(self.victim, self.channel)) if not self.responded: schedule.addEvent(reinvite, time.time() + 5)
def floodPunish(self, irc, msg, floodType, dummy = False): channel = msg.args[0] if (not irc.nick in irc.state.channels[channel].ops) and\ (not irc.nick in irc.state.channels[channel].halfops): self.log.warning("%s flooded in %s, but not opped.",\ msg.nick, channel) return if msg.nick in self.immunities: self.log.debug("Not punnishing %s, they are immune.", msg.nick) return if msg.nick in irc.state.channels[channel].ops or\ msg.nick in irc.state.channels[channel].halfops or\ msg.nick in irc.state.channels[channel].voices: self.log.debug("%s flooded in %s. But"\ + " I will not punish them because they have"\ + " special access.", msg.nick, channel) return if ircdb.checkCapability(msg.prefix, 'trusted') or\ ircdb.checkCapability(msg.prefix, 'admin') or\ ircdb.checkCapability(msg.prefix, channel + ',op'): self.log.debug("%s flooded in %s. But"\ + " I will not punish them because they are"\ + " trusted.", msg.nick, channel) return if msg.host in self.offenses and self.offenses[msg.host] > 2: hostmask = irc.state.nickToHostmask(msg.nick) banmaskstyle = conf.supybot.protocols.irc.banmask banmask = banmaskstyle.makeBanmask(hostmask) if not dummy: irc.queueMsg(ircmsgs.ban(channel, banmask)) self.log.warning("Banned %s (%s) from %s for repeated"\ + " flooding.", banmask, msg.nick, channel) reason = floodType + " flood detected." if floodType == "Paste": reason += " Use a pastebin like pastebin.ubuntu.com or gist.github.com." if not dummy: irc.queueMsg(ircmsgs.kick(channel, msg.nick, reason)) self.log.warning("Kicked %s from %s for %s flooding.",\ msg.nick, channel, floodType) # Don't schedule the same nick twice if not (msg.host in self.offenses): schedule.addEvent(self.clearOffenses, time.time()+300, args=[msg.host]) self.offenses[msg.host] = 0 # Incremented below self.offenses[msg.host] += 1 self.immunities[msg.nick] = True schedule.addEvent(self.unImmunify, time.time()+3, args=[msg.nick])
def kickme(self, irc, msg, args, reason): """[<reason>] Kick yourself.""" if ircutils.isChannel(msg.args[0]): irc.queueMsg(ircmsgs.kick(msg.args[0], msg.nick, reason or '')) else: irc.error(_("This command must be run in a channel."))
def detonate(self, irc): self.active = False self.thrown = False if self.showCorrectWire: # self.irc.reply('Should\'ve gone for the %s wire!' % self.goodWire) s = "%s should've gone for the %s wire!" % (self.victim, self.goodWire) self.irc.queueMsg(ircmsgs.action(self.channel, s)) if self.showArt: self.irc.sendMsg( ircmsgs.privmsg(self.channel, "\x031,1.....\x0315,1_.\x0314,1-^^---....,\x0315,1,-_\x031,1.......") ) self.irc.sendMsg( ircmsgs.privmsg(self.channel, "\x031,1.\x0315,1_--\x0314,1,.';,`.,';,.;;`;,.\x0315,1--_\x031,1...") ) self.irc.sendMsg( ircmsgs.privmsg(self.channel, "\x0315,1<,.\x0314,1;'`\".,;`..,;`*.,';`.\x0315,1;'>)\x031,1.") ) self.irc.sendMsg( ircmsgs.privmsg(self.channel, "\x0315,1I.:;\x0314,1.,`;~,`.;'`,.;'`,..\x0315,1';`I\x031,1.") ) self.irc.sendMsg( ircmsgs.privmsg(self.channel, "\x031,1.\x0315,1\\_.\x0314,1`'`..`';.,`';,`';,\x0315,1_../\x031,1..") ) self.irc.sendMsg( ircmsgs.privmsg(self.channel, "\x031,1....\x0315,1```\x0314,1--. . , ; .--\x0315,1'''\x031,1.....") ) self.irc.sendMsg( ircmsgs.privmsg( self.channel, "\x031,1..........\x034,1I\x031,1.\x038,1I\x037,1I\x031,1.\x038,1I\x034,1I\x031,1...........", ) ) self.irc.sendMsg( ircmsgs.privmsg( self.channel, "\x031,1..........\x034,1I\x031,1.\x037,1I\x038,1I\x031,1.\x037,1I\x034,1I\x031,1...........", ) ) self.irc.sendMsg( ircmsgs.privmsg( self.channel, "\x031,1.......,\x034,1-=\x034,1II\x037,1..I\x034,1.I=-,\x031,1........" ) ) self.irc.sendMsg( ircmsgs.privmsg( self.channel, "\x031,1.......\x034,1`-=\x037,1#$\x038,1%&\x037,1%$#\x034,1=-'\x031,1........" ) ) else: self.irc.sendMsg(ircmsgs.privmsg(self.channel, "KABOOM!")) self.irc.queueMsg(ircmsgs.kick(self.channel, self.victim, "BOOM!")) def reinvite(): if not self.victim in irc.state.channels[self.channel].users: self.irc.queueMsg(ircmsgs.invite(self.victim, self.channel)) if not self.responded: schedule.addEvent(reinvite, time.time() + 5)
def testKick(self): # do it as the stock test user, because he has admin capability and can kick gpg = self.irc.getCallback('GPG') gpg.authed_users['[email protected]'] = {'nick':'test', 'keyid':'AAAAAAAAAAAAAAA4', 'fingerprint':'AAAAAAAAAAAAAAAAAAA1AAAAAAAAAAAAAAA4'} self.prefix = '[email protected]' self.assertRegexp('gpg ident', 'are identified') self.irc.feedMsg(msg=ircmsgs.kick("#test", 'test', prefix=self.prefix)) self.assertRegexp('gpg ident', 'not identified')
def doJoin(self, irc, msg): user = ircutils.userFromHostmask(msg.prefix) if user == 'root' or user == '~root': channel = msg.args[0] s = self.registryValue('warning', channel) if self.registryValue('warn', channel): irc.queueMsg(ircmsgs.notice(msg.nick, s)) if self.registryValue('kick', channel): irc.queueMsg(ircmsgs.kick(channel, msg.nick, s))
def saveLast(self, irc, msg, match): r""".+""" channel = msg.args[0] try: self.buffer[channel] except: self.buffer[channel] = [] # Stuff for multikick if channel in self.kickuser: for each in self.kickuser[channel]: if (each in msg.nick.lower() and not self.kickuser[channel][each]['num'] <= 0): irc.queueMsg(ircmsgs.ban(msg.args[0], msg.nick)) irc.queueMsg( ircmsgs.kick( msg.args[0], msg.nick, '{0}'.format( self.kickuser[channel][each]['msg'].replace( '#n', str(self.kickuser[channel][each] ['num']))))) self.kickuser[channel][each]['num'] -= 1 def un(): irc.queueMsg(ircmsgs.unban(msg.args[0], msg.nick)) schedule.addEvent(un, time.time() + random.randint(10, 60)) # 30,120 # END line = match.group(0).replace("\x01ACTION", "*").strip("\x01") if msg.nick.lower() in self.annoyUser: def fu(): self._notice( irc, msg.nick, "\x02\x03{0},{1}{2}".format(random.randint(0, 15), random.randint(0, 15), line)) schedule.addEvent(fu, time.time() + random.randint(2, 60)) if re.match(r"^u[/].*[/].*[/].*$", match.group(0)) \ or re.match(r"^s[/].*[/].*$", match.group(0)): return 1 self.buffer[channel].insert(0, [msg.nick, line]) if len(self.buffer[channel]) > self.buffsize: self.buffer[channel].pop(self.buffsize) return 1
def raptors(self, irc, msg, args): """takes no arguments""" channel = msg.args[0] if irc.nick in irc.state.channels[channel].ops: irc.queueMsg(ircmsgs.kick(channel, msg.nick, 'Raptor Attack!')) irc.reply( ("%(name)s just got attacked by several raptors. As they " + "pick the remaining meat from %(name)s's bones they look up " + "and see BamaWOLF...") % {'name': msg.nick}, prefixNick=False ) else: irc.reply("runs screaming", action=True)
def doBan(): if irc.state.channels[channel].isOp(bannedNick): irc.queueMsg(ircmsgs.deop(channel, bannedNick)) irc.queueMsg(ircmsgs.ban(channel, banmask)) irc.queueMsg(ircmsgs.kick(channel, bannedNick, reason)) def f(): if channel in irc.state.channels and \ banmask in irc.state.channels[channel].bans: irc.queueMsg(ircmsgs.unban(channel, banmask)) schedule.addEvent(f, 3600)
def doPrivmsg(self, irc, msg): currentChannel = msg.args[0] if irc.isChannel(msg.args[0]): if (msg.args[1] == '\_o< quack!'): message = msg.nick + ", don't pretend to be me!"; # If kickMode is enabled for this channel, and the bot have op capability, let's kick! if self.registryValue('kickMode', currentChannel) and irc.nick in irc.state.channels[currentChannel].ops: irc.queueMsg(ircmsgs.kick(currentChannel, msg.nick, message)) else: # Else, just say it irc.reply(message)
def awayMsgKicker(self, irc, msg, match): r"""(is now (set as )?away [-:(] Reason|is no longer away [:-] Gone for|is away:)""" if self.registryValue('enableAwayMsgKicker', msg.args[0]): self.log.info("KICKING {0} for away announce".format(msg.nick)) self._sendMsg( irc, ircmsgs.kick(msg.args[0], msg.nick, "Autokick: Spam (Away/Back Announce)")) else: return
def capsKick(self, irc, msg, match): r""".+""" data = match.group(0) data = data.strip("\x01ACTION").strip("\x01").strip("\x02").strip( "\x07").strip("\x0f") knownCapsNicks = ["UBERNESS", "ADL"] for each in knownCapsNicks: data = data.strip(each) data = list(data) # Simon: Increased from 5 to 15, was making quite a few people unhappy if len(data) < 15: return 0 length = 0 caps = 0 for each in data: if each in self.alpha: length += 1 if each in each.upper(): caps += 1 self.log.warning("{0} {1} {2}".format(length, caps, int(float(caps) / length * 100))) if int(float(caps) / length * 100) > 60: self.log.info("Kicking {0} from {1} for caps rage.".format( msg.nick, msg.args[0])) if self.consolechannel: irc.queueMsg( ircmsgs.privmsg( self.consolechannel, "KICK: {0} for excessive caps. (automatic)".format( msg.nick))) with open("KCOUNT", "r") as f: kd = json.load(f) with open("KCOUNT", "w") as f: try: kd[msg.nick.lower()] += 1 except: kd[msg.nick.lower()] = 1 f.write(json.dumps(kd, sort_keys=True, indent=4)) reason = "{0} - Kicked {1} time".format("Excessive Caps", kd[msg.nick.lower()]) if kd[msg.nick.lower()] > 1: reason = "{0}s".format(reason) del kd irc.queueMsg(ircmsgs.kick(msg.args[0], msg.nick, reason))
def doBan(): if irc.state.channels[channel].isOp(bannedNick): irc.queueMsg(ircmsgs.deop(channel, bannedNick)) irc.queueMsg(ircmsgs.ban(channel, banmask)) irc.queueMsg(ircmsgs.kick(channel, bannedNick, reason)) if expiry > 0: def f(): if channel in irc.state.channels and \ banmask in irc.state.channels[channel].bans: irc.queueMsg(ircmsgs.unban(channel, banmask)) schedule.addEvent(f, expiry)
def awayMsgKicker(self, irc, msg, match): r"(is now (set as)? away [-:(] Reason |is no longer away : Gone for|is away:)" self.log.info("KICKING %s for away announce" % msg.nick) if (self.consolechannel): irc.queueMsg( ircmsgs.privmsg( self.consolechannel, "KICK: %s for away announcement (automatic)" % msg.nick)) self._sendMsg( irc, ircmsgs.kick(msg.args[0], msg.nick, "Autokick: Spam (Away/Back Announce)"))
def _check_privileges(self, irc, msg, reply=False): channel = msg.args[0] if irc.nick not in irc.state.channels[channel].ops: if reply: irc.reply("%s braucht op ;_;" % irc.nick) return False if self._calculate_id(msg.nick, channel) in self.recently_joined: if reply: irc.queueMsg(ircmsgs.kick(channel, msg.nick, "Du warst noch nicht lange genug anwesend um abzustimmen!")) self._user_left(irc, msg.nick, channel) return False return True
def doPrivmsg(self, irc, msg): """This is called everytime an IRC message is recieved.""" (recipients, text) = msg.args for channel in recipients.split(','): if irc.isChannel(channel): enable = self.registryValue('enable', channel=channel) if not enable: return maxKick = self.registryValue('maxKick', channel=channel) self.queueKick.enqueue(msg) if self.queueKick.len(msg) > 4: #self.queueKick.reset(msg) self.queueBan.enqueue(msg) maxKickBeforeBan = self.registryValue('maxKickToBan', channel=channel) reason = self.registryValue('reasonKick', channel=channel) if self.queueBan.len(msg) > maxKickBeforeBan: #self.queueBan.reset(msg) self.queueLongBan.enqueue(msg) maxBanToLongBan = self.registryValue('maxBanToLongBan', channel=channel) duration = int(0) if self.queueLongBan.len(msg) > maxBanToLongBan: #self.queueLongBan.reset(msg) duration = int( self.registryValue('durationLongBan', channel=channel)) else: duration = int( self.registryValue('durationBan', channel=channel)) hostmask = irc.state.nickToHostmask(msg.nick) (nick, user, host) = ircutils.splitHostmask(hostmask) banmask = ircutils.joinHostmask('*', '*', host) irc.sendMsg(ircmsgs.ban(channel, banmask)) if duration > 0: def ub(): if channel in irc.state.channels and banmask in irc.state.channels[ channel].bans: irc.queueMsg( ircmsgs.unban(channel, banmask)) schedule.addEvent(ub, time.time() + duration) reason = self.registryValue('reasonBan', channel=channel) # reason = reason % utils.timeElapsed(duration) # irc.sendMsg(ircmsgs.IrcMsg('remove %s %s : %s' % (channel, msg.nick, reason))) irc.reply('remove %s %s : %s' % (channel, msg.nick, reason)) self.log.info('remove %s %s : %s' % (channel, msg.nick, reason)) irc.sendMsg(ircmsgs.kick(channel, msg.nick, reason))
def doJoin(self, irc, msg): channel = msg.args[0] if ircutils.strEqual(irc.nick, msg.nick): return if not self.registryValue('enable', channel): return fallthrough = self.registryValue('fallthrough', channel) def do(type): cap = ircdb.makeChannelCapability(channel, type) if ircdb.checkCapability(msg.prefix, cap, ignoreOwner=not self.registryValue('owner')): if self.registryValue(type, channel): self.log.info('Scheduling auto-%s of %s in %s.', type, msg.prefix, channel) msgmaker = getattr(ircmsgs, type) schedule_msg(msgmaker(channel, msg.nick)) raise Continue # Even if fallthrough, let's only do one. elif not fallthrough: self.log.debug('%s has %s, but supybot.plugins.AutoMode.%s' ' is not enabled in %s, refusing to fall ' 'through.', msg.prefix, cap, type, channel) raise Continue def schedule_msg(msg): def f(): irc.queueMsg(msg) delay = self.registryValue('delay', channel) if delay: schedule.addEvent(f, time.time() + delay) else: f() try: do('op') if 'h' in irc.state.supported['prefix']: do('halfop') do('voice') except Continue: return c = ircdb.channels.getChannel(channel) if c.checkBan(msg.prefix) and self.registryValue('ban', channel): period = self.registryValue('ban.period', channel) if period: def unban(): try: if msg.prefix in irc.state.channels[channel].bans: irc.queueMsg(ircmsgs.unban(channel, msg.prefix)) except KeyError: # We're not in the channel anymore. pass schedule.addEvent(unban, time.time()+period) banmask =conf.supybot.protocols.irc.banmask.makeBanmask(msg.prefix) irc.queueMsg(ircmsgs.ban(channel, banmask)) irc.queueMsg(ircmsgs.kick(channel, msg.nick))
def testKick(self): # do it as the stock test user, because he has admin capability and can kick gpg = self.irc.getCallback("GPG") gpg.authed_users["[email protected]"] = { "nick": "test", "keyid": "AAAAAAAAAAAAAAA4", "fingerprint": "AAAAAAAAAAAAAAAAAAA1AAAAAAAAAAAAAAA4", "bitcoinaddress": "1blabsanthoeu", } self.prefix = "[email protected]" self.assertRegexp("gpg ident", "are identified") self.irc.feedMsg(msg=ircmsgs.kick("#test", "test", prefix=self.prefix)) self.assertRegexp("gpg ident", "not identified")
def _remove_kebab(self, irc, channel, target): prefix = irc.state.nickToHostmask(target) host = ircutils.hostFromHostmask(prefix) hostmask = "*!*@%s" % host irc.queueMsg(ircmsgs.ban(channel, hostmask)) if target in irc.state.channels[channel].users: irc.queueMsg(ircmsgs.kick(channel, target, "Das Volk hat entschieden.")) def unban(): irc.queueMsg(ircmsgs.unban(channel, hostmask)) schedule.addEvent(unban, time.time() + int(self.registryValue("ban_duration")))
def capsKick(self, irc, msg, match): r".+" data = match.group(0) data = data.strip('\x01ACTION').strip('\x01').strip('\x02').strip( '\x07').strip('\x0f') knownCapsNicks = ['UBERNESS', 'ADL'] for each in knownCapsNicks: data = data.strip(each) data = list(data) if len(data) < 15: return 0 #Simon: Increased from 5 to 15, was making quite a few people unhappy length = 0 caps = 0 for each in data: if each in self.alpha: length += 1 if each in each.upper(): caps += 1 self.log.warning('{0} {1} {2}'.format( length, caps, int((float(caps) / length) * 100))) if int((float(caps) / length) * 100) > 60: self.log.info('Kicking {0} from {1} for caps rage.'.format( msg.nick, msg.args[0])) if (self.consolechannel): irc.queueMsg( ircmsgs.privmsg( self.consolechannel, "KICK: %s for excessive caps. (automatic)" % msg.nick)) with open('KCOUNT', 'r') as f: kd = json.load(f) with open('KCOUNT', 'w') as f: try: kd[msg.nick.lower()] += 1 except: kd[msg.nick.lower()] = 1 f.write(json.dumps(kd, sort_keys=True, indent=4)) reason = '{0} - Kicked {1} time'.format('Excessive Caps', kd[msg.nick.lower()]) if kd[msg.nick.lower()] > 1: reason = '{0}s'.format(reason) del kd irc.queueMsg(ircmsgs.kick(msg.args[0], msg.nick, reason))
def inFilter(self, irc, msg): self.filtering = True # We need to check for bad words here rather than in doPrivmsg because # messages don't get to doPrivmsg is the user is ignored. if msg.command == 'PRIVMSG': self.updateRegexp() s = ircutils.stripFormatting(msg.args[1]) channel = msg.args[0] if ircutils.isChannel(channel) and self.registryValue('kickban', channel): if self.regexp.search(s): if irc.nick in irc.state.channels[channel].ops: message = self.registryValue('kickban.message', channel) bannedHostmask = irc.state.nickToHostmask(msg.nick) banmaskstyle = conf.supybot.protocols.irc.banmask banmask = banmaskstyle.makeBanmask(bannedHostmask) irc.queueMsg(ircmsgs.ban(channel, banmask)) irc.queueMsg(ircmsgs.kick(channel, msg.nick, message)) expiry = self.registryValue('kickban.banexpire', channel) if expiry > 0: def f(): if channel in irc.state.channels and \ banmask in irc.state.channels[channel].bans: irc.queueMsg(ircmsgs.unban(channel, banmask)) schedule.addEvent(f,time.time()+expiry) else: self.log.warning('Should kickban %s from %s, but not opped.', msg.nick, channel) else: if ircutils.isChannel(channel) and self.registryValue('kick', channel): if self.regexp.search(s): if irc.nick in irc.state.channels[channel].ops: message = self.registryValue('kick.message', channel) irc.queueMsg(ircmsgs.kick(channel, msg.nick, message)) else: self.log.warning('Should kick %s from %s, but not opped.', msg.nick, channel) return msg
def detonate(self, irc): fairnessInvert = False if not self.responded: if self.sender in irc.state.channels[self.channel].ops and not self.victim in irc.state.channels[self.channel].ops: print(" Sender has ops and victim does not! Throwing for a fairness detonation inversion!" ) randNum = self.rng.randint(0,4) if randNum == 0 : irc.reply("The bomb goes klunk.") fairnessInvert = True self.irc.queueMsg(ircmsgs.op(self.channel, self.victim) ) else: print "Throw failed." self.active = False #if self.showCorrectWire: # self.irc.reply('Should\'ve gone for the %s wire!' % self.goodWire) if self.showArt: self.irc.sendMsg(ircmsgs.privmsg(self.channel, ' (} ,^. . .')) self.irc.sendMsg(ircmsgs.privmsg(self.channel, ' / \\\\/\. ` `._-\' \'`-~. .')) self.irc.sendMsg(ircmsgs.privmsg(self.channel, ' \, \` ) __ ( .')) self.irc.sendMsg(ircmsgs.privmsg(self.channel, ' . / . -< //\\\\ `_- .')) self.irc.sendMsg(ircmsgs.privmsg(self.channel, ' ` . ) // \\\\ ( \' P A N T S P L O D E')) detonateMsg = "BOOM!" if self.thrown: detonateMsg = "KA" + detonateMsg else: if self.showCorrectWire : detonateMsg += " (it was %s)" % self.goodWire self.active = False self.thrown = False if fairnessInvert: #self.irc.queueMsg(irc.reply("The bomb goes klunk.") ) print "Fairness invert activated!" newVictim = self.sender self.sender = self.victim self.victim = newVictim #irc.reply("The bomb goes beep!")) #time.sleep(10) else: self.irc.queueMsg(ircmsgs.kick(self.channel, self.victim, detonateMsg) ) def reinvite(): if not self.victim in irc.state.channels[self.channel].users: self.irc.queueMsg(ircmsgs.invite(self.victim, self.channel)) if not self.responded: schedule.addEvent(reinvite, time.time()+5)
def doPrivmsg(self,irc,msg): caller = msg.prefix.split('!')[0]#caller= ircdb.users.getUser(msg.prefix) text = msg.args[1].lower().split(' ') lentext = float(len(text)) regex = re.compile('r+o+a+r+', flags=re.I) roarcnt = 0.0 for x in text: if regex.match(x): roarcnt += 1.0 if roarcnt/lentext > .9: chance = random.random() if chance > .65: #irc.sendMsg(ircmsgs.privmsg(msg.args[0],"NO")) irc.queueMsg(ircmsgs.kick(msg.args[0], caller, "NO"))
def feedBan(self, hostmask, prefix='', channel=None, mode='b'): if not channel: channel = self.channel if not prefix: prefix = '[email protected]' if mode == 'b': ban = ircmsgs.ban(channel, hostmask, prefix=prefix) elif mode == 'q': ban = quiet(channel, hostmask, prefix=prefix) elif mode == 'k': ban = ircmsgs.kick(channel, hostmask, s='kthxbye!', prefix=prefix) elif mode == 'p': ban = ircmsgs.part(channel, prefix=hostmask, s='requested by %s (kthxbye!)' %prefix[:prefix.find('!')]) self.irc.feedMsg(ban) return ban
def inFilter(self, irc, msg): self.filtering = True # We need to check for bad words here rather than in doPrivmsg because # messages don't get to doPrivmsg is the user is ignored. if msg.command == 'PRIVMSG': self.updateRegexp() s = ircutils.stripFormatting(msg.args[1]) channel = msg.args[0] if ircutils.isChannel(channel) and self.registryValue('kick', channel): if self.regexp.search(s): if irc.nick in irc.state.channels[channel].ops: message = self.registryValue('kick.message', channel) irc.queueMsg(ircmsgs.kick(channel, msg.nick, message)) else: self.log.warning('Should kick %s from %s, but not opped.', msg.nick, channel) return msg
def doJoin(self, irc, msg): channel = msg.args[0] if ircutils.strEqual(irc.nick, msg.nick): return if not self.registryValue('enable', channel): return fallthrough = self.registryValue('fallthrough', channel) def do(type): if ircdb.checkCapability(msg.prefix, 'owner') and not \ self.registryValue('owner'): raise Continue cap = ircdb.makeChannelCapability(channel, type) if ircdb.checkCapability(msg.prefix, cap): if self.registryValue(type, channel): self.log.info('Sending auto-%s of %s in %s.', type, msg.prefix, channel) msgmaker = getattr(ircmsgs, type) irc.queueMsg(msgmaker(channel, msg.nick)) raise Continue # Even if fallthrough, let's only do one. elif not fallthrough: self.log.debug('%s has %s, but supybot.plugins.AutoMode.%s' ' is not enabled in %s, refusing to fall ' 'through.', msg.prefix, cap, type, channel) raise Continue try: do('op') if 'h' in irc.state.supported['prefix']: do('halfop') do('voice') except Continue: return c = ircdb.channels.getChannel(channel) if c.checkBan(msg.prefix) and self.registryValue('ban', channel): period = self.registryValue('ban.period', channel) if period: def unban(): try: if msg.prefix in irc.state.channels[channel].bans: irc.queueMsg(ircmsgs.unban(channel, msg.prefix)) except KeyError: # We're not in the channel anymore. pass schedule.addEvent(unban, time.time()+period) banmask =conf.supybot.protocols.irc.banmask.makeBanmask(msg.prefix) irc.queueMsg(ircmsgs.ban(channel, banmask)) irc.queueMsg(ircmsgs.kick(channel, msg.nick))
def doPrivmsg(self, irc, msg): currentChannel = msg.args[0] line = msg.args[1] if irc.isChannel(currentChannel): if(self.started.get(currentChannel) == True): if re.search(r'(.+)?\_o<(.+)?', msg.args[1], re.I): #or re.search(r'quack(.*)\!', msg.args[1], re.I) or re.search(r'!bang', msg.args[1], re.I): try: self.scores[currentChannel][msg.nick] -= 5 except: try: self.scores[currentChannel][msg.nick] = -5 except: self.scores[currentChannel] = {} self.scores[currentChannel][msg.nick] = -5 reason = " %i for being an asshat! >:| " % (self.scores[currentChannel][msg.nick]) msg = ircmsgs.kick(currentChannel, msg.nick, reason) irc.queueMsg(msg)
def doJoin(self, irc, msg): channel = msg.args[0] if not self.registryValue('enable', channel): return nick, ident, host = ircutils.splitHostmask(msg.prefix) fd = utils.web.getUrlFd('http://rbls.org/%s' % host) line = ' ' while line and not line.startswith('<title>'): line = fd.readline() if not line: return if 'is listed in' in line: irc.queueMsg(ircmsgs.ban(channel, '*!*@%s' % host)) irc.queueMsg(ircmsgs.kick(channel, nick)) else: assert 'is not listed' in line
def randroulette(self, irc, msg, args, channel): """takes no arguments Keeps firing the revolver at a random person in the channel until it fires. """ chamberSize = self._chamberSizeMax nicks = list(irc.state.channels[channel].users) if channel not in self._rouletteChamber: self._rouletteChamber[channel] = self.rng.randrange( self._chamberMin, self._chamberMax) self._rouletteBullet[channel] = self.rng.randrange( self._bulletMin, self._bulletMax) while True: nickCount = 0 nick = self.rng.choice(nicks) while nickCount < 99 and nick in self.registryValue( 'exclusions', channel): nick = self.rng.choice(nicks) nickCount += 1 if nickCount >= 96: nick = msg.nick if self._rouletteChamber[channel] == self._rouletteBullet[channel]: break else: irc.sendMsg(ircmsgs.privmsg(channel, '%s: *click*' % nick)) self._rouletteChamber[channel] += 1 self._rouletteChamber[channel] %= chamberSize self._rouletteChamber[channel] = self.rng.randrange( self._chamberMin, self._chamberMax) self._rouletteBullet[channel] = self.rng.randrange( self._bulletMin, self._bulletMax) if irc.nick in irc.state.channels[channel].ops: irc.sendMsg(ircmsgs.privmsg(channel, '%s: BANG!!' % nick)) irc.queueMsg(ircmsgs.kick(channel, nick, 'BANG!')) else: irc.reply('*BANG* Hey, who put a blank in here?!', prefixNick=False) irc.reply('reloads and spins the chambers.', action=True)
def doPrivmsg(self, irc, msg): channel = msg.args[0] text = msg.args[1] prefix = msg.prefix nick = prefix.split('!')[0] if callbacks.addressed(irc.nick, msg): #message is direct command return checker = SpellChecker(text, self.registryValue('level', channel)) errors = checker.getErrors() if len(errors) == 0: return elif len(errors) == 1: reason = 'Erreur : %s' % errors[0] else: reason = 'Erreurs : %s' % ' | '.join(errors) msg = ircmsgs.kick(channel, nick, reason) irc.queueMsg(msg)
def kick(self, irc, msg, args, channel, nick, reason): """[<channel>] <nick> [<reason>] Kicks <nick> from <channel> for <reason>. If <reason> isn't given, uses the nick of the person making the command as the reason. <channel> is only necessary if the message isn't sent in the channel itself. """ if ircutils.strEqual(nick, irc.nick): irc.error('I cowardly refuse to kick myself.', Raise=True) if not reason: reason = msg.nick kicklen = irc.state.supported.get('kicklen', sys.maxint) if len(reason) > kicklen: irc.error('The reason you gave is longer than the allowed ' 'length for a KICK reason on this server.', Raise=True) self._sendMsg(irc, ircmsgs.kick(channel, nick, reason))
def kick(self, irc, msg, args, channel, nicks, reason): """[<channel>] <nick>[, <nick>, ...] [<reason>] Kicks <nick>(s) from <channel> for <reason>. If <reason> isn't given, uses (kicked). <channel> is only necessary if the message isn't sent in the channel itself. """ if utils.iter.any(lambda n: ircutils.strEqual(n, irc.nick), nicks): irc.error('I cowardly refuse to kick myself.', Raise=True) if not reason: reason = 'kicked' kicklen = irc.state.supported.get('kicklen', sys.maxint) if len(reason) > kicklen: irc.error('The reason you gave is longer than the allowed ' 'length for a KICK reason on this server.', Raise=True) for nick in nicks: self._sendMsg(irc, ircmsgs.kick(channel, nick, reason))
def feedBan(self, hostmask, prefix='', channel=None, mode='b'): if not channel: channel = self.channel if not prefix: prefix = '[email protected]' if mode == 'b': ban = ircmsgs.ban(channel, hostmask, prefix=prefix) elif mode == 'q': ban = quiet(channel, hostmask, prefix=prefix) elif mode == 'k': ban = ircmsgs.kick(channel, hostmask, s='kthxbye!', prefix=prefix) elif mode == 'p': ban = ircmsgs.part(channel, prefix=hostmask, s='requested by %s (kthxbye!)' % prefix[:prefix.find('!')]) self.irc.feedMsg(ban) return ban
def saveLast(self, irc, msg, match): r".+" channel = msg.args[0] try: self.buffer[channel] except: self.buffer[channel] = [] # Stuff for multikick for each in self.kickuser: if each in msg.nick.lower( ) and not self.kickuser[each]['num'] <= 0: irc.queueMsg(ircmsgs.ban(msg.args[0], msg.nick)) irc.queueMsg( ircmsgs.kick( msg.args[0], msg.nick, "{}".format(self.kickuser[each]['msg'].replace( '#n', str(self.kickuser[each]['num']))))) self.kickuser[each]['num'] -= 1 def un(): irc.queueMsg(ircmsgs.unban(msg.args[0], msg.nick)) schedule.addEvent(un, time.time() + random.randint(30, 120)) # END line = match.group(0).replace('\x01ACTION', '*').strip('\x01') if msg.nick.lower() in self.annoyUser: def fu(): irc.queueMsg( ircmsgs.IrcMsg('NOTICE {} :\x02\x03{},{}{}'.format( msg.nick, random.randint(0, 15), random.randint(0, 15), line))) schedule.addEvent(fu, time.time() + random.randint(2, 60)) self.buffer[channel].insert(0, [msg.nick, line]) if len(self.buffer[channel]) > self.buffsize: self.buffer[channel].pop(self.buffsize) return 1
def rroulette(self, irc, msg, args, spin): """[spin] Fires the revolver. If the bullet was in the chamber, you're dead. Tell me to spin the chambers and I will. """ if spin: self._rouletteBullet = random.randrange(0, 6) irc.reply('*SPIN* Are you feeling lucky?', prefixNick=False) return channel = msg.args[0] if self._rouletteChamber == self._rouletteBullet: self._rouletteBullet = random.randrange(0, 6) self._rouletteChamber = random.randrange(0, 6) if irc.nick in irc.state.channels[channel].ops or irc.nick in irc.state.channels[channel].halfops: try: bannedHostmask = irc.state.nickToHostmask(msg.nick) except KeyError: irc.error(format('I haven\'t seen %s.', msg.nick), Raise=True) banmaskstyle = conf.supybot.protocols.irc.banmask banmask = banmaskstyle.makeBanmask(bannedHostmask, ["nick", "host"]) if ircutils.hostmaskPatternEqual(banmask, irc.prefix): if ircutils.hostmaskPatternEqual(bannedHostmask, irc.prefix): self.log.warning('%q played rroulette, but he\'s got the same hostmask as me, strangely enough.',msg.prefix) irc.error('I\'m not playing this game.') return else: self.log.warning('Using exact hostmask since banmask would ' 'ban myself.') banmask = bannedHostmask def f(): if channel in irc.state.channels and banmask in irc.state.channels[channel].bans: irc.queueMsg(ircmsgs.unban(channel, banmask)) schedule.addEvent(f, 60) irc.queueMsg(ircmsgs.ban(channel, banmask)) irc.queueMsg(ircmsgs.kick(channel, msg.nick, 'BANG!')) else: irc.reply('*BANG* Hey, who put a blank in here?!', prefixNick=False) irc.reply('reloads and spins the chambers.', action=True) else: irc.reply('*click*') self._rouletteChamber += 1 self._rouletteChamber %= 6
def doMode(self, irc, msg): channel = msg.args[0] mainchan = channel.replace('-unregged', '') if (channel.endswith('-unregged') and mainchan in self.registryValue('channels')) and channel in irc.state.channels: modes = ircutils.separateModes(msg.args[1:]) for (mode, value) in modes: if mode == '+i': kicks = [] for user in irc.state.channels[channel].users: if not (user in irc.state.channels[channel].ops or user in irc.state.channels[channel].voices): kicks.append(user) if 'r' in irc.state.channels[channel].modes: for user in kicks: irc.queueMsg(ircmsgs.IrcMsg('REMOVE %s %s :%s' % (channel, user, self.registryValue('kickMessage') % (mainchan, mainchan)))) irc.queueMsg(ircmsgs.mode(channel, '-ir')) else: for user in kicks: irc.queueMsg(ircmsgs.kick(channel, user, self.registryValue('kickMessage') % (mainchan, mainchan))) irc.queueMsg(ircmsgs.mode(channel, '-i'))
def kick(self, irc, msg, args, channel, nicks, reason): """[<channel>] <nick>[, <nick>, ...] [<reason>] Kicks <nick>(s) from <channel> for <reason>. If <reason> isn't given, uses (kicked). <channel> is only necessary if the message isn't sent in the channel itself. """ if utils.iter.any(lambda n: ircutils.strEqual(n, irc.nick), nicks): irc.error('I cowardly refuse to kick myself.', Raise=True) if not reason: reason = 'kicked' kicklen = irc.state.supported.get('kicklen', sys.maxint) if len(reason) > kicklen: irc.error( 'The reason you gave is longer than the allowed ' 'length for a KICK reason on this server.', Raise=True) for nick in nicks: self._sendMsg(irc, ircmsgs.kick(channel, nick, reason))
def _punishRelayers(self, msg): assert self._checkRelayMsg(msg), 'Punishing without checking.' who = msg.prefix channel = msg.args[0] def notPunishing(irc, s, *args): self.log.info('Not punishing %s in %s on %s: %s.', msg.prefix, channel, irc.network, s, *args) for irc in world.ircs: if channel in irc.state.channels: if irc.nick in irc.state.channels[channel].ops: if who in irc.state.channels[channel].bans: notPunishing(irc, 'already banned') else: self.log.info('Punishing %s in %s on %s for relaying.', who, channel, irc.network) irc.sendMsg(ircmsgs.ban(channel, who)) kmsg = _('You seem to be relaying, punk.') irc.sendMsg(ircmsgs.kick(channel, msg.nick, kmsg)) else: notPunishing(irc, 'not opped')
def _ban(self, irc, nick, channel): try: hostmask = irc.state.nickToHostmask(nick) except KeyError: return (nick, user, host) = ircutils.splitHostmask(hostmask) user = self._fnUser.sub('*', user) banmask = ircutils.joinHostmask('*', user, host) if ircutils.hostmaskPatternEqual(banmask, irc.prefix): return irc.queueMsg(ircmsgs.ban(channel, banmask)) irc.queueMsg(ircmsgs.kick(channel, nick)) expiry = self.registryValue('autokban.timeout', channel) if expiry > 0: expiry += time.time() def f(): if channel in irc.state.channels and \ banmask in irc.state.channels[channel].bans: irc.queueMsg(ircmsgs.unban(channel, banmask)) schedule.addEvent(f, expiry)