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,7 +197,8 @@ def bold(s):
"""Returns the string s, bolded."""
return "\x02%s\x02" % s
mircColors = {None: '',
mircColors = {
None: '',
'white': '0',
'black': '1',
'blue': '2',
@ -213,17 +214,21 @@ mircColors = {None: '',
'dark blue': '12',
'pink': '13',
'dark grey': '14',
'light grey': '15'}
'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):
"""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:
return s
elif bg is None:
return '\x03%s%s\x03' % (mircColors[fg], s)
else:
if bg is None:
return "\x03%s%s\x03" % (mircColors[fg], s)
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):