src/ircutils.py: A nasty hack around mIRC's broken color code rules. Must specify a foreground color if a background color is being specified, so we'll default it to white.

This commit is contained in:
James Vega 2006-05-25 19:52:16 +00:00
parent 4de0a49489
commit 07be8cd2c0

View File

@ -108,7 +108,7 @@ def toLower(s, casemapping=None):
def strEqual(nick1, nick2): def strEqual(nick1, nick2):
"""s1, s2 => bool """s1, s2 => bool
Returns True if nick1 == nick2 according to IRC case rules.""" Returns True if nick1 == nick2 according to IRC case rules."""
assert isinstance(nick1, basestring) assert isinstance(nick1, basestring)
assert isinstance(nick2, basestring) assert isinstance(nick2, basestring)
return toLower(nick1) == toLower(nick2) return toLower(nick1) == toLower(nick2)
@ -287,7 +287,10 @@ def mircColor(s, fg=None, bg=None):
return '\x03%s%s\x03' % (fg.zfill(2), s) return '\x03%s%s\x03' % (fg.zfill(2), s)
elif fg is None: elif fg is None:
bg = mircColors[str(bg)] bg = mircColors[str(bg)]
return '\x03,%s%s\x03' % (bg.zfill(2), s) # According to the mirc color doc, a fg color MUST be specified if a
# background color is specified. So, we'll specify 00 (white) if the
# user doesn't specify one.
return '\x0300,%s%s\x03' % (bg.zfill(2), s)
else: else:
fg = mircColors[str(fg)] fg = mircColors[str(fg)]
bg = mircColors[str(bg)] bg = mircColors[str(bg)]