@@ -241,61 +241,62 @@ https://developers.line.me/en/docs/messaging-api/reference/#leave-room
241
241
242
242
line_bot_api.leave_room(room_id)
243
243
244
- create\_ rich\_ menu(self, data, timeout=None)
245
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
246
- Create a rich menu object through a group of given data and return rich menu id.
247
- The data is an rich menu object to create.
244
+ get\_ rich\_ menu(self, rich\_ menu\_ id, timeout=None)
245
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
246
+
247
+ Gets a rich menu via a rich menu ID.
248
+
249
+ https://developers.line.me/en/docs/messaging-api/reference/#get-rich-menu
250
+
251
+ .. code :: python
252
+
253
+ rich_menu = line_bot_api.get_rich_menu(rich_menu_id)
254
+ print (rich_menu.rich_menu_id)
255
+
256
+ create\_ rich\_ menu(self, rich _\m enu, timeout=None)
257
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
258
+
259
+ Creates a rich menu.
260
+ You must upload a rich menu image and link the rich menu to a user for the rich menu to be displayed. You can create up to 10 rich menus for one bot.
248
261
249
262
https://developers.line.me/en/docs/messaging-api/reference/#create-rich-menu
250
263
251
264
.. code :: python
252
-
265
+
253
266
rich_menu_to_create = RichMenu(
254
- size = RichMenuBound(
255
- width = 2500 ,
256
- height = 1686
257
- ),
258
- selected = False ,
259
- name = " nice richmenu" ,
260
- chatBarText = " touch me" ,
261
- areas = [
262
- RichMenuArea(
263
- RichMenuBound(
264
- x = 0 ,
265
- y = 0 ,
266
- width = 2500 ,
267
- height = 1686
268
- ),
269
- URITemplateAction(
270
- uri = ' line://nv/location'
271
- )
272
- )
273
- ]
274
- )
275
- rich_menu_id = line_bot_api.create_rich_menu(data = rich_menu_to_create)
267
+ size = RichMenuSize(width = 2500 , height = 843 ),
268
+ selected = False ,
269
+ name = " Nice richmenu" ,
270
+ chat_bar_text = " Tap here" ,
271
+ areas = [RichMenuArea(
272
+ bounds = RichMenuBounds(x = 0 , y = 0 , width = 2500 , height = 843 ),
273
+ action = URIAction(label = ' Go to line.me' , uri = ' https://line.me' ))]
274
+ )
275
+ rich_menu_id = line_bot_api.create_rich_menu(rich_menu = rich_menu_to_create)
276
276
print (rich_menu_id)
277
277
278
278
delete\_ rich\_ menu(self, rich\_ menu\_ id, timeout=None)
279
279
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
280
280
281
- Delete rich menu object through a given rich_menu_id .
281
+ Deletes a rich menu .
282
282
283
283
https://developers.line.me/en/docs/messaging-api/reference/#delete-rich-menu
284
284
285
285
.. code :: python
286
286
287
287
line_bot_api.delete_rich_menu(rich_menu_id)
288
288
289
- set \_ rich\_ menu\_ image (self, rich \_ menu \ _ id, content \_ type, content , timeout=None)
290
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
289
+ get \_ rich\_ menu\_ id \_ of \_ user (self, user \ _ id, timeout=None)
290
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
291
291
292
- Uploads and attaches an image to a rich menu through id and image path .
292
+ Gets the ID of the rich menu linked to a user .
293
293
294
- https://developers.line.me/en/docs/messaging-api/reference/#upload -rich-menu-image
294
+ https://developers.line.me/en/docs/messaging-api/reference/#get -rich-menu-id-of-user
295
295
296
296
.. code :: python
297
297
298
- line_bot_api.set_rich_menu_image(rich_menu_id, content_type, content)
298
+ rich_menu_id = ine_bot_api.get_rich_menu_id_of_user(user_id)
299
+ print (rich_menu_id)
299
300
300
301
link\_ rich\_ menu\_ to\_ user(self, user\_ id, rich\_ menu\_ id, timeout=None)
301
302
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -308,67 +309,55 @@ https://developers.line.me/en/docs/messaging-api/reference/#link-rich-menu-to-us
308
309
309
310
line_bot_api.link_rich_menu_to_user(user_id, rich_menu_id)
310
311
311
- get\_ rich\_ menu\_ list(self, timeout=None)
312
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
313
-
314
- Gets a list of all uploaded rich menus.
315
-
316
- https://developers.line.me/en/docs/messaging-api/reference/#get-rich-menu-list
317
-
318
- .. code :: python
319
-
320
- lst_rich_menu_obj = line_bot_api.get_rich_menu_list()
321
- for rich_menu_obj in lst_rich_menu_obj:
322
- print (rich_menu_obj.rich_menu_id)
323
-
324
- get\_ rich\_ menu(self, rich\_ menu\_ id, timeout=None)
325
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
312
+ unlink\_ rich\_ menu\_ from\_ user(self, user\_ id, timeout=None)
313
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
326
314
327
- Get rich menu object through a given Rich menu ID .
315
+ Unlinks a rich menu from a user .
328
316
329
- https://developers.line.me/en/docs/messaging-api/reference/#get -rich-menu
317
+ https://developers.line.me/en/docs/messaging-api/reference/#unlink -rich-menu-from-user
330
318
331
319
.. code :: python
332
320
333
- rich_menu_object = line_bot_api.get_rich_menu(rich_menu_id)
334
- print (rich_menu_obj.rich_menu_id)
321
+ line_bot_api.unlink_rich_menu_from_user(user_id)
335
322
336
- get\_ rich\_ menu\_ id \_ of \_ user (self, user \_ id, timeout=None)
337
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
323
+ get\_ rich\_ menu\_ image (self, rich \_ menu \_ id, timeout=None)
324
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
338
325
339
- Gets the ID of the rich menu linked to a user .
326
+ Downloads an image associated with a rich menu.
340
327
341
- https://developers.line.me/en/docs/messaging-api/reference/#get -rich-menu-id-of-user
328
+ https://developers.line.me/en/docs/messaging-api/reference/#download -rich-menu-image
342
329
343
330
.. code :: python
344
331
345
- rich_menu_object = ine_bot_api.get_rich_menu_id_of_user(user_id)
346
- print (rich_menu_object.rich_menu_id)
332
+ content = line_bot_api.get_rich_menu_image(rich_menu_id)
333
+ with open (file_path, ' wb' ) as fd:
334
+ for chunk in content.iter_content():
335
+ fd.write(chunk)
347
336
348
- unlink \_ rich\_ menu\_ from \_ user (self, user \ _ id, timeout=None)
349
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
337
+ set \_ rich\_ menu\_ image (self, rich \_ menu \ _ id, content \_ type, content , timeout=None)
338
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
350
339
351
- Unlinks a rich menu from a user .
340
+ Uploads and attaches an image to a rich menu .
352
341
353
- https://developers.line.me/en/docs/messaging-api/reference/#unlink -rich-menu-from-user
342
+ https://developers.line.me/en/docs/messaging-api/reference/#upload -rich-menu-image
354
343
355
344
.. code :: python
356
345
357
- line_bot_api.unlink_rich_menu_from_user(user_id)
346
+ with open (file_path, ' rb' ) as f:
347
+ line_bot_api.set_rich_menu_image(rich_menu_id, content_type, f)
358
348
359
- get_rich_menu_image(self, rich \ _ menu\_ id , timeout=None)
360
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
349
+ get \_ rich \ _ menu\_ list(self , timeout=None)
350
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
361
351
362
- Downloads an image associated with a rich menu .
352
+ Gets a list of all uploaded rich menus .
363
353
364
- https://developers.line.me/en/docs/messaging-api/reference/#download -rich-menu-image
354
+ https://developers.line.me/en/docs/messaging-api/reference/#get -rich-menu-list
365
355
366
356
.. code :: python
367
357
368
- message_content = line_bot_api.get_rich_menu_image(rich_menu_id)
369
- with open (file_path, ' wb' ) as fd:
370
- for chunk in message_content.iter_content():
371
- fd.write(chunk)
358
+ rich_menu_list = line_bot_api.get_rich_menu_list()
359
+ for rich_menu in rich_menu_list:
360
+ print (rich_menu.rich_menu_id)
372
361
373
362
※ Error handling
374
363
^^^^^^^^^^^^^^^^
@@ -489,16 +478,16 @@ TemplateSendMessage - ButtonsTemplate
489
478
title = ' Menu' ,
490
479
text = ' Please select' ,
491
480
actions = [
492
- PostbackTemplateAction (
481
+ PostbackAction (
493
482
label = ' postback' ,
494
483
text = ' postback text' ,
495
484
data = ' action=buy&itemid=1'
496
485
),
497
- MessageTemplateAction (
486
+ MessageAction (
498
487
label = ' message' ,
499
488
text = ' message text'
500
489
),
501
- URITemplateAction (
490
+ URIAction (
502
491
label = ' uri' ,
503
492
uri = ' http://example.com/'
504
493
)
@@ -516,12 +505,12 @@ TemplateSendMessage - ConfirmTemplate
516
505
template = ConfirmTemplate(
517
506
text = ' Are you sure?' ,
518
507
actions = [
519
- PostbackTemplateAction (
508
+ PostbackAction (
520
509
label = ' postback' ,
521
510
text = ' postback text' ,
522
511
data = ' action=buy&itemid=1'
523
512
),
524
- MessageTemplateAction (
513
+ MessageAction (
525
514
label = ' message' ,
526
515
text = ' message text'
527
516
)
@@ -543,16 +532,16 @@ TemplateSendMessage - CarouselTemplate
543
532
title = ' this is menu1' ,
544
533
text = ' description1' ,
545
534
actions = [
546
- PostbackTemplateAction (
535
+ PostbackAction (
547
536
label = ' postback1' ,
548
537
text = ' postback text1' ,
549
538
data = ' action=buy&itemid=1'
550
539
),
551
- MessageTemplateAction (
540
+ MessageAction (
552
541
label = ' message1' ,
553
542
text = ' message text1'
554
543
),
555
- URITemplateAction (
544
+ URIAction (
556
545
label = ' uri1' ,
557
546
uri = ' http://example.com/1'
558
547
)
@@ -563,16 +552,16 @@ TemplateSendMessage - CarouselTemplate
563
552
title = ' this is menu2' ,
564
553
text = ' description2' ,
565
554
actions = [
566
- PostbackTemplateAction (
555
+ PostbackAction (
567
556
label = ' postback2' ,
568
557
text = ' postback text2' ,
569
558
data = ' action=buy&itemid=2'
570
559
),
571
- MessageTemplateAction (
560
+ MessageAction (
572
561
label = ' message2' ,
573
562
text = ' message text2'
574
563
),
575
- URITemplateAction (
564
+ URIAction (
576
565
label = ' uri2' ,
577
566
uri = ' http://example.com/2'
578
567
)
@@ -593,15 +582,15 @@ TemplateSendMessage - ImageCarouselTemplate
593
582
columns = [
594
583
ImageCarouselColumn(
595
584
image_url = ' https://example.com/item1.jpg' ,
596
- action = PostbackTemplateAction (
585
+ action = PostbackAction (
597
586
label = ' postback1' ,
598
587
text = ' postback text1' ,
599
588
data = ' action=buy&itemid=1'
600
589
)
601
590
),
602
591
ImageCarouselColumn(
603
592
image_url = ' https://example.com/item2.jpg' ,
604
- action = PostbackTemplateAction (
593
+ action = PostbackAction (
605
594
label = ' postback2' ,
606
595
text = ' postback text2' ,
607
596
data = ' action=buy&itemid=2'
0 commit comments