Exemple #1
0
def handle_message(event):
    session = getattr(g, 'session', None)
    msgId = event.message.id
    message_content = line_bot_api.get_message_content(msgId)

    if sequence_is_not_initialized(session) or session.get(
            'next_input') == IMAGE:
        # upload s3
        presigned_url = img_s3.upload_to_s3(message_content.content, bucket)
        print(presigned_url)

        # set input value to session
        session['IMAGE'] = presigned_url
        session['next_input'] = DESCRIPTION
        basic_reply(event.reply_token, session.get('next_input'))

    else:
        # when get wrong input value
        basic_reply(event.reply_token, session.get('next_input'))
Exemple #2
0
    def handle_image_message(self, event, session):
        msgId = event.message.id
        message_content = self.line_bot_api.get_message_content(msgId)

        # when session is not initialized
        if 'next_input' not in session or session.get('next_input') == IMAGE:
            # upload s3
            presigned_url = img_s3.upload_to_s3(message_content.content,
                                                bucket)
            print(presigned_url)

            # set input value to session
            session['IMAGE'] = presigned_url
            session['next_input'] = DESCRIPTION
            self.basic_reply(event.reply_token, session.get('next_input'))

        else:
            # when get wrong input value
            self.basic_reply(event.reply_token, session.get('next_input'))
Exemple #3
0
    def handle_image_message(self, event, session):
        msgId = event.message.id
        message_content = self.line_bot_api.get_message_content(msgId)

        if session.get('edit_target') == IMAGE:
            # upload s3
            presigned_url  = img_s3.upload_to_s3(message_content.content, bucket)
            print(presigned_url)

            # set a new value to session
            self.edit_item_detail('image_url', presigned_url, session)
            self.show_items(event.reply_token, session)

            # reset flow and edit_target
            self.reset(session)

        else:
            # when get wrong input value
            self.basic_reply(event.reply_token, session.get('edit_target'))