line/line-bot-sdk-python

How to used ClipboardAction?

dalnel opened this issue · 3 comments

I want add ClipboardAction in Buttons Template ,but it is not work,my code:

from linebot.v3.messaging.models import ClipboardAction
from linebot.models import ButtonsTemplate, MessageAction, TemplateSendMessage, CarouselTemplate,  CarouselColumn, PostbackAction, URIAction

def delet_CarouselTemplate():
    columns=[]
    column_item = ButtonsTemplate(
        title="copy test",
        text="click button to copy text",
        actions=[
            ClipboardAction(
                type="clipboard",
                label="copy",
                clipboardText="copy hellow word"
            )
        ]
    )
    columns.append(column_item)
    return TemplateSendMessage(
        alt_text='ButtonsTemplate',
        template=ButtonsTemplate(columns)
    )
CarouselTemplate = delet_CarouselTemplate()
line_bot_api.reply_message(tk,CarouselTemplate)

I used breakpoints in VS Code to inspect what was happening, and I found out that this action was not even added. So, I checked the linebot.models, and I realized that ClipboardAction is not included there. Did I use the wrong method or did I forget to add it?

image

I can't use this action either

Hi @YrChen1001, thank you for using line-bot-sdk-python.
Please import definition from linebot.v3.messaging.models instead of linebot.models. linebot.models are too old. I'll deprecate them.

elif text == 'buttons':
buttons_template = ButtonsTemplate(
title='My buttons sample',
text='Hello, my buttons',
actions=[
URIAction(label='Go to line.me', uri='https://line.me'),
PostbackAction(label='ping', data='ping'),
PostbackAction(label='ping with text', data='ping', text='ping'),
MessageAction(label='Translate Rice', text='米')
])
template_message = TemplateMessage(
alt_text='Buttons alt text',
template=buttons_template
)
line_bot_api.reply_message(
ReplyMessageRequest(
reply_token=event.reply_token,
messages=[template_message]
)
)
shows how to use ButtonsTemplate in linebot.v3.messaging.models, that might help you!