def _handle_long_response(self, res):
        """Splits messages that are too long into multiple events
        :param res: a slack response string or dict
        """

        is_rtm_message = isinstance(res, basestring)
        is_api_message = isinstance(res, dict)

        if is_rtm_message:
            text = res
        elif is_api_message:
            text = res['text']

        message_length = len(text)

        if message_length <= SLACK_MESSAGE_LIMIT:
            return [res]

        remaining_str = text
        responses = []

        while remaining_str:
            less_than_limit = len(remaining_str) < SLACK_MESSAGE_LIMIT

            if less_than_limit:
                last_line_break = None
            else:
                last_line_break = remaining_str[:SLACK_MESSAGE_LIMIT].rfind('\n')

            if is_rtm_message:
                responses.append(remaining_str[:last_line_break])
            elif is_api_message:
                template = res.copy()
                template['text'] = remaining_str[:last_line_break]
                responses.append(template)

            if less_than_limit:
                remaining_str = None
            else:
                remaining_str = remaining_str[last_line_break:]

        self.log.debug("_handle_long_response: splitting long response %s, returns: \n %s",
                pprint.pformat(res), pprint.pformat(responses))
        return responses