Skip to content

Commit 7ae50c6

Browse files
nnsnodnbbe-hase
authored andcommitted
Add display_text in PostbackAction (#110)
1 parent b39e645 commit 7ae50c6

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

linebot/models/actions.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,15 @@ class PostbackAction(Action):
7070
a postback event is returned via webhook with the specified string in the data property.
7171
"""
7272

73-
def __init__(self, label=None, data=None, text=None, **kwargs):
73+
def __init__(self, label=None, data=None, display_text=None, text=None, **kwargs):
7474
"""__init__ method.
7575
7676
:param str label: Label for the action.
7777
:param str data: String returned via webhook
7878
in the postback.data property of the postback event.
79-
:param str text: Text displayed in the chat as a message sent by
79+
:param str display_text: Text displayed in the chat as a message sent by
80+
the user when the action is performed.
81+
:param str text: Deprecated. Text displayed in the chat as a message sent by
8082
the user when the action is performed. Returned from the server through a webhook.
8183
:param kwargs:
8284
"""
@@ -85,6 +87,7 @@ def __init__(self, label=None, data=None, text=None, **kwargs):
8587
self.type = 'postback'
8688
self.label = label
8789
self.data = data
90+
self.display_text = display_text
8891
self.text = text
8992

9093

tests/api/test_send_template_message.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def setUp(self):
4444
title='Menu', text='Please select',
4545
actions=[
4646
PostbackAction(
47-
label='postback', text='postback text',
47+
label='postback', display_text='postback text',
4848
data='action=buy&itemid=1'
4949
),
5050
MessageAction(
@@ -70,7 +70,7 @@ def setUp(self):
7070
{
7171
"type": "postback",
7272
"label": "postback",
73-
"text": "postback text",
73+
"displayText": "postback text",
7474
"data": "action=buy&itemid=1"
7575
},
7676
{
@@ -93,7 +93,7 @@ def setUp(self):
9393
text='Are you sure?',
9494
actions=[
9595
PostbackAction(
96-
label='postback', text='postback text',
96+
label='postback', display_text='postback text',
9797
data='action=buy&itemid=1'
9898
),
9999
MessageAction(
@@ -113,7 +113,7 @@ def setUp(self):
113113
{
114114
"type": "postback",
115115
"label": "postback",
116-
"text": "postback text",
116+
"displayText": "postback text",
117117
"data": "action=buy&itemid=1"
118118
},
119119
{
@@ -135,7 +135,7 @@ def setUp(self):
135135
title='this is menu1', text='description1',
136136
actions=[
137137
PostbackAction(
138-
label='postback1', text='postback text1',
138+
label='postback1', display_text='postback text1',
139139
data='action=buy&itemid=1'
140140
),
141141
MessageAction(
@@ -154,7 +154,7 @@ def setUp(self):
154154
title='this is menu2', text='description2',
155155
actions=[
156156
PostbackAction(
157-
label='postback2', text='postback text2',
157+
label='postback2', display_text='postback text2',
158158
data='action=buy&itemid=2'
159159
),
160160
MessageAction(
@@ -216,7 +216,7 @@ def setUp(self):
216216
{
217217
"type": "postback",
218218
"label": "postback1",
219-
"text": "postback text1",
219+
"displayText": "postback text1",
220220
"data": "action=buy&itemid=1"
221221
},
222222
{
@@ -241,7 +241,7 @@ def setUp(self):
241241
{
242242
"type": "postback",
243243
"label": "postback2",
244-
"text": "postback text2",
244+
"displayText": "postback text2",
245245
"data": "action=buy&itemid=2"
246246
},
247247
{

0 commit comments

Comments
 (0)