def _get_next_event(self):
"""Slack-specific message reader.
Returns a web event from the API listener if available, otherwise
waits for the slack streaming event.
"""
if len(self._web_events):
event = self._web_events.pop()
raise gen.Return(event)
# TODO: rewrite this logic to use `on_message` feature of the socket
# FIXME: At the moment if there are 0 socket messages then web_events
# will never be handled.
message = yield self.connection.read_message()
log.debug('Slack message: "%s"' % message)
message = json.loads(message)
raise gen.Return(message)
评论列表
文章目录