def unescape(msg, extra_format_dict={}):
new_msg = '<STR_LIT>'<EOL>extra_format_dict.update(format_dict)<EOL>while len(msg):<EOL><INDENT>char = msg[<NUM_LIT:0>]<EOL>msg = msg[<NUM_LIT:1>:]<EOL>if char == escape_character:<EOL><INDENT>escape_key = msg[<NUM_LIT:0>]<EOL>msg = msg[<NUM_LIT:1>:]<EOL>if escape_key == escape_character:<EOL><INDENT>new_msg += escape_character<EOL><DEDENT>elif escape_key == '<STR_LIT:{>':<EOL><INDENT>buf = '<STR_LIT>'<EOL>new_char = '<STR_LIT>'<EOL>while True:<EOL><INDENT>new_char = msg[<NUM_LIT:0>]<EOL>msg = msg[<NUM_LIT:1>:]<EOL>if new_char == '<STR_LIT:}>':<EOL><INDENT>break<EOL><DEDENT>else:<EOL><INDENT>buf += new_char<EOL><DEDENT><DEDENT>new_msg += _get_from_format_dict(extra_format_dict, buf)<EOL><DEDENT>else:<EOL><INDENT>new_msg += _get_from_format_dict(extra_format_dict, escape_key)<EOL><DEDENT>if escape_key == '<STR_LIT:c>':<EOL><INDENT>fill_last = len(msg) and msg[<NUM_LIT:0>] in digits<EOL>colours, msg = extract_girc_colours(msg, fill_last)<EOL>new_msg += colours<EOL><DEDENT><DEDENT>else:<EOL><INDENT>new_msg += char<EOL><DEDENT><DEDENT>return new_msg<EOL>
Takes a girc-escaped message and returns a raw IRC message