'Tries to match the message to the list of patterns. Supports multiline messages.
:param patterns: list of (regex, variable)-pairs
:param msg: The parsed IRC message
:param multiline: True if msg is multiline
:return: A dict of the variables and their extracted values'

def match_message_patterns(self, patterns, msg):

    result = {}
    for (rx, vals, _) in patterns:
        log.debug(u'Using    pattern    %s    to    parse    message    vars', rx.pattern)
        match = rx.search(msg)
        if match:
            val_names = [irc_prefix(val.lower()) for val in vals]
            val_values = [(strip_whitespace(x) or u'') for x in match.groups()]
            result.update(dict(zip(val_names, val_values)))
            log.debug(u'Found:    %s', dict(zip(val_names, val_values)))
            break
        else:
            log.debug(u'No    matches    found    for    %s    in    %s', rx.pattern, msg)
    return result
