예제 #1
0
 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
예제 #2
0
파일: plugin.py 프로젝트: rostob/Limnoria
    def unban(self, irc, msg, args, channel, hostmask):
        """[<channel>] [<hostmask|--all>]

        Unbans <hostmask> on <channel>.  If <hostmask> is not given, unbans
        any hostmask currently banned on <channel> that matches your current
        hostmask.  Especially useful for unbanning yourself when you get
        unexpectedly (or accidentally) banned from the channel.  <channel> is
        only necessary if the message isn't sent in the channel itself.
        """
        if hostmask == '--all':
            bans = irc.state.channels[channel].bans
            self._sendMsg(irc, ircmsgs.unbans(channel, bans))
        elif hostmask:
            self._sendMsg(irc, ircmsgs.unban(channel, hostmask))
        else:
            bans = []
            for banmask in irc.state.channels[channel].bans:
                if ircutils.hostmaskPatternEqual(banmask, msg.prefix):
                    bans.append(banmask)
            if bans:
                irc.queueMsg(ircmsgs.unbans(channel, bans))
                irc.replySuccess(format(_('All bans on %s matching %s '
                                        'have been removed.'),
                                        channel, msg.prefix))
            else:
                irc.error(_('No bans matching %s were found on %s.') %
                          (msg.prefix, channel))
예제 #3
0
파일: plugin.py 프로젝트: Ban3/Limnoria
    def unban(self, irc, msg, args, channel, hostmask):
        """[<channel>] [<hostmask|--all>]

        Unbans <hostmask> on <channel>.  If <hostmask> is not given, unbans
        any hostmask currently banned on <channel> that matches your current
        hostmask.  Especially useful for unbanning yourself when you get
        unexpectedly (or accidentally) banned from the channel.  <channel> is
        only necessary if the message isn't sent in the channel itself.
        """
        if hostmask == '--all':
            bans = irc.state.channels[channel].bans
            self._sendMsg(irc, ircmsgs.unbans(channel, bans))
        elif hostmask:
            self._sendMsg(irc, ircmsgs.unban(channel, hostmask))
        else:
            bans = []
            for banmask in irc.state.channels[channel].bans:
                if ircutils.hostmaskPatternEqual(banmask, msg.prefix):
                    bans.append(banmask)
            if bans:
                irc.queueMsg(ircmsgs.unbans(channel, bans))
                irc.replySuccess(format(_('All bans on %s matching %s '
                                        'have been removed.'),
                                        channel, msg.prefix))
            else:
                irc.error(_('No bans matching %s were found on %s.') %
                          (msg.prefix, channel))
예제 #4
0
파일: plugin.py 프로젝트: tpapaioa/Limnoria
 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
예제 #5
0
파일: test.py 프로젝트: bnrubin/Bantracker
 def testBaninfo(self):
     cb = self.getCallback()
     self.feedBan('asd!*@*')
     self.assertResponse('duration 1', 
             "[1] ban - asd!*@* - #test - never expires")
     self.assertNotError('duration 1 10')
     self.assertResponse('duration 1', 
             "[1] ban - asd!*@* - #test - expires soon")
     self.assertNotError('duration 1 34502')
     self.assertResponse('duration 1', 
             "[1] ban - asd!*@* - #test - expires in 9 hours and 35 minutes")
     self.irc.feedMsg(ircmsgs.unban(self.channel, 'asd!*@*', 
                                    '[email protected]'))
     self.assertResponse('duration 1', 
             "[1] ban - asd!*@* - #test - not active")
예제 #6
0
 def f():
     if channel in irc.state.channels and \
        banmask in irc.state.channels[channel].bans:
         irc.queueMsg(ircmsgs.unban(channel, banmask))
예제 #7
0
					def un():
						irc.queueMsg(ircmsgs.unban(msg.args[0],msg.nick))
예제 #8
0
파일: plugin.py 프로젝트: rostob/Limnoria
 def f():
     if channel in irc.state.channels and \
        banmask in irc.state.channels[channel].bans:
         irc.queueMsg(ircmsgs.unban(channel, banmask))
예제 #9
0
 def testUnban(self):
     channel = '#supybot'
     ban = 'foo!bar@baz'
     self.assertEqual(str(ircmsgs.unban(channel, ban)),
                      'MODE %s -b :%s\r\n' % (channel, ban))
예제 #10
0
파일: test.py 프로젝트: bnrubin/Bantracker
 def testDurationInactiveBan(self):
     self.feedBan('asd!*@*')
     self.irc.feedMsg(ircmsgs.unban(self.channel, 'asd!*@*', 
                                    '[email protected]'))
     self.assertResponse('duration 1 1', 
             "Failed to set duration time on 1 (ban was removed)")
예제 #11
0
 def unBan():
     if channel in irc.state.channels and \
        banmask in irc.state.channels[channel].bans:
         irc.queueMsg(unban(channel, banmask))
예제 #12
0
 def un():
     irc.queueMsg(ircmsgs.unban(msg.args[0], msg.nick))
예제 #13
0
    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 = self.registryValue('%s.kickmessage' % kind, channel)
        if not reason:
            reason = self.registryValue('kickmessage').replace('$kind', 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.startswith('ban'):
            msg = ircmsgs.ban(channel, banmask)
            irc.queueMsg(msg)

            if punishment.startswith('ban+'):
                delay = int(punishment[4:])
                unban = functools.partial(irc.queueMsg,
                        ircmsgs.unban(channel, banmask))
                schedule.addEvent(unban, delay + time.time())

        elif punishment.startswith('kban'):
            msg = ircmsgs.ban(channel, banmask)
            irc.queueMsg(msg)
            msg = ircmsgs.kick(channel, nick, reason)
            irc.queueMsg(msg)

            if punishment.startswith('kban+'):
                delay = int(punishment[5:])
                unban = functools.partial(irc.queueMsg,
                        ircmsgs.unban(channel, banmask))
                schedule.addEvent(unban, delay + time.time())

        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'):], msg.nick))
            irc.queueMsg(msg)
        elif punishment.startswith('mmode'):
            msg = ircmsgs.mode(channel, (punishment[len('mmode'):], banmask))
            irc.queueMsg(msg)
        elif punishment.startswith('command '):
            tokens = callbacks.tokenize(punishment[len('command '):])
            self.Proxy(irc, msg, tokens)
예제 #14
0
 def testUnban(self):
     channel = '#supybot'
     ban = 'foo!bar@baz'
     self.assertEqual(str(ircmsgs.unban(channel, ban)),
                      'MODE %s -b :%s\r\n' % (channel, ban))
예제 #15
0
    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 = self.registryValue('%s.kickmessage' % kind, channel)
        if not reason:
            reason = self.registryValue('kickmessage').replace('$kind', 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.startswith('ban'):
            msg = ircmsgs.ban(channel, banmask)
            irc.queueMsg(msg)

            if punishment.startswith('ban+'):
                delay = int(punishment[4:])
                unban = functools.partial(irc.queueMsg,
                        ircmsgs.unban(channel, banmask))
                schedule.addEvent(unban, delay + time.time())

        elif punishment.startswith('kban'):
            msg = ircmsgs.ban(channel, banmask)
            irc.queueMsg(msg)
            msg = ircmsgs.kick(channel, nick, reason)
            irc.queueMsg(msg)

            if punishment.startswith('kban+'):
                delay = int(punishment[5:])
                unban = functools.partial(irc.queueMsg,
                        ircmsgs.unban(channel, banmask))
                schedule.addEvent(unban, delay + time.time())

        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'):], msg.nick))
            irc.queueMsg(msg)
        elif punishment.startswith('mmode'):
            msg = ircmsgs.mode(channel, (punishment[len('mmode'):], banmask))
            irc.queueMsg(msg)
        elif punishment.startswith('command '):
            tokens = callbacks.tokenize(punishment[len('command '):])
            self.Proxy(irc, msg, tokens)
예제 #16
0
 def unban():
     irc.queueMsg(ircmsgs.unban(channel, hostmask))