def METHOD_NAME(self, msg):
    kwargs = msg.get("kwargs", {})
    if 'list_files' == msg['func'] and 'filter' in kwargs:
        def filter_by_name(keyword):
            return lambda x: re.search(keyword, x['name'], re.IGNORECASE)
        # filter is a lambda function in octoprint api
        kwargs['filter'] = filter_by_name(kwargs['filter'])
    return kwargs