diff --git a/plugins/Channel/plugin.py b/plugins/Channel/plugin.py index aa1084eb0..746a4aa47 100644 --- a/plugins/Channel/plugin.py +++ b/plugins/Channel/plugin.py @@ -575,8 +575,8 @@ class Channel(callbacks.Plugin): hostmask = wrap(hostmask, ['op', ('haveHalfop+', _('ban someone')), 'text']) @internationalizeDocstring - def add(self, irc, msg, args, channel, banmask, expires, description): - """[] [] [] + def add(self, irc, msg, args, channel, banmask, expires): + """[] [] If you have the #channel,op capability, this will effect a persistent ban from interacting with the bot on the given @@ -589,11 +589,10 @@ class Channel(callbacks.Plugin): channel itself. """ c = ircdb.channels.getChannel(channel) - c.addBan(banmask, expires or 0, description) + c.addBan(banmask, expires) ircdb.channels.setChannel(channel, c) irc.replySuccess() - add = wrap(add, ['op', first('hostmask', 'banmask'), - optional('expiry'), optional('text')]) + add = wrap(add, ['op', first('hostmask', 'banmask'), additional('expiry', 0)]) @internationalizeDocstring def remove(self, irc, msg, args, channel, banmask): @@ -631,16 +630,12 @@ class Channel(callbacks.Plugin): if filtered_bans: bans = [] for ban in filtered_bans: - (expiration, description) = all_bans[ban] - if expiration: - bans.append(format(_('%q (%s, expires %t)'), - ban, - description or _('no description'), - expiration)) + if all_bans[ban]: + bans.append(format(_('%q (expires %t)'), + ban, all_bans[ban])) else: - bans.append(format(_('%q (%s, never expires)'), - ban, - description or _('no description'))) + bans.append(format(_('%q (never expires)'), + ban, all_bans[ban])) irc.reply(format('%L', bans)) else: irc.reply(format(_('There are no persistent bans on %s.'), diff --git a/plugins/Channel/test.py b/plugins/Channel/test.py index 4ff4d1d94..5addfd925 100644 --- a/plugins/Channel/test.py +++ b/plugins/Channel/test.py @@ -234,15 +234,7 @@ class ChannelTestCase(ChannelPluginTestCase): self.assertRegexp('ban list foobar!*@baz', r'.*foobar!\*@baz.*') self.assertRegexp('ban list foobar!*@baz', r'.*foobar!qux@baz.*') self.assertResponse('ban list foobar!\*@baz', - '"foobar!*@baz" (no description, never expires)') - - self.assertNotError('ban add foobarbaz!qux@baz foo') - self.assertResponse('ban list foobarbaz!*@baz', - '"foobarbaz!qux@baz" (foo, never expires)') - - self.assertNotError('ban add foobarbazqux!qux@baz 5 bar') - self.assertRegexp('ban list foobarbazqux!*@baz', - r'"foobarbazqux!qux@baz" \(bar, expires [^ ]+\)') + '"foobar!*@baz" (never expires)') def testIgnore(self): orig = conf.supybot.protocols.irc.banmask() diff --git a/src/ircdb.py b/src/ircdb.py index 5363d8375..ba8ae9075 100644 --- a/src/ircdb.py +++ b/src/ircdb.py @@ -389,11 +389,11 @@ class IrcChannel(object): self.capabilities, self.lobotomized, self.defaultAllow, self.silences, self.exceptions) - def addBan(self, hostmask, expiration=0, description=None): + def addBan(self, hostmask, expiration=0): """Adds a ban to the channel banlist.""" assert not conf.supybot.protocols.irc.strictRfc() or \ ircutils.isUserHostmask(hostmask), 'got %s' % hostmask - self.bans[hostmask] = (int(expiration), description) + self.bans[hostmask] = int(expiration) def removeBan(self, hostmask): """Removes a ban from the channel banlist.""" @@ -405,7 +405,7 @@ class IrcChannel(object): """Checks whether a given hostmask is banned by the channel banlist.""" assert ircutils.isUserHostmask(hostmask), 'got %s' % hostmask now = time.time() - for (pattern, (expiration, description)) in self.bans.items(): + for (pattern, expiration) in self.bans.items(): if now < expiration or not expiration: if ircutils.hostmaskPatternEqual(pattern, hostmask): return True @@ -478,11 +478,9 @@ class IrcChannel(object): for capability in self.capabilities: write('capability ' + capability) bans = self.bans.items() - bans = [(x, (y, None) if isinstance(y, int) else y) - for (x, y) in bans] - utils.sortBy(lambda x:x[1][0], bans) - for (ban, (expiration, description)) in bans: - write('ban %s %d %s' % (ban, expiration, description)) + utils.sortBy(operator.itemgetter(1), bans) + for (ban, expiration) in bans: + write('ban %s %d' % (ban, expiration)) ignores = self.ignores.items() utils.sortBy(operator.itemgetter(1), ignores) for (ignore, expiration) in ignores: @@ -592,11 +590,7 @@ class IrcChannelCreator(Creator): def ban(self, rest, lineno): self._checkId() - parts = rest.split(None, 2) - if len(parts) == 2: # Old format - (pattern, expiration) = parts - else: - (pattern, expiration, description) = parts + (pattern, expiration) = rest.split() self.c.bans[pattern] = int(float(expiration)) def ignore(self, rest, lineno):