def extract_irc_colours(msg):
    """Extract the IRC colours from the start of the string.

    Extracts the colours from the start, and returns the colour code in our
    format, and then the rest of the message.
    """
    # first colour
    fore, msg = _extract_irc_colour_code(msg)

    if not fore:
        return '[]', msg
    if not len(msg) or msg[0] != ',':
        return '[{}]'.format(_ctos(fore)), msg

    msg = msg[1:]  # strip comma

    # second colour
    back, msg = _extract_irc_colour_code(msg)

    if back:
        return '[{},{}]'.format(_ctos(fore), _ctos(back)), msg
    else:
        return '[{}]'.format(_ctos(fore)), ',' + msg
Extract the IRC colours from the start of the string.

    Extracts the colours from the start, and returns the colour code in our
    format, and then the rest of the message.