Fix KeyError when using colors in a message containing numbers.

This commit is contained in:
Valentin Lorentz 2012-06-16 11:27:31 +00:00
parent ceee427e1f
commit c39ad2f379

View File

@ -280,7 +280,13 @@ def mircColor(s, fg=None, bg=None):
if fg is None and bg is None:
return s
elif bg is None:
fg = mircColors[str(fg)]
if str(fg) in mircColors:
fg = mircColors[str(fg)]
elif len(str(fg)) > 1:
fg = mircColors[str(fg)[:-1]]
else:
# Should not happen
pass
return '\x03%s%s\x03' % (fg.zfill(2), s)
elif fg is None:
bg = mircColors[str(bg)]