'Handle the background color state.
Background colors can consist of up to two digits and must occur after
a foreground color and must be preceded by a I{,}. Any non-digit
character is treated as invalid input and results in the state being
set to "text".
@param ch: The character being processed.'

def state_COLOR_BACKGROUND(self, ch):

    if (ch.isdigit() and (len(self._buffer) < 2)):
        self._buffer += ch
    else:
        if self._buffer:
            col = (int(self._buffer) % len(_IRC_COLORS))
            self.background = getattr(attributes.bg, _IRC_COLOR_NAMES[col])
            self._buffer = ''
        self.emit()
        self.state = 'TEXT'
        self.process(ch)
