# Buggy code
async def match_event(event, event_opts):
    """Filter and matches the event."""
    event_type = event_opts.get("type", None)

    if event_type:
        # The event type can be specified with a string
        if isinstance(event_type, str):
            # pylint: disable=invalid-name
            et = Event.event_registry.get(event_type, None)
            if et is None:
                raise ValueError(
                    "{event_type} is not a valid opsdroid event representation.".format(
                        event_type=event_type
                    )
                )
            event_type = et

        # TODO: Add option to match all subclasses as well
        # if isinstance(event, event_type):
        # pylint: disable=unidiomatic-typecheck
        if type(event) is event_type:
            for key in event_opts:
                if key != "type":
                    event_value = event_opts.get(key, None)
                    entity_value = event.entities.get(key, {}).get("value", None)

                    if event_value != entity_value:
                        return False

            return True

    return False


# Traceback (KeyError)
ERROR aiohttp.server: Error handling request
Traceback (most recent call last):
File "/path/to/venv/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 418, in start
resp = await task
File "/path/to/venv/lib/python3.7/site-packages/aiohttp/web_app.py", line 458, in _handle
resp = await handler(request)
File "/path/to/venv/lib/python3.7/site-packages/opsdroid/connector/slack/__init__.py", line 268, in slack_interactions_handler
await block_action.update_entity("value", action["value"])
KeyError: 'value'
INFO aiohttp.access: 127.0.0.1 [14/Dec/2019:15:01:36 +0000] "POST /connector/slack/interactions HTTP/1.1" 500 244 "-" "Slackbot 1.0 (+https://api.slack.com/robots)"

# Fixed code
async def match_event(event, event_opts):
    """Filter and matches the event."""
    event_type = event_opts.get("type", None)

    if event_type:
        # The event type can be specified with a string
        if isinstance(event_type, str):
            # pylint: disable=invalid-name
            et = Event.event_registry.get(event_type, None)
            if et is None:
                raise ValueError(
                    "{event_type} is not a valid opsdroid event representation.".format(
                        event_type=event_type
                    )
                )
            event_type = et

        # TODO: Add option to match all subclasses as well
        # if isinstance(event, event_type):
        # pylint: disable=unidiomatic-typecheck
        if type(event) is event_type:
            for key in event_opts:
                if key != "type":
                    event_value = event_opts.get(key, None)
                    entity_value = event.entities.get(key, {}).get("value", None)

                    if (
                        isinstance(event_value, list)
                        and isinstance(entity_value, list)
                        and sorted(event_value) != sorted(entity_value)
                    ):
                        return False

                    if event_value != entity_value:
                        return False

            return True

    return False