add some colors in the notification message.

This commit is contained in:
Elián Hanisch 2012-07-05 20:40:57 -03:00
parent c90821186e
commit bf93f42503
2 changed files with 14 additions and 8 deletions

View File

@ -833,13 +833,13 @@ class Bantracker(callbacks.Plugin):
if not self.registryValue('autoremove', channel):
continue
if type == 'quiet':
mask = mask[1:]
self.log.info("%s [%s] %s in %s expired", type,
ban.ban.id,
mask,
channel)
# send unban msg
if type == 'quiet':
mask = mask[1:]
unban = ircmsgs.mode(channel, (modedict[type], mask))
irc.queueMsg(unban)
@ -853,12 +853,17 @@ class Bantracker(callbacks.Plugin):
or not self.registryValue('autoremove.notify', channel):
continue
type, mask = ban.ban.type, ban.ban.mask
if type == 'quiet':
mask = mask[1:]
for c in self.registryValue('autoremove.notify.channels', channel):
notice = ircmsgs.notice(c, "%s [%s] %s in %s will expire in a few minutes." \
% (ban.ban.type,
ban.ban.id,
ban.ban.mask,
channel))
notice = ircmsgs.notice(c, "%s %s%s%s %s in %s will expire in a few minutes." \
% (type,
ircutils.mircColor('[', 'light green'),
ircutils.bold(ban.ban.id),
ircutils.mircColor(']', 'light green'),
ircutils.mircColor(mask, 'teal'),
ircutils.mircColor(channel, 'teal')))
irc.queueMsg(notice)
ban.notified = True

View File

@ -416,7 +416,8 @@ class BantrackerTestCase(ChannelPluginTestCase):
cb.autoRemoveBans(self.irc)
msg = self.irc.takeMsg()
self.assertEqual(str(msg).strip(),
"NOTICE #test :ban [1] asd!*@* in #test will expire in a few minutes.")
"NOTICE #test :ban \x0309[\x03\x021\x02\x0309]\x03 \x0310asd!*@*\x03"\
" in \x0310#test\x03 will expire in a few minutes.")
# don't send the notice again.
cb.autoRemoveBans(self.irc)
self.assertFalse(self.irc.takeMsg())