Bantracker: strip '%' from quiets in the string that's send to channels/nicks.

This commit is contained in:
Elián Hanisch 2011-05-31 01:45:05 -03:00
parent 223c3f9229
commit 638ccf7b47
2 changed files with 12 additions and 6 deletions

View File

@ -495,10 +495,13 @@ class Bantracker(callbacks.Plugin):
continue
if not ban.id:
ban.id = self.get_banId(ban.mask, channel)
mask = ban.mask
if type == 'quiet':
mask = mask[1:]
if nickMatch(nick, self.registryValue('review.forward', channel)):
s = "Hi, please somebody review the %s '%s' set by %s on %s in"\
" %s, link: %s/bans.cgi?log=%s" % (type,
ban.mask,
mask,
nick,
ban.ascwhen,
channel,
@ -508,7 +511,7 @@ class Bantracker(callbacks.Plugin):
else:
s = "Hi, please review the %s '%s' that you set on %s in %s, link:"\
" %s/bans.cgi?log=%s" % (type,
ban.mask,
mask,
ban.ascwhen,
channel,
self.registryValue('bansite'),

View File

@ -211,7 +211,7 @@ class BantrackerTestCase(ChannelPluginTestCase):
# test again with two ops
self.feedBan('asd2!*@*')
self.irc.takeMsg()
self.feedBan('qwe!*@*', prefix='otherop!user@home.net')
self.feedBan('qwe!*@*', prefix='otherop!user@home.net', mode='q')
self.irc.takeMsg()
time.sleep(2)
cb.reviewBans()
@ -223,7 +223,7 @@ class BantrackerTestCase(ChannelPluginTestCase):
self.feedMsg('Hi!', frm='mynickissocreative!user@home.net')
msg = self.irc.takeMsg()
self.assertEqual(str(msg).strip(),
"PRIVMSG mynickissocreative :Hi, please review the ban 'qwe!*@*' that you set on %s in #test, link: "\
"PRIVMSG mynickissocreative :Hi, please review the quiet 'qwe!*@*' that you set on %s in #test, link: "\
"%s/bans.cgi?log=3" %(cb.bans['#test'][2].ascwhen, pluginConf.bansite()))
self.feedMsg('ping', to='test', frm='op!user@host.net') # in a query
self.irc.takeMsg() # drop pong reply
@ -238,6 +238,7 @@ class BantrackerTestCase(ChannelPluginTestCase):
pluginConf.review.forward.channels.set('#channel')
cb = self.getCallback()
self.feedBan('asd!*@*', prefix='bot!user@host.net')
self.feedBan('asd!*@*', prefix='bot!user@host.net', mode='q')
cb.reviewBans(self.irc)
self.assertFalse(cb.pendingReviews)
print 'waiting 2 secs..'
@ -245,10 +246,12 @@ class BantrackerTestCase(ChannelPluginTestCase):
cb.reviewBans(self.irc)
# since it's a forward, it was sent already
self.assertFalse(cb.pendingReviews)
msg = self.irc.takeMsg()
self.assertEqual(str(msg).strip(),
self.assertEqual(str(self.irc.takeMsg()).strip(),
"NOTICE #channel :Hi, please somebody review the ban 'asd!*@*' set by bot on %s in #test, link: "\
"%s/bans.cgi?log=1" %(cb.bans['#test'][0].ascwhen, pluginConf.bansite()))
self.assertEqual(str(self.irc.takeMsg()).strip(),
"NOTICE #channel :Hi, please somebody review the quiet 'asd!*@*' set by bot on %s in #test, link: "\
"%s/bans.cgi?log=2" %(cb.bans['#test'][0].ascwhen, pluginConf.bansite()))
def testReviewIgnore(self):
pluginConf.review.setValue(True)