Added command to turn colorization off.

This commit is contained in:
Jeremy Fincher 2003-08-21 11:19:32 +00:00
parent 28a8071635
commit 89e4a3ea59

View File

@ -92,6 +92,7 @@ def configure(onStart, afterConnect, advanced):
class Relay(callbacks.Privmsg): class Relay(callbacks.Privmsg):
def __init__(self): def __init__(self):
callbacks.Privmsg.__init__(self) callbacks.Privmsg.__init__(self)
self.color = 0
self.ircs = {} self.ircs = {}
self.whois = {} self.whois = {}
self.started = False self.started = False
@ -255,6 +256,22 @@ class Relay(callbacks.Privmsg):
otherIrc.queueMsg(ircmsgs.whois(nick)) otherIrc.queueMsg(ircmsgs.whois(nick))
self.whois[(otherIrc, nick)] = (irc, msg, {}) self.whois[(otherIrc, nick)] = (irc, msg, {})
def relaycolor(self, irc, msg, args):
"""<0,1,2>
0 turns coloring of nicks/angle brackets off entirely. 1 colors the
nicks, but not the angle brackets. 2 colors both.
"""
try:
self.color = int(privmsgs.getArgs(args))
if color != 0 and color != 1 and color != 2:
raise callbacks.ArgumentError
except ValueError:
raise callbacks.ArgumentError
irc.reply(msg, conf.replySuccess)
relaycolor = privmsgs.checkCapability(relaycolor, 'admin')
def do311(self, irc, msg): def do311(self, irc, msg):
if not isinstance(irc, irclib.Irc): if not isinstance(irc, irclib.Irc):
irc = irc.getRealIrc() irc = irc.getRealIrc()
@ -292,14 +309,23 @@ class Relay(callbacks.Privmsg):
def _formatPrivmsg(self, nick, network, msg): def _formatPrivmsg(self, nick, network, msg):
# colorize nicks # colorize nicks
if self.color >= 1:
nick = ircutils.mircColor(nick, *ircutils.canonicalColor(nick)) nick = ircutils.mircColor(nick, *ircutils.canonicalColor(nick))
if self.color >= 2:
colors = ircutils.canonicalColor(nick, shift=4) colors = ircutils.canonicalColor(nick, shift=4)
if ircmsgs.isAction(msg): if ircmsgs.isAction(msg):
if self.color >= 2:
t = ircutils.mircColor('*', *colors) t = ircutils.mircColor('*', *colors)
else:
t = '*'
s = '%s %s@%s %s' % (t, nick, network, ircmsgs.unAction(msg)) s = '%s %s@%s %s' % (t, nick, network, ircmsgs.unAction(msg))
else: else:
if self.color >= 2:
lt = ircutils.mircColor('<', *colors) lt = ircutils.mircColor('<', *colors)
gt = ircutils.mircColor('>', *colors) gt = ircutils.mircColor('>', *colors)
else:
lt = '<'
gt = '>'
s = '%s%s@%s%s %s' % (lt, nick, network, gt, msg.args[1]) s = '%s%s@%s%s %s' % (lt, nick, network, gt, msg.args[1])
return s return s