Tweaked mircColor (yeah, I'm anal beyond all reason)

This commit is contained in:
Jeremy Fincher 2003-07-23 15:13:30 +00:00
parent d346d877c9
commit 2a52871fcc

View File

@ -197,33 +197,38 @@ def bold(s):
"""Returns the string s, bolded.""" """Returns the string s, bolded."""
return "\x02%s\x02" % s return "\x02%s\x02" % s
mircColors = {None: '', mircColors = {
'white': '0', None: '',
'black': '1', 'white': '0',
'blue': '2', 'black': '1',
'green': '3', 'blue': '2',
'red': '4', 'green': '3',
'brown': '5', 'red': '4',
'purple': '6', 'brown': '5',
'orange': '7', 'purple': '6',
'yellow': '8', 'orange': '7',
'light green': '9', 'yellow': '8',
'teal': '10', 'light green': '9',
'light blue': '11', 'teal': '10',
'dark blue': '12', 'light blue': '11',
'pink': '13', 'dark blue': '12',
'dark grey': '14', 'pink': '13',
'light grey': '15'} 'dark grey': '14',
'light grey': '15',
}
# Now add the reverse to the dictionary.
for (k, v) in mircColors.items():
mircColors[int(v)] = k
def mircColor(s, fg=None, bg=None): def mircColor(s, fg=None, bg=None):
"""Returns the string s, with the appropriate mIRC color codes applied.""" """Returns s, with the appropriate mIRC color codes applied."""
if fg is None and bg is None: if fg is None and bg is None:
return s return s
else: elif bg is None:
if bg is None: return '\x03%s%s\x03' % (mircColors[fg], s)
return "\x03%s%s\x03" % (mircColors[fg], s) else:
else: return '\x03%s,%s%s\x03' % (mircColors[fg], mircColors[bg], s)
return "\x03%s,%s%s\x03" % (mircColors[fg], mircColors[bg], s)
def isValidArgument(s): def isValidArgument(s):