def extract_girc_colours(msg, fill_last):
if not len(msg):<EOL><INDENT>return '<STR_LIT>', '<STR_LIT>'<EOL><DEDENT>if '<STR_LIT:]>' not in msg or not msg.startswith('<STR_LIT:[>'):<EOL><INDENT>return '<STR_LIT>', msg<EOL><DEDENT>original_msg = msg<EOL>colours, msg = msg.split('<STR_LIT:]>', <NUM_LIT:1>)<EOL>colours = colours.lstrip('<STR_LIT:[>')<EOL>if '<STR_LIT:U+002C>' in colours:<EOL><INDENT>fore, back = colours.split('<STR_LIT:U+002C>')<EOL>if fore not in colour_name_to_code or back not in colour_name_to_code:<EOL><INDENT>return '<STR_LIT>', original_msg<EOL><DEDENT>fore = colour_name_to_code[fore]<EOL>back = colour_name_to_code[back]<EOL>return '<STR_LIT>'.format(fore, back.zfill(<NUM_LIT:2>) if fill_last else back), msg<EOL><DEDENT>else:<EOL><INDENT>if colours not in colour_name_to_code:<EOL><INDENT>return '<STR_LIT>', original_msg<EOL><DEDENT>fore = colour_name_to_code[colours]<EOL>return '<STR_LIT:{}>'.format(fore.zfill(<NUM_LIT:2>) if fill_last else fore), msg<EOL><DEDENT>
Extract the girc-formatted colours from the start of the string.

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

    If `fill_last`, last number must be zero-padded.