# Buggy code
async def process_message(self, **payload):
    """Process a raw message and pass it to the parser."""
    message = payload["data"]

    # Ignore own messages
    if (
        "subtype" in message
        and message["subtype"] == "bot_message"
        and message["bot_id"] == self.bot_id
    ):
        return

    # Lookup username
    _LOGGER.debug(_("Looking up sender username"))
    try:
        user_info = await self.lookup_username(message["user"])
    except ValueError:
        return

    # Replace usernames in the message
    _LOGGER.debug(_("Replacing userids in message with usernames"))
    message["text"] = await self.replace_usernames(message["text"])

    await self.opsdroid.parse(
        Message(
            message["text"],
            user_info["name"],
            message["channel"],
            self,
            raw_event=message,
        )
    )


# Traceback (KeyError)
ERROR slack.rtm.client: When calling '#process_message()' in the 'opsdroid.connector.slack' module the following error was raised: 'user'
Traceback (most recent call last):
File "C:\Users\koe4945\desktop\git\personal\ops\venv\Scripts\opsdroid-script.py", line 11, in <module>
load_entry_point('opsdroid', 'console_scripts', 'opsdroid')()
File "c:\users\koe4945\desktop\git\personal\ops\venv\lib\site-packages\click\core.py", line 764, in __call__
return self.main(*args, **kwargs)
File "c:\users\koe4945\desktop\git\personal\ops\venv\lib\site-packages\click\core.py", line 717, in main
rv = self.invoke(ctx)
File "c:\users\koe4945\desktop\git\personal\ops\venv\lib\site-packages\click\core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "c:\users\koe4945\desktop\git\personal\ops\venv\lib\site-packages\click\core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "c:\users\koe4945\desktop\git\personal\ops\venv\lib\site-packages\click\core.py", line 555, in invoke
return callback(*args, **kwargs)
File "c:\users\koe4945\desktop\git\personal\ops\opsdroid\opsdroid\cli\start.py", line 31, in start
opsdroid.run()
File "c:\users\koe4945\desktop\git\personal\ops\opsdroid\opsdroid\core.py", line 161, in run
self.eventloop.run_until_complete(asyncio.gather(*pending))
File "C:\Users\koe4945\AppData\Local\Programs\Python\Python37\lib\asyncio\base_events.py", line 584, in run_until_complete
return future.result()
File "c:\users\koe4945\desktop\git\personal\ops\python-slackclient\slack\rtm\client.py", line 339, in _connect_and_read
await self._read_messages()
File "c:\users\koe4945\desktop\git\personal\ops\python-slackclient\slack\rtm\client.py", line 390, in _read_messages
await self._dispatch_event(event, data=payload)
File "c:\users\koe4945\desktop\git\personal\ops\python-slackclient\slack\rtm\client.py", line 437, in _dispatch_event
rtm_client=self, web_client=self._web_client, data=data
File "c:\users\koe4945\desktop\git\personal\ops\opsdroid\opsdroid\connector\slack\__init__.py", line 104, in process_message
user_info = await self.lookup_username(message["user"])
KeyError: 'user'
ERROR: Unhandled exception in opsdroid, exiting...

# Fixed code
async def process_message(self, **payload):
    """Process a raw message and pass it to the parser."""
    message = payload["data"]

    # Ignore message edits
    if "subtype" in message and message["subtype"] == "message_changed":
        return

    # Ignore own messages
    if (
        "subtype" in message
        and message["subtype"] == "bot_message"
        and message["bot_id"] == self.bot_id
    ):
        return

    # Lookup username
    _LOGGER.debug(_("Looking up sender username"))
    try:
        user_info = await self.lookup_username(message["user"])
    except ValueError:
        return

    # Replace usernames in the message
    _LOGGER.debug(_("Replacing userids in message with usernames"))
    message["text"] = await self.replace_usernames(message["text"])

    await self.opsdroid.parse(
        Message(
            message["text"],
            user_info["name"],
            message["channel"],
            self,
            raw_event=message,
        )
    )