# Buggy code
def serve_once(self):
    log.info("Verifying authentication token")
    self.auth = self.api_call("auth.test", raise_errors=False)
    if not self.auth["ok"]:
        log.error(
            "Couldn't authenticate with Slack. Server said: %s" % self.auth["error"]
        )
    log.debug("Token accepted")
    self.jid = SlackIdentifier(
        node=self.auth["user_id"],
        domain=self.sc.server.domain,
        resource=self.auth["user_id"],
    )

    log.info("Connecting to Slack real-time-messaging API")
    if self.sc.rtm_connect():
        log.info("Connected")
        self.reset_reconnection_count()
        try:
            while True:
                for message in self.sc.rtm_read():
                    if "type" not in message:
                        log.debug("Ignoring non-event message: %s" % message)
                        continue

                    event_type = message["type"]
                    event_handler = getattr(
                        self, "_%s_event_handler" % event_type, None
                    )
                    if event_handler is None:
                        log.debug(
                            "No event handler available for %s, ignoring this event"
                            % event_type
                        )
                        continue
                    try:
                        log.debug("Processing slack event: %s" % message)
                        event_handler(message)
                    except Exception:
                        log.exception(
                            "%s event handler raised an exception" % event_type
                        )
                time.sleep(1)
        except KeyboardInterrupt:
            log.info("Interrupt received, shutting down..")
            return True
        except:
            log.exception("Error reading from RTM stream:")
        finally:
            log.debug("Triggering disconnect callback")
            self.disconnect_callback()
    else:
        raise Exception("Connection failed, invalid token ?")


# Traceback (ConnectionResetError)
(err)whiskeyriver@whiskeyriver-VirtualBox:~/Code/err$ err.py -S
15:30:01 INFO     __main__                  Config check passed...
15:30:02 INFO     __main__                  Checking for '/home/whiskeyriver/Code/err/data'...
15:30:02 DEBUG    errbot.errBot             ErrBot init.
15:30:02 INFO     errbot.storage            Opened shelf of SlackBackend at /home/whiskeyriver/Code/err/data/core.db
15:30:02 DEBUG    errbot.backends.base      created the thread pool<errbot.bundled.threadpool.ThreadPool object at 0x7f453284e8d0>
15:30:02 DEBUG    errbot.plugin_manager     check dependencies of /home/whiskeyriver/Code/err/errbot/core_plugins
15:30:02 DEBUG    errbot.plugin_manager     /home/whiskeyriver/Code/err/errbot/core_plugins has no requirements.txt file
15:30:02 DEBUG    errbot.plugin_manager     plugin __init__(args=['self', 'bot'], argslist=None, kwargs=None)
15:30:02 INFO     errbot.storage            Init shelf of ChatRoom
15:30:02 DEBUG    errbot.plugin_manager     plugin __init__(args=['self', 'bot'], argslist=None, kwargs=None)
15:30:02 INFO     errbot.storage            Init shelf of Backup
15:30:02 DEBUG    errbot.plugin_manager     plugin __init__(args=['self', 'bot'], argslist=None, kwargs=None)
15:30:02 INFO     errbot.storage            Init shelf of VersionChecker
15:30:02 INFO     errbot.decorators         webhooks:  Flag to bind /echo/ to echo
15:30:02 DEBUG    errbot.plugin_manager     plugin __init__(args=['self', 'bot'], argslist=None, kwargs=None)
15:30:02 INFO     errbot.storage            Init shelf of Webserver
15:30:02 DEBUG    errbot.main               serve from <errbot.backends.slack.SlackBackend object at 0x7f453284e710>
15:30:02 INFO     errbot.backends.slack     Verifying authentication token
15:30:03 DEBUG    errbot.backends.slack     Token accepted
15:30:03 INFO     errbot.backends.slack     Connecting to Slack real-time-messaging API
15:30:04 INFO     errbot.backends.slack     Connected
15:30:05 DEBUG    errbot.backends.slack     Processing slack event: {'type': 'hello'}
15:30:05 INFO     errbot.errBot             Activate internal commands
15:30:05 INFO     errbot.errBot             Activating all the plugins...
15:30:05 INFO     errbot.errBot             Activate plugin: Webserver
15:30:05 INFO     errbot.plugin_manager     Activating Webserver with min_err_version = 2.2.1 and max_version = 2.2.1
15:30:05 DEBUG    errbot.templating         Templates directory found for this plugin [/home/whiskeyriver/Code/err/errbot/core_plugins/templates]
15:30:05 INFO     yapsy_loaded_plugin_Webse Webserver is not configured. Forbid activation
15:30:05 INFO     errbot.core_plugins.wsvie Checking Webserver for webhooks
15:30:05 INFO     errbot.core_plugins.wsvie ... Routing echo
15:30:05 INFO     errbot.errBot             Activate plugin: Backup
15:30:05 INFO     errbot.plugin_manager     Activating Backup with min_err_version = None and max_version = None
15:30:05 DEBUG    errbot.templating         Templates directory found for this plugin [/home/whiskeyriver/Code/err/errbot/core_plugins/templates]
15:30:05 DEBUG    errbot.botplugin          Init storage for Backup
15:30:05 DEBUG    errbot.botplugin          Loading /home/whiskeyriver/Code/err/data/plugins/Backup.db
15:30:05 INFO     errbot.storage            Opened shelf of Backup at /home/whiskeyriver/Code/err/data/plugins/Backup.db
15:30:05 DEBUG    errbot.backends.base      Adding command : backup -> backup
15:30:05 INFO     errbot.core_plugins.wsvie Checking Backup for webhooks
15:30:05 INFO     errbot.errBot             Activate plugin: ChatRoom
15:30:05 INFO     errbot.plugin_manager     Activating ChatRoom with min_err_version = 2.2.1 and max_version = 2.2.1
15:30:05 DEBUG    errbot.templating         Templates directory found for this plugin [/home/whiskeyriver/Code/err/errbot/core_plugins/templates]
15:30:05 DEBUG    errbot.botplugin          Init storage for ChatRoom
15:30:05 DEBUG    errbot.botplugin          Loading /home/whiskeyriver/Code/err/data/plugins/ChatRoom.db
15:30:05 INFO     errbot.storage            Opened shelf of ChatRoom at /home/whiskeyriver/Code/err/data/plugins/ChatRoom.db
15:30:05 DEBUG    errbot.backends.base      Adding command : gtalk_room_create -> gtalk_room_create
15:30:05 DEBUG    errbot.backends.base      Adding command : room_create -> room_create
15:30:05 DEBUG    errbot.backends.base      Adding command : room_destroy -> room_destroy
15:30:05 DEBUG    errbot.backends.base      Adding command : room_invite -> room_invite
15:30:05 DEBUG    errbot.backends.base      Adding command : room_join -> room_join
15:30:05 DEBUG    errbot.backends.base      Adding command : room_leave -> room_leave
15:30:05 DEBUG    errbot.backends.base      Adding command : room_list -> room_list
15:30:05 DEBUG    errbot.backends.base      Adding command : room_occupants -> room_occupants
15:30:05 DEBUG    errbot.backends.base      Adding command : room_topic -> room_topic
15:30:05 INFO     errbot.core_plugins.wsvie Checking ChatRoom for webhooks
15:30:05 INFO     errbot.errBot             Activate plugin: VersionChecker
15:30:05 INFO     errbot.plugin_manager     Activating VersionChecker with min_err_version = 2.2.1 and max_version = 2.2.1
15:30:05 DEBUG    errbot.templating         Templates directory found for this plugin [/home/whiskeyriver/Code/err/errbot/core_plugins/templates]
15:30:05 DEBUG    yapsy_loaded_plugin_Versi Checking version
15:30:06 DEBUG    errbot.botplugin          Programming the polling of version_check every 86400 seconds with args [] and kwargs {}
15:30:06 DEBUG    errbot.botplugin          Init storage for VersionChecker
15:30:06 DEBUG    errbot.botplugin          Loading /home/whiskeyriver/Code/err/data/plugins/VersionChecker.db
15:30:06 INFO     errbot.storage            Opened shelf of VersionChecker at /home/whiskeyriver/Code/err/data/plugins/VersionChecker.db
15:30:06 INFO     errbot.core_plugins.wsvie Checking VersionChecker for webhooks
15:30:06 INFO     errbot.errBot
15:30:06 INFO     errbot.errBot             Notifying connection to all the plugins...
15:30:06 DEBUG    errbot.errBot             Trigger callback_connect on Backup
15:30:06 DEBUG    errbot.errBot             Trigger callback_connect on ChatRoom
15:30:06 INFO     yapsy_loaded_plugin_ChatR Callback_connect
15:30:06 DEBUG    errbot.errBot             Trigger callback_connect on VersionChecker
15:30:06 INFO     errbot.errBot             Plugin activation done.
15:30:06 DEBUG    errbot.backends.base      Adding command : about -> about
15:30:06 DEBUG    errbot.backends.base      Adding command : apropos -> apropos
15:30:06 DEBUG    errbot.backends.base      Adding command : blacklist -> blacklist
15:30:06 DEBUG    errbot.backends.base      Adding command : config -> config
15:30:06 DEBUG    errbot.backends.base      Adding command : echo -> echo
15:30:06 DEBUG    errbot.backends.base      Adding command : help -> help
15:30:06 DEBUG    errbot.backends.base      Adding command : history -> history
15:30:06 DEBUG    errbot.backends.base      Adding command : load -> load
15:30:06 DEBUG    errbot.backends.base      Adding command : log_tail -> log_tail
15:30:06 DEBUG    errbot.backends.base      Adding command : reload -> reload
15:30:06 DEBUG    errbot.backends.base      Adding command : repos -> repos
15:30:06 DEBUG    errbot.backends.base      Adding command : repos_install -> repos_install
15:30:06 DEBUG    errbot.backends.base      Adding command : repos_uninstall -> repos_uninstall
15:30:06 DEBUG    errbot.backends.base      Adding command : repos_update -> repos_update
15:30:06 DEBUG    errbot.backends.base      Adding command : restart -> restart
15:30:06 DEBUG    errbot.backends.base      Adding command : status -> status
15:30:06 DEBUG    errbot.backends.base      Adding command : status_gc -> status_gc
15:30:06 DEBUG    errbot.backends.base      Adding command : status_load -> status_load
15:30:06 DEBUG    errbot.backends.base      Adding command : status_plugins -> status_plugins
15:30:06 DEBUG    errbot.backends.base      Adding command : unblacklist -> unblacklist
15:30:06 DEBUG    errbot.backends.base      Adding command : unload -> unload
15:30:06 DEBUG    errbot.backends.base      Adding command : uptime -> uptime
15:30:06 DEBUG    errbot.errBot             Triggering callback_presence on Backup
15:30:06 DEBUG    errbot.errBot             Triggering callback_presence on ChatRoom
15:30:06 DEBUG    errbot.errBot             Triggering callback_presence on VersionChecker
15:30:07 DEBUG    errbot.backends.slack     Processing slack event: {'user': 'U00ERRBOT', 'text': 'Command "needs" / "needs some" not found.', 'reply_to': None, 'channel': 'C00000001', 'ts': '1433881703.000186', 'type': 'message'}
15:30:07 DEBUG    errbot.backends.slack     Handling message from a public channel
15:30:07 DEBUG    errbot.backends.base      *** jid = deployment@shinyservers/deploybot
15:30:07 DEBUG    errbot.backends.base      *** username = deploybot
15:30:07 DEBUG    errbot.backends.base      *** type = groupchat
15:30:07 DEBUG    errbot.backends.base      *** text = Command "needs" / "needs some" not found.
15:30:07 DEBUG    errbot.errBot             Trigger callback_message on Backup
15:30:07 DEBUG    errbot.errBot             Trigger callback_message on ChatRoom
15:30:07 DEBUG    errbot.errBot             Trigger callback_message on VersionChecker
15:30:10 DEBUG    errbot.backends.slack     No event handler available for user_typing, ignoring this event
15:30:12 DEBUG    errbot.backends.slack     Processing slack event: {'user': 'UWHSKYRVR', 'text': '!status', 'team': 'TSHNYSRVR', 'channel': 'G00000002', 'ts': '1433881812.000007', 'type': 'message'}
15:30:12 DEBUG    errbot.backends.slack     Handling message from a private group
15:30:12 DEBUG    errbot.backends.base      *** jid = test_deploy_bot@shinyservers/whiskeyriver
15:30:12 DEBUG    errbot.backends.base      *** username = whiskeyriver
15:30:12 DEBUG    errbot.backends.base      *** type = groupchat
15:30:12 DEBUG    errbot.backends.base      *** text = !status
15:30:12 INFO     errbot.backends.base      Processing command 'status' with parameters '' from test_deploy_bot@shinyservers/whiskeyriver/whiskeyriver
15:30:12 DEBUG    errbot.errBot             Trigger callback_message on Backup
15:30:12 DEBUG    errbot.errBot             Trigger callback_message on ChatRoom
15:30:12 DEBUG    errbot.errBot             Trigger callback_message on VersionChecker
15:30:12 DEBUG    errbot.backends.slack     Sending groupchat message to test_deploy_bot (G00000002)
15:30:13 DEBUG    errbot.backends.slack     Ignoring non-event message: {'ts': '1433881813.000008', 'ok': True, 'text': 'Yes I am alive...        \n            \n        With these plugins (L=Loaded, U=Unloaded, B=Blacklisted, C=Needs to be configured):\n                    [L] Backup\n                    [L] ChatRoom\n                    [L] VersionChecker\n                    [C] Webserver\n        \n        Load 0.07, 0.04, 0.05\n        GC 0-&amp;gt;66 1-&amp;gt;4 2-&amp;gt;6', 'reply_to': None}
15:30:43 ERROR    errbot.backends.slack     Error reading from RTM stream:
Traceback (most recent call last):
File "/home/whiskeyriver/Code/err/errbot/backends/slack.py", line 142, in serve_once
for message in self.sc.rtm_read():
File "/home/whiskeyriver/Code/virtualenv/err/lib/python3.4/site-packages/slackclient/_client.py", line 27, in rtm_read
json_data = self.server.websocket_safe_read()
File "/home/whiskeyriver/Code/virtualenv/err/lib/python3.4/site-packages/slackclient/_server.py", line 109, in websocket_safe_read
data += "{}\n".format(self.websocket.recv())
File "/home/whiskeyriver/Code/virtualenv/err/lib/python3.4/site-packages/websocket/_core.py", line 348, in recv
opcode, data = self.recv_data()
File "/home/whiskeyriver/Code/virtualenv/err/lib/python3.4/site-packages/websocket/_core.py", line 365, in recv_data
opcode, frame = self.recv_data_frame(control_frame)
File "/home/whiskeyriver/Code/virtualenv/err/lib/python3.4/site-packages/websocket/_core.py", line 378, in recv_data_frame
frame = self.recv_frame()
File "/home/whiskeyriver/Code/virtualenv/err/lib/python3.4/site-packages/websocket/_core.py", line 410, in recv_frame
return self.frame_buffer.recv_frame()
File "/home/whiskeyriver/Code/virtualenv/err/lib/python3.4/site-packages/websocket/_abnf.py", line 300, in recv_frame
self.recv_header()
File "/home/whiskeyriver/Code/virtualenv/err/lib/python3.4/site-packages/websocket/_abnf.py", line 249, in recv_header
header = self.recv_strict(2)
File "/home/whiskeyriver/Code/virtualenv/err/lib/python3.4/site-packages/websocket/_abnf.py", line 334, in recv_strict
bytes = self.recv(min(16384, shortage))
File "/home/whiskeyriver/Code/virtualenv/err/lib/python3.4/site-packages/websocket/_core.py", line 476, in _recv
return recv(self.sock, bufsize)
File "/home/whiskeyriver/Code/virtualenv/err/lib/python3.4/site-packages/websocket/_socket.py", line 77, in recv
bytes = sock.recv(bufsize)
File "/usr/lib/python3.4/ssl.py", line 731, in recv
return self.read(buflen)
File "/usr/lib/python3.4/ssl.py", line 620, in read
v = self._sslobj.read(len or 1024)
ConnectionResetError: [Errno 104] Connection reset by peer
15:30:43 DEBUG    errbot.backends.slack     Triggering disconnect callback
15:30:43 INFO     errbot.errBot             Disconnect callback, deactivating all the plugins.
15:30:43 DEBUG    errbot.storage            Closed shelf of Backup
15:30:43 DEBUG    errbot.storage            Closed shelf of ChatRoom
15:30:43 DEBUG    errbot.botplugin          You still have active pollers at deactivation stage, I cleaned them up for you.
15:30:43 DEBUG    errbot.storage            Closed shelf of VersionChecker
15:30:43 INFO     errbot.backends.base      Reconnecting in 1 seconds (0 attempted reconnections so far)
15:30:44 INFO     errbot.backends.slack     Verifying authentication token
15:30:44 DEBUG    errbot.backends.slack     Token accepted
15:30:44 INFO     errbot.backends.slack     Connecting to Slack real-time-messaging API
15:30:45 INFO     errbot.backends.slack     Connected
15:30:46 DEBUG    errbot.backends.slack     Processing slack event: {'type': 'hello'}
15:30:46 INFO     errbot.errBot             Activate internal commands
15:30:46 INFO     errbot.errBot             Activating all the plugins...
15:30:46 INFO     errbot.errBot             Activate plugin: Webserver
15:30:46 INFO     errbot.plugin_manager     Activating Webserver with min_err_version = 2.2.1 and max_version = 2.2.1
15:30:46 DEBUG    errbot.templating         Templates directory found for this plugin [/home/whiskeyriver/Code/err/errbot/core_plugins/templates]
15:30:46 INFO     yapsy_loaded_plugin_Webse Webserver is not configured. Forbid activation
15:30:46 INFO     errbot.core_plugins.wsvie Checking Webserver for webhooks
15:30:46 INFO     errbot.core_plugins.wsvie ... Routing echo
15:30:46 INFO     errbot.errBot             Activate plugin: Backup
15:30:46 INFO     errbot.plugin_manager     Activating Backup with min_err_version = None and max_version = None
15:30:46 DEBUG    errbot.templating         Templates directory found for this plugin [/home/whiskeyriver/Code/err/errbot/core_plugins/templates]
15:30:46 DEBUG    errbot.botplugin          Init storage for Backup
15:30:46 DEBUG    errbot.botplugin          Loading /home/whiskeyriver/Code/err/data/plugins/Backup.db
15:30:46 INFO     errbot.storage            Opened shelf of Backup at /home/whiskeyriver/Code/err/data/plugins/Backup.db
15:30:46 DEBUG    errbot.backends.base      Adding command : backup -> backup
15:30:46 INFO     errbot.core_plugins.wsvie Checking Backup for webhooks
15:30:46 INFO     errbot.errBot             Activate plugin: ChatRoom
15:30:46 INFO     errbot.plugin_manager     Activating ChatRoom with min_err_version = 2.2.1 and max_version = 2.2.1
15:30:46 DEBUG    errbot.templating         Templates directory found for this plugin [/home/whiskeyriver/Code/err/errbot/core_plugins/templates]
15:30:46 DEBUG    errbot.botplugin          Init storage for ChatRoom
15:30:46 DEBUG    errbot.botplugin          Loading /home/whiskeyriver/Code/err/data/plugins/ChatRoom.db
15:30:46 INFO     errbot.storage            Opened shelf of ChatRoom at /home/whiskeyriver/Code/err/data/plugins/ChatRoom.db
15:30:46 DEBUG    errbot.backends.base      Adding command : gtalk_room_create -> gtalk_room_create
15:30:46 DEBUG    errbot.backends.base      Adding command : room_create -> room_create
15:30:46 DEBUG    errbot.backends.base      Adding command : room_destroy -> room_destroy
15:30:46 DEBUG    errbot.backends.base      Adding command : room_invite -> room_invite
15:30:46 DEBUG    errbot.backends.base      Adding command : room_join -> room_join
15:30:46 DEBUG    errbot.backends.base      Adding command : room_leave -> room_leave
15:30:46 DEBUG    errbot.backends.base      Adding command : room_list -> room_list
15:30:46 DEBUG    errbot.backends.base      Adding command : room_occupants -> room_occupants
15:30:46 DEBUG    errbot.backends.base      Adding command : room_topic -> room_topic
15:30:46 INFO     errbot.core_plugins.wsvie Checking ChatRoom for webhooks
15:30:46 INFO     errbot.errBot             Activate plugin: VersionChecker
15:30:46 INFO     errbot.plugin_manager     Activating VersionChecker with min_err_version = 2.2.1 and max_version = 2.2.1
15:30:46 DEBUG    errbot.templating         Templates directory found for this plugin [/home/whiskeyriver/Code/err/errbot/core_plugins/templates]
15:30:46 DEBUG    yapsy_loaded_plugin_Versi Checking version
15:30:47 DEBUG    errbot.botplugin          Programming the polling of version_check every 86400 seconds with args [] and kwargs {}
15:30:47 DEBUG    errbot.botplugin          Init storage for VersionChecker
15:30:47 DEBUG    errbot.botplugin          Loading /home/whiskeyriver/Code/err/data/plugins/VersionChecker.db
15:30:47 INFO     errbot.storage            Opened shelf of VersionChecker at /home/whiskeyriver/Code/err/data/plugins/VersionChecker.db
15:30:47 INFO     errbot.core_plugins.wsvie Checking VersionChecker for webhooks
15:30:47 INFO     errbot.errBot
15:30:47 INFO     errbot.errBot             Notifying connection to all the plugins...
15:30:47 DEBUG    errbot.errBot             Trigger callback_connect on Backup
15:30:47 DEBUG    errbot.errBot             Trigger callback_connect on ChatRoom
15:30:47 INFO     yapsy_loaded_plugin_ChatR Callback_connect
15:30:47 DEBUG    errbot.errBot             Trigger callback_connect on VersionChecker
15:30:47 INFO     errbot.errBot             Plugin activation done.
15:30:47 DEBUG    errbot.backends.base      Adding command : about -> about
15:30:47 DEBUG    errbot.backends.base      Adding command : apropos -> apropos
15:30:47 DEBUG    errbot.backends.base      Adding command : blacklist -> blacklist
15:30:47 DEBUG    errbot.backends.base      Adding command : config -> config
15:30:47 DEBUG    errbot.backends.base      Adding command : echo -> echo
15:30:47 DEBUG    errbot.backends.base      Adding command : help -> help
15:30:47 DEBUG    errbot.backends.base      Adding command : history -> history
15:30:47 DEBUG    errbot.backends.base      Adding command : load -> load
15:30:47 DEBUG    errbot.backends.base      Adding command : log_tail -> log_tail
15:30:47 DEBUG    errbot.backends.base      Adding command : reload -> reload
15:30:47 DEBUG    errbot.backends.base      Adding command : repos -> repos
15:30:47 DEBUG    errbot.backends.base      Adding command : repos_install -> repos_install
15:30:47 DEBUG    errbot.backends.base      Adding command : repos_uninstall -> repos_uninstall
15:30:47 DEBUG    errbot.backends.base      Adding command : repos_update -> repos_update
15:30:47 DEBUG    errbot.backends.base      Adding command : restart -> restart
15:30:47 DEBUG    errbot.backends.base      Adding command : status -> status
15:30:47 DEBUG    errbot.backends.base      Adding command : status_gc -> status_gc
15:30:47 DEBUG    errbot.backends.base      Adding command : status_load -> status_load
15:30:47 DEBUG    errbot.backends.base      Adding command : status_plugins -> status_plugins
15:30:47 DEBUG    errbot.backends.base      Adding command : unblacklist -> unblacklist
15:30:47 DEBUG    errbot.backends.base      Adding command : unload -> unload
15:30:47 DEBUG    errbot.backends.base      Adding command : uptime -> uptime
15:30:47 DEBUG    errbot.errBot             Triggering callback_presence on Backup
15:30:47 DEBUG    errbot.errBot             Triggering callback_presence on ChatRoom
15:30:47 DEBUG    errbot.errBot             Triggering callback_presence on VersionChecker
15:30:48 DEBUG    errbot.backends.slack     Processing slack event: {'user': 'U00ERRBOT', 'text': 'Yes I am alive...        \n            \n        With these plugins (L=Loaded, U=Unloaded, B=Blacklisted, C=Needs to be configured):\n                    [L] Backup\n                    [L] ChatRoom\n                    [L] VersionChecker\n                    [C] Webserver\n        \n        Load 0.07, 0.04, 0.05\n        GC 0-&amp;gt;66 1-&amp;gt;4 2-&amp;gt;6', 'reply_to': None, 'channel': 'G00000002', 'ts': '1433881813.000008', 'type': 'message'}
15:30:48 DEBUG    errbot.backends.slack     Handling message from a private group
15:30:48 ERROR    errbot.backends.slack     message event handler raised an exception
Traceback (most recent call last):
File "/home/whiskeyriver/Code/err/errbot/backends/slack.py", line 154, in serve_once
event_handler(message)
File "/home/whiskeyriver/Code/err/errbot/backends/slack.py", line 210, in _message_event_handler
node=self.channelid_to_channelname(event['channel']),
File "/home/whiskeyriver/Code/err/errbot/backends/slack.py", line 241, in channelid_to_channelname
return channel.name
AttributeError: 'list' object has no attribute 'name'
15:30:52 DEBUG    errbot.backends.slack     No event handler available for user_typing, ignoring this event
15:30:53 DEBUG    errbot.backends.slack     Processing slack event: {'user': 'UWHSKYRVR', 'text': '!status', 'team': 'TSHNYSRVR', 'channel': 'G00000002', 'ts': '1433881853.000010', 'type': 'message'}
15:30:53 DEBUG    errbot.backends.slack     Handling message from a private group
15:30:53 ERROR    errbot.backends.slack     message event handler raised an exception
Traceback (most recent call last):
File "/home/whiskeyriver/Code/err/errbot/backends/slack.py", line 154, in serve_once
event_handler(message)
File "/home/whiskeyriver/Code/err/errbot/backends/slack.py", line 210, in _message_event_handler
node=self.channelid_to_channelname(event['channel']),
File "/home/whiskeyriver/Code/err/errbot/backends/slack.py", line 241, in channelid_to_channelname
return channel.name
AttributeError: 'list' object has no attribute 'name'
15:31:25 DEBUG    errbot.backends.slack     Processing slack event: {'user': 'U00000003', 'type': 'presence_change', 'presence': 'away'}
15:31:25 DEBUG    errbot.errBot             Triggering callback_presence on Backup
15:31:25 DEBUG    errbot.errBot             Triggering callback_presence on ChatRoom
15:31:25 DEBUG    errbot.errBot             Triggering callback_presence on VersionChecker
15:32:25 DEBUG    errbot.backends.slack     Processing slack event: {'user': 'U00000004', 'type': 'presence_change', 'presence': 'away'}
15:32:25 DEBUG    errbot.errBot             Triggering callback_presence on Backup
15:32:25 DEBUG    errbot.errBot             Triggering callback_presence on ChatRoom
15:32:25 DEBUG    errbot.errBot             Triggering callback_presence on VersionChecker
15:32:59 DEBUG    errbot.backends.slack     No event handler available for user_typing, ignoring this event
15:33:00 DEBUG    errbot.backends.slack     Processing slack event: {'user': 'UWHSKYRVR', 'text': '!status', 'team': 'TSHNYSRVR', 'channel': 'G00000002', 'ts': '1433881980.000011', 'type': 'message'}
15:33:00 DEBUG    errbot.backends.slack     Handling message from a private group
15:33:00 ERROR    errbot.backends.slack     message event handler raised an exception
Traceback (most recent call last):
File "/home/whiskeyriver/Code/err/errbot/backends/slack.py", line 154, in serve_once
event_handler(message)
File "/home/whiskeyriver/Code/err/errbot/backends/slack.py", line 210, in _message_event_handler
node=self.channelid_to_channelname(event['channel']),
File "/home/whiskeyriver/Code/err/errbot/backends/slack.py", line 241, in channelid_to_channelname
return channel.name
AttributeError: 'list' object has no attribute 'name'
15:33:10 DEBUG    errbot.backends.slack     No event handler available for user_typing, ignoring this event
15:33:12 DEBUG    errbot.backends.slack     Processing slack event: {'user': 'UWHSKYRVR', 'text': '<@U00ERRBOT>: die', 'team': 'TSHNYSRVR', 'channel': 'C00000001', 'ts': '1433881993.000187', 'type': 'message'}
15:33:12 DEBUG    errbot.backends.slack     Handling message from a public channel
15:33:12 ERROR    errbot.backends.slack     message event handler raised an exception
Traceback (most recent call last):
File "/home/whiskeyriver/Code/err/errbot/backends/slack.py", line 154, in serve_once
event_handler(message)
File "/home/whiskeyriver/Code/err/errbot/backends/slack.py", line 210, in _message_event_handler
node=self.channelid_to_channelname(event['channel']),
File "/home/whiskeyriver/Code/err/errbot/backends/slack.py", line 241, in channelid_to_channelname
return channel.name
AttributeError: 'list' object has no attribute 'name'
^C15:33:20 INFO     errbot.backends.slack     Interrupt received, shutting down..
15:33:20 DEBUG    errbot.backends.slack     Triggering disconnect callback
15:33:20 INFO     errbot.errBot             Disconnect callback, deactivating all the plugins.
15:33:20 DEBUG    errbot.storage            Closed shelf of Backup
15:33:20 DEBUG    errbot.storage            Closed shelf of ChatRoom
15:33:20 DEBUG    errbot.botplugin          You still have active pollers at deactivation stage, I cleaned them up for you.
15:33:20 DEBUG    errbot.storage            Closed shelf of VersionChecker
15:33:20 INFO     errbot.backends.base      Trigger shutdown
15:33:20 INFO     errbot.errBot             Shutdown.
15:33:20 DEBUG    errbot.storage            Closed shelf of SlackBackend
15:33:20 INFO     errbot.errBot             Bye.
15:33:20 INFO     __main__                  Process exiting

# Fixed code
def serve_once(self):
    self.sc = SlackClient(self.token)
    log.info("Verifying authentication token")
    self.auth = self.api_call("auth.test", raise_errors=False)
    if not self.auth["ok"]:
        log.error(
            "Couldn't authenticate with Slack. Server said: %s" % self.auth["error"]
        )
    log.debug("Token accepted")
    self.jid = SlackIdentifier(
        node=self.auth["user_id"],
        domain=self.sc.server.domain,
        resource=self.auth["user_id"],
    )

    log.info("Connecting to Slack real-time-messaging API")
    if self.sc.rtm_connect():
        log.info("Connected")
        self.reset_reconnection_count()
        try:
            while True:
                for message in self.sc.rtm_read():
                    if "type" not in message:
                        log.debug("Ignoring non-event message: %s" % message)
                        continue

                    event_type = message["type"]
                    event_handler = getattr(
                        self, "_%s_event_handler" % event_type, None
                    )
                    if event_handler is None:
                        log.debug(
                            "No event handler available for %s, ignoring this event"
                            % event_type
                        )
                        continue
                    try:
                        log.debug("Processing slack event: %s" % message)
                        event_handler(message)
                    except Exception:
                        log.exception(
                            "%s event handler raised an exception" % event_type
                        )
                time.sleep(1)
        except KeyboardInterrupt:
            log.info("Interrupt received, shutting down..")
            return True
        except:
            log.exception("Error reading from RTM stream:")
        finally:
            log.debug("Triggering disconnect callback")
            self.disconnect_callback()
    else:
        raise Exception("Connection failed, invalid token ?")