# Buggy code
async def connect(self):
    """Connect to the chat service."""
    _LOGGER.info("Connecting to Slack")

    try:
        connection = await self.slacker.rtm.start()
        self.websocket = await websockets.connect(connection.body["url"])

        _LOGGER.debug("Connected as %s", self.bot_name)
        _LOGGER.debug("Using icon %s", self.icon_emoji)
        _LOGGER.debug("Default room is %s", self.default_room)
        _LOGGER.info("Connected successfully")

        if self.keepalive is None or self.keepalive.done():
            self.keepalive = self.opsdroid.eventloop.create_task(
                self.keepalive_websocket()
            )
    except aiohttp.ClientOSError as error:
        _LOGGER.error(error)
        _LOGGER.error("Failed to connect to Slack, retrying in 10")
        await self.reconnect(10)
    except Exception:
        await self.disconnect()
        raise


# Traceback (slacker.Error)
Traceback (most recent call last):
File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/Users/fabiorosado/Documents/GitHub/opsdroid/opsdroid/__main__.py", line 206, in <module>
init()
File "/Users/fabiorosado/Documents/GitHub/opsdroid/opsdroid/__main__.py", line 203, in init
main()
File "/Users/fabiorosado/.local/share/virtualenvs/opsdroid-13bLHlYD/lib/python3.6/site-packages/click/core.py", line 764, in __call__
return self.main(*args, **kwargs)
File "/Users/fabiorosado/.local/share/virtualenvs/opsdroid-13bLHlYD/lib/python3.6/site-packages/click/core.py", line 717, in main
rv = self.invoke(ctx)
File "/Users/fabiorosado/.local/share/virtualenvs/opsdroid-13bLHlYD/lib/python3.6/site-packages/click/core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/fabiorosado/.local/share/virtualenvs/opsdroid-13bLHlYD/lib/python3.6/site-packages/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
File "/Users/fabiorosado/Documents/GitHub/opsdroid/opsdroid/__main__.py", line 196, in main
opsdroid.load()
File "/Users/fabiorosado/Documents/GitHub/opsdroid/opsdroid/core.py", line 153, in load
self.start_connectors(self.modules["connectors"])
File "/Users/fabiorosado/Documents/GitHub/opsdroid/opsdroid/core.py", line 248, in start_connectors
self.eventloop.run_until_complete(connector.connect(self))
File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/base_events.py", line 466, in run_until_complete
return future.result()
File "/Users/fabiorosado/Documents/GitHub/opsdroid/opsdroid/connector/slack/__init__.py", line 50, in connect
connection = await self.slacker.rtm.start()
File "/Users/fabiorosado/.local/share/virtualenvs/opsdroid-13bLHlYD/lib/python3.6/site-packages/aioslacker/__init__.py", line 97, in __request
raise Error(response.error)
slacker.Error: invalid_auth
Exception ignored in: <bound method BaseEventLoop.__del__ of <_UnixSelectorEventLoop running=False closed=True debug=False>>
Traceback (most recent call last):
File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/base_events.py", line 511, in __del__
File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/unix_events.py", line 65, in close
File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/unix_events.py", line 146, in remove_signal_handler
File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/signal.py", line 47, in signal
TypeError: signal handler must be signal.SIG_IGN, signal.SIG_DFL, or a callable object

# Fixed code
async def connect(self):
    """Connect to the chat service."""
    _LOGGER.info("Connecting to Slack")

    try:
        connection = await self.slacker.rtm.start()
        self.websocket = await websockets.connect(connection.body["url"])

        _LOGGER.debug("Connected as %s", self.bot_name)
        _LOGGER.debug("Using icon %s", self.icon_emoji)
        _LOGGER.debug("Default room is %s", self.default_room)
        _LOGGER.info("Connected successfully")

        if self.keepalive is None or self.keepalive.done():
            self.keepalive = self.opsdroid.eventloop.create_task(
                self.keepalive_websocket()
            )
    except aiohttp.ClientOSError as error:
        _LOGGER.error(error)
        _LOGGER.error("Failed to connect to Slack, retrying in 10")
        await self.reconnect(10)
    except slacker.Error as error:
        _LOGGER.error(
            "Unable to connect to Slack due to %s - "
            "The Slack Connector will not be available.",
            error,
        )
    except Exception:
        await self.disconnect()
        raise