def parse_modes(params, mode_types=None, prefixes='<STR_LIT>'):
<EOL>params = list(params)<EOL>if params[<NUM_LIT:0>][<NUM_LIT:0>] not in '<STR_LIT>':<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>if mode_types is None:<EOL><INDENT>mode_types = ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>']<EOL><DEDENT>mode_string = params.pop(<NUM_LIT:0>)<EOL>args = params<EOL>assembled_modes = []<EOL>direction = mode_string[<NUM_LIT:0>]<EOL>for char in mode_string:<EOL><INDENT>if char in '<STR_LIT>':<EOL><INDENT>direction = char<EOL>continue<EOL><DEDENT>if (char in mode_types[<NUM_LIT:0>] or char in mode_types[<NUM_LIT:1>] or char in prefixes or<EOL>(char in mode_types[<NUM_LIT:2>] and direction == '<STR_LIT:+>') and len(args)):<EOL><INDENT>value = args.pop(<NUM_LIT:0>)<EOL><DEDENT>else:<EOL><INDENT>value = None<EOL><DEDENT>assembled_modes.append([direction, char, value])<EOL><DEDENT>return assembled_modes<EOL>
Return a modelist.

    Args:
        params (list of str): Parameters from MODE event.
        mode_types (list): CHANMODES-like mode types.
        prefixes (str): PREFIX-like mode types.