def _slack_message_to_parts()

in processors/slack.py [0:0]


    def _slack_message_to_parts(self, message, token, multi_modal, no_question):
        parts = []
        if 'files' in message and multi_modal:
            for file in message['files']:
                if file['size'] >= 20971520:  # 20MB limit
                    self.logger.debug(
                        'Attachment too large to download from Slack (%d bytes).'
                        % (file['size']),
                        extra={'file': file})
                    continue
                if file['mimetype'][0:6] == 'image/':
                    self.logger.info(
                        'Downloaded Slack image (720p version): %s (mime %s)' %
                        (file['thumb_720'], file['mimetype']),
                        extra={'mimetype': file['mimetype']})
                    if 'thumb_720' in file:
                        parts.append({
                            'inlineData': {
                                'mimeType':
                                    file['mimetype'],
                                'data':
                                    self.download_slack(file['thumb_720'],
                                                        token)
                            }
                        })
                    elif 'url_private_download' in file:
                        self.logger.info(
                            'Downloaded Slack image (full version): %s (mime %s)'
                            % (file['url_private_download'], file['mimetype']),
                            extra={'mimetype': file['mimetype']})
                        parts.append({
                            'inlineData': {
                                'mimeType':
                                    file['mimetype'],
                                'data':
                                    self.download_slack(
                                        file['url_private_download'], token)
                            }
                        })
                elif 'url_private_download' in file:
                    self.logger.info(
                        'Downloaded Slack file: %s (mime %s)' %
                        (file['url_private_download'], file['mimetype']),
                        extra={'mimetype': file['mimetype']})
                    parts.append({
                        'inlineData': {
                            'mimeType':
                                file['mimetype'],
                            'data':
                                self.download_slack(
                                    file['url_private_download'], token)
                        }
                    })
        if 'text' in message and message['text'] != '':
            parts.append({'text': message['text']})
        elif no_question != '':
            parts.append({'text': no_question})

        return parts