質問編集履歴
1
レイアウト
test
CHANGED
File without changes
|
test
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
|
3
3
|
linebotでflex_messageを使ってbotを作りたい!!
|
4
4
|
|
5
|
+
pythonでlinebotを作っています。GitHubのlinebot-sdkの中のflex_message.pyを利用したいのですが、”contents=”の後をどう書けばいいかわかりません。Josonを書けばいいのでしょうか?
|
6
|
+
|
7
|
+
下にcodeを載せます。
|
8
|
+
|
5
9
|
|
6
10
|
|
7
11
|
ここに質問の内容を詳しく書いてください。
|
8
12
|
|
9
|
-
(例)PHP(CakePHP)で●●なシステムを作っています。
|
10
|
-
|
11
|
-
■■な機能を実装中に以下のエラーメッセージが発生しました。
|
12
|
-
|
13
13
|
|
14
14
|
|
15
15
|
### 発生している問題・エラーメッセージ
|
@@ -18,7 +18,401 @@
|
|
18
18
|
|
19
19
|
```
|
20
20
|
|
21
|
+
from __future__ import unicode_literals
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
from abc import ABCMeta
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
from future.utils import with_metaclass
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
from .actions import get_action
|
34
|
+
|
35
|
+
from .base import Base
|
36
|
+
|
37
|
+
from .send_messages import SendMessage
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
class FlexSendMessage(SendMessage):
|
44
|
+
|
45
|
+
"""FlexSendMessage.
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
https://developers.line.me/en/docs/messaging-api/reference/#flex-message
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
Flex Messages are messages with a customizable layout.
|
54
|
+
|
55
|
+
You can customize the layout freely by combining multiple elements.
|
56
|
+
|
57
|
+
"""
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
def __init__(self, alt_text=None, contents=None, **kwargs):
|
62
|
+
|
63
|
+
"""__init__ method.
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
:param str alt_text: Alternative text
|
68
|
+
|
69
|
+
:param contents: Flex Message container object
|
70
|
+
|
71
|
+
:type contents: :py:class:`linebot.models.flex_message.FlexContainer`
|
72
|
+
|
73
|
+
:param kwargs:
|
74
|
+
|
75
|
+
"""
|
76
|
+
|
77
|
+
super(FlexSendMessage, self).__init__(**kwargs)
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
self.type = 'flex'
|
82
|
+
|
83
|
+
self.alt_text = alt_text
|
84
|
+
|
85
|
+
self.contents = contents
|
86
|
+
|
87
|
+
self.contents = self.get_or_new_from_json_dict_with_types(
|
88
|
+
|
89
|
+
contents, {
|
90
|
+
|
91
|
+
'bubble': BubbleContainer,
|
92
|
+
|
93
|
+
'carousel': CarouselContainer
|
94
|
+
|
95
|
+
}
|
96
|
+
|
97
|
+
)
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
class FlexContainer(with_metaclass(ABCMeta, Base)):
|
104
|
+
|
105
|
+
"""FlexContainer.
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
https://developers.line.me/en/docs/messaging-api/reference/#container
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
A container is the top-level structure of a Flex Message.
|
114
|
+
|
115
|
+
"""
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
def __init__(self, **kwargs):
|
120
|
+
|
121
|
+
"""__init__ method.
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
:param kwargs:
|
126
|
+
|
127
|
+
"""
|
128
|
+
|
129
|
+
super(FlexContainer, self).__init__(**kwargs)
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
self.type = None
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
class BubbleContainer(FlexContainer):
|
140
|
+
|
141
|
+
"""BubbleContainer.
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
https://developers.line.me/en/docs/messaging-api/reference/#bubble-container
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
This is a container that contains one message bubble.
|
150
|
+
|
151
|
+
It can contain four blocks: header, hero, body, and footer.
|
152
|
+
|
153
|
+
"""
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
def __init__(self, direction=None, header=None, hero=None, body=None, footer=None, styles=None,
|
158
|
+
|
159
|
+
**kwargs):
|
160
|
+
|
161
|
+
"""__init__ method.
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
:param str direction: Text directionality and the order of components
|
166
|
+
|
167
|
+
in horizontal boxes in the container
|
168
|
+
|
169
|
+
:param header: Header block
|
170
|
+
|
171
|
+
:type header: :py:class:`linebot.models.flex_message.BoxComponent`
|
172
|
+
|
173
|
+
:param hero: Hero block
|
174
|
+
|
175
|
+
:type hero: :py:class:`linebot.models.flex_message.ImageComponent`
|
176
|
+
|
177
|
+
:param body: Body block
|
178
|
+
|
179
|
+
:type body: :py:class:`linebot.models.flex_message.BoxComponent`
|
180
|
+
|
181
|
+
:param footer: Footer block
|
182
|
+
|
183
|
+
:type footer: :py:class:`linebot.models.flex_message.BoxComponent`
|
184
|
+
|
185
|
+
:param styles: Style of each block
|
186
|
+
|
187
|
+
:type styles: :py:class:`linebot.models.flex_message.BubbleStyle`
|
188
|
+
|
189
|
+
:param kwargs:
|
190
|
+
|
191
|
+
"""
|
192
|
+
|
193
|
+
super(BubbleContainer, self).__init__(**kwargs)
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
self.type = 'bubble'
|
198
|
+
|
199
|
+
self.direction = direction
|
200
|
+
|
201
|
+
self.header = self.get_or_new_from_json_dict(header, BoxComponent)
|
202
|
+
|
203
|
+
self.hero = self.get_or_new_from_json_dict(hero, ImageComponent)
|
204
|
+
|
205
|
+
self.body = self.get_or_new_from_json_dict(body, BoxComponent)
|
206
|
+
|
207
|
+
self.footer = self.get_or_new_from_json_dict(footer, BoxComponent)
|
208
|
+
|
209
|
+
self.styles = self.get_or_new_from_json_dict(styles, BubbleStyle)
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
class BubbleStyle(with_metaclass(ABCMeta, Base)):
|
216
|
+
|
217
|
+
"""BubbleStyle.
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
https://developers.line.me/en/docs/messaging-api/reference/#objects-for-the-block-style
|
222
|
+
|
223
|
+
"""
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
def __init__(self, header=None, hero=None, body=None, footer=None, **kwargs):
|
228
|
+
|
229
|
+
"""__init__ method.
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
:param header: Style of the header block
|
234
|
+
|
235
|
+
:type header: :py:class:`linebot.models.flex_message.BlockStyle`
|
236
|
+
|
237
|
+
:param hero: Style of the hero block
|
238
|
+
|
239
|
+
:type hero: :py:class:`linebot.models.flex_message.BlockStyle`
|
240
|
+
|
241
|
+
:param body: Style of the body block
|
242
|
+
|
243
|
+
:type body: :py:class:`linebot.models.flex_message.BlockStyle`
|
244
|
+
|
245
|
+
:param footer: Style of the footer block
|
246
|
+
|
247
|
+
:type footer: :py:class:`linebot.models.flex_message.BlockStyle`
|
248
|
+
|
249
|
+
:param kwargs:
|
250
|
+
|
251
|
+
"""
|
252
|
+
|
253
|
+
super(BubbleStyle, self).__init__(**kwargs)
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
self.header = self.get_or_new_from_json_dict(header, BlockStyle)
|
258
|
+
|
259
|
+
self.hero = self.get_or_new_from_json_dict(hero, BlockStyle)
|
260
|
+
|
261
|
+
self.body = self.get_or_new_from_json_dict(body, BlockStyle)
|
262
|
+
|
263
|
+
self.footer = self.get_or_new_from_json_dict(footer, BlockStyle)
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
class BlockStyle(with_metaclass(ABCMeta, Base)):
|
270
|
+
|
271
|
+
"""BlockStyle.
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
https://developers.line.me/en/docs/messaging-api/reference/#objects-for-the-block-style
|
276
|
+
|
277
|
+
"""
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
def __init__(self, background_color=None, separator=None, separator_color=None, **kwargs):
|
282
|
+
|
283
|
+
"""__init__ method.
|
284
|
+
|
285
|
+
|
286
|
+
|
287
|
+
:param str background_color: Background color of the block. Use a hexadecimal color code
|
288
|
+
|
289
|
+
:param bool separator: True to place a separator above the block
|
290
|
+
|
291
|
+
True will be ignored for the first block in a container
|
292
|
+
|
293
|
+
because you cannot place a separator above the first block.
|
294
|
+
|
295
|
+
The default value is False
|
296
|
+
|
297
|
+
:param str separator_color: Color of the separator. Use a hexadecimal color code
|
298
|
+
|
299
|
+
:param kwargs:
|
300
|
+
|
301
|
+
"""
|
302
|
+
|
303
|
+
super(BlockStyle, self).__init__(**kwargs)
|
304
|
+
|
305
|
+
self.background_color = background_color
|
306
|
+
|
307
|
+
self.separator = separator
|
308
|
+
|
309
|
+
self.separator_color = separator_color
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
class CarouselContainer(FlexContainer):
|
316
|
+
|
317
|
+
"""CarouselContainer.
|
318
|
+
|
319
|
+
|
320
|
+
|
21
|
-
p
|
321
|
+
https://developers.line.me/en/docs/messaging-api/reference/#carousel-container
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
This is a container that contains multiple bubble containers, or message bubbles.
|
326
|
+
|
327
|
+
The bubbles will be shown in order by scrolling horizontally.
|
328
|
+
|
329
|
+
"""
|
330
|
+
|
331
|
+
|
332
|
+
|
333
|
+
def __init__(self, contents=None, **kwargs):
|
334
|
+
|
335
|
+
"""__init__ method.
|
336
|
+
|
337
|
+
|
338
|
+
|
339
|
+
:param contents: Array of bubble containers
|
340
|
+
|
341
|
+
:type contents: list[T <= :py:class:`linebot.models.flex_message.BubbleContainer`]
|
342
|
+
|
343
|
+
:param kwargs:
|
344
|
+
|
345
|
+
"""
|
346
|
+
|
347
|
+
super(CarouselContainer, self).__init__(**kwargs)
|
348
|
+
|
349
|
+
|
350
|
+
|
351
|
+
self.type = 'carousel'
|
352
|
+
|
353
|
+
|
354
|
+
|
355
|
+
new_contents = []
|
356
|
+
|
357
|
+
if contents:
|
358
|
+
|
359
|
+
for it in contents:
|
360
|
+
|
361
|
+
new_contents.append(self.get_or_new_from_json_dict(
|
362
|
+
|
363
|
+
it, BubbleContainer
|
364
|
+
|
365
|
+
))
|
366
|
+
|
367
|
+
self.contents = new_contents
|
368
|
+
|
369
|
+
|
370
|
+
|
371
|
+
|
372
|
+
|
373
|
+
class FlexComponent(with_metaclass(ABCMeta, Base)):
|
374
|
+
|
375
|
+
"""FlexComponent.
|
376
|
+
|
377
|
+
|
378
|
+
|
379
|
+
https://developers.line.me/en/docs/messaging-api/reference/#component
|
380
|
+
|
381
|
+
|
382
|
+
|
383
|
+
Components are objects that compose a Flex Message container.
|
384
|
+
|
385
|
+
"""
|
386
|
+
|
387
|
+
|
388
|
+
|
389
|
+
def __init__(self, **kwargs):
|
390
|
+
|
391
|
+
"""__init__ method.
|
392
|
+
|
393
|
+
|
394
|
+
|
395
|
+
:param kwargs:
|
396
|
+
|
397
|
+
"""
|
398
|
+
|
399
|
+
super(FlexComponent, self).__init__(**kwargs)
|
400
|
+
|
401
|
+
|
402
|
+
|
403
|
+
self.type = None
|
404
|
+
|
405
|
+
|
406
|
+
|
407
|
+
|
408
|
+
|
409
|
+
…………
|
410
|
+
|
411
|
+
……
|
412
|
+
|
413
|
+
…(略)
|
414
|
+
|
415
|
+
|
22
416
|
|
23
417
|
```
|
24
418
|
|
@@ -28,401 +422,7 @@
|
|
28
422
|
|
29
423
|
|
30
424
|
|
31
|
-
|
32
|
-
|
33
|
-
from __future__ import unicode_literals
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
from abc import ABCMeta
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
from future.utils import with_metaclass
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
from .actions import get_action
|
46
|
-
|
47
|
-
from .base import Base
|
48
|
-
|
49
|
-
from .send_messages import SendMessage
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
class FlexSendMessage(SendMessage):
|
56
|
-
|
57
|
-
"""FlexSendMessage.
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
https://developers.line.me/en/docs/messaging-api/reference/#flex-message
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
Flex Messages are messages with a customizable layout.
|
66
|
-
|
67
|
-
You can customize the layout freely by combining multiple elements.
|
68
|
-
|
69
|
-
"""
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
def __init__(self, alt_text=None, contents=None, **kwargs):
|
74
|
-
|
75
|
-
"""__init__ method.
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
:param str alt_text: Alternative text
|
80
|
-
|
81
|
-
:param contents: Flex Message container object
|
82
|
-
|
83
|
-
:type contents: :py:class:`linebot.models.flex_message.FlexContainer`
|
84
|
-
|
85
|
-
:param kwargs:
|
86
|
-
|
87
|
-
"""
|
88
|
-
|
89
|
-
super(FlexSendMessage, self).__init__(**kwargs)
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
self.type = 'flex'
|
94
|
-
|
95
|
-
self.alt_text = alt_text
|
96
|
-
|
97
|
-
self.contents = contents
|
98
|
-
|
99
|
-
self.contents = self.get_or_new_from_json_dict_with_types(
|
100
|
-
|
101
|
-
contents, {
|
102
|
-
|
103
|
-
'bubble': BubbleContainer,
|
104
|
-
|
105
|
-
'carousel': CarouselContainer
|
106
|
-
|
107
|
-
}
|
108
|
-
|
109
|
-
)
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
class FlexContainer(with_metaclass(ABCMeta, Base)):
|
116
|
-
|
117
|
-
"""FlexContainer.
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
https://developers.line.me/en/docs/messaging-api/reference/#container
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
A container is the top-level structure of a Flex Message.
|
126
|
-
|
127
|
-
"""
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
def __init__(self, **kwargs):
|
132
|
-
|
133
|
-
"""__init__ method.
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
:param kwargs:
|
138
|
-
|
139
|
-
"""
|
140
|
-
|
141
|
-
super(FlexContainer, self).__init__(**kwargs)
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
self.type = None
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
class BubbleContainer(FlexContainer):
|
152
|
-
|
153
|
-
"""BubbleContainer.
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
https://developers.line.me/en/docs/messaging-api/reference/#bubble-container
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
This is a container that contains one message bubble.
|
162
|
-
|
163
|
-
It can contain four blocks: header, hero, body, and footer.
|
164
|
-
|
165
|
-
"""
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
def __init__(self, direction=None, header=None, hero=None, body=None, footer=None, styles=None,
|
170
|
-
|
171
|
-
**kwargs):
|
172
|
-
|
173
|
-
"""__init__ method.
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
:param str direction: Text directionality and the order of components
|
178
|
-
|
179
|
-
in horizontal boxes in the container
|
180
|
-
|
181
|
-
:param header: Header block
|
182
|
-
|
183
|
-
:type header: :py:class:`linebot.models.flex_message.BoxComponent`
|
184
|
-
|
185
|
-
:param hero: Hero block
|
186
|
-
|
187
|
-
:type hero: :py:class:`linebot.models.flex_message.ImageComponent`
|
188
|
-
|
189
|
-
:param body: Body block
|
190
|
-
|
191
|
-
:type body: :py:class:`linebot.models.flex_message.BoxComponent`
|
192
|
-
|
193
|
-
:param footer: Footer block
|
194
|
-
|
195
|
-
:type footer: :py:class:`linebot.models.flex_message.BoxComponent`
|
196
|
-
|
197
|
-
:param styles: Style of each block
|
198
|
-
|
199
|
-
:type styles: :py:class:`linebot.models.flex_message.BubbleStyle`
|
200
|
-
|
201
|
-
:param kwargs:
|
202
|
-
|
203
|
-
"""
|
204
|
-
|
205
|
-
super(BubbleContainer, self).__init__(**kwargs)
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
self.type = 'bubble'
|
210
|
-
|
211
|
-
self.direction = direction
|
212
|
-
|
213
|
-
self.header = self.get_or_new_from_json_dict(header, BoxComponent)
|
214
|
-
|
215
|
-
self.hero = self.get_or_new_from_json_dict(hero, ImageComponent)
|
216
|
-
|
217
|
-
self.body = self.get_or_new_from_json_dict(body, BoxComponent)
|
218
|
-
|
219
|
-
self.footer = self.get_or_new_from_json_dict(footer, BoxComponent)
|
220
|
-
|
221
|
-
self.styles = self.get_or_new_from_json_dict(styles, BubbleStyle)
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
class BubbleStyle(with_metaclass(ABCMeta, Base)):
|
228
|
-
|
229
|
-
"""BubbleStyle.
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
https://developers.line.me/en/docs/messaging-api/reference/#objects-for-the-block-style
|
234
|
-
|
235
|
-
"""
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
def __init__(self, header=None, hero=None, body=None, footer=None, **kwargs):
|
240
|
-
|
241
|
-
"""__init__ method.
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
:param header: Style of the header block
|
246
|
-
|
247
|
-
:type header: :py:class:`linebot.models.flex_message.BlockStyle`
|
248
|
-
|
249
|
-
:param hero: Style of the hero block
|
250
|
-
|
251
|
-
:type hero: :py:class:`linebot.models.flex_message.BlockStyle`
|
252
|
-
|
253
|
-
:param body: Style of the body block
|
254
|
-
|
255
|
-
:type body: :py:class:`linebot.models.flex_message.BlockStyle`
|
256
|
-
|
257
|
-
:param footer: Style of the footer block
|
258
|
-
|
259
|
-
:type footer: :py:class:`linebot.models.flex_message.BlockStyle`
|
260
|
-
|
261
|
-
:param kwargs:
|
262
|
-
|
263
|
-
"""
|
264
|
-
|
265
|
-
super(BubbleStyle, self).__init__(**kwargs)
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
self.header = self.get_or_new_from_json_dict(header, BlockStyle)
|
270
|
-
|
271
|
-
self.hero = self.get_or_new_from_json_dict(hero, BlockStyle)
|
272
|
-
|
273
|
-
self.body = self.get_or_new_from_json_dict(body, BlockStyle)
|
274
|
-
|
275
|
-
self.footer = self.get_or_new_from_json_dict(footer, BlockStyle)
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
class BlockStyle(with_metaclass(ABCMeta, Base)):
|
282
|
-
|
283
|
-
"""BlockStyle.
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
https://developers.line.me/en/docs/messaging-api/reference/#objects-for-the-block-style
|
288
|
-
|
289
|
-
"""
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
def __init__(self, background_color=None, separator=None, separator_color=None, **kwargs):
|
294
|
-
|
295
|
-
"""__init__ method.
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
:param str background_color: Background color of the block. Use a hexadecimal color code
|
300
|
-
|
301
|
-
:param bool separator: True to place a separator above the block
|
302
|
-
|
303
|
-
True will be ignored for the first block in a container
|
304
|
-
|
305
|
-
because you cannot place a separator above the first block.
|
306
|
-
|
307
|
-
The default value is False
|
308
|
-
|
309
|
-
:param str separator_color: Color of the separator. Use a hexadecimal color code
|
310
|
-
|
311
|
-
:param kwargs:
|
312
|
-
|
313
|
-
"""
|
314
|
-
|
315
|
-
super(BlockStyle, self).__init__(**kwargs)
|
316
|
-
|
317
|
-
self.background_color = background_color
|
318
|
-
|
319
|
-
self.separator = separator
|
320
|
-
|
321
|
-
self.separator_color = separator_color
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
class CarouselContainer(FlexContainer):
|
328
|
-
|
329
|
-
"""CarouselContainer.
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
https://developers.line.me/en/docs/messaging-api/reference/#carousel-container
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
This is a container that contains multiple bubble containers, or message bubbles.
|
338
|
-
|
339
|
-
The bubbles will be shown in order by scrolling horizontally.
|
340
|
-
|
341
|
-
"""
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
def __init__(self, contents=None, **kwargs):
|
346
|
-
|
347
|
-
"""__init__ method.
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
:param contents: Array of bubble containers
|
352
|
-
|
353
|
-
:type contents: list[T <= :py:class:`linebot.models.flex_message.BubbleContainer`]
|
354
|
-
|
355
|
-
:param kwargs:
|
356
|
-
|
357
|
-
"""
|
358
|
-
|
359
|
-
super(CarouselContainer, self).__init__(**kwargs)
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
self.type = 'carousel'
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
new_contents = []
|
368
|
-
|
369
|
-
|
425
|
+
python
|
370
|
-
|
371
|
-
for it in contents:
|
372
|
-
|
373
|
-
new_contents.append(self.get_or_new_from_json_dict(
|
374
|
-
|
375
|
-
it, BubbleContainer
|
376
|
-
|
377
|
-
))
|
378
|
-
|
379
|
-
self.contents = new_contents
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
class FlexComponent(with_metaclass(ABCMeta, Base)):
|
386
|
-
|
387
|
-
"""FlexComponent.
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
https://developers.line.me/en/docs/messaging-api/reference/#component
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
Components are objects that compose a Flex Message container.
|
396
|
-
|
397
|
-
"""
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
def __init__(self, **kwargs):
|
402
|
-
|
403
|
-
"""__init__ method.
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
:param kwargs:
|
408
|
-
|
409
|
-
"""
|
410
|
-
|
411
|
-
super(FlexComponent, self).__init__(**kwargs)
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
self.type = None
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
…………
|
422
|
-
|
423
|
-
……
|
424
|
-
|
425
|
-
…
|
426
426
|
|
427
427
|
|
428
428
|
|