From c39ad2f379944e52373beae045871924ccdae70a Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Sat, 16 Jun 2012 11:27:31 +0000 Subject: [PATCH] Fix KeyError when using colors in a message containing numbers. --- src/ircutils.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ircutils.py b/src/ircutils.py index e2eb137eb..b252e1275 100644 --- a/src/ircutils.py +++ b/src/ircutils.py @@ -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)]