Your Name 3 năm trước cách đây
mục cha
commit
130a3bb5ca
1 tập tin đã thay đổi với 30 bổ sung1 xóa
  1. 30 1
      step_question/apis/newbot.py

+ 30 - 1
step_question/apis/newbot.py

@@ -17,7 +17,7 @@ from linebot.models import (
     UnfollowEvent, FollowEvent, JoinEvent, LeaveEvent, BeaconEvent,
     MemberJoinedEvent, MemberLeftEvent,
     FlexSendMessage, BubbleContainer, ImageComponent, BoxComponent,
-    TextComponent, IconComponent, ButtonComponent,
+    TextComponent, IconComponent, ButtonComponent, MessageTemplateAction,
     SeparatorComponent, QuickReply, QuickReplyButton,
     ImageSendMessage)
 
@@ -63,6 +63,35 @@ async def callback(request: fastapi.Request):
     return 'OK'
 
 
+@handler.add(FollowEvent)
+def handle_follow(event):
+    print("in Follow")
+    button_template_message =ButtonsTemplate(
+                                    thumbnail_image_url="http://www.choozmo.com/images/logo%20%281%29.webp",
+                                    title='Menu', 
+                                    text='歡迎follow',
+                                    image_size="cover",
+                                    actions=[
+                                        MessageTemplateAction(
+                                            label='功能1', text='function-1'
+                                        ),
+                                        MessageTemplateAction(
+                                            label='功能2', text='function-2'
+                                        ),
+                                        MessageTemplateAction(
+                                            label='功能3', text='function-3'
+                                        ),
+                                    ]
+                                )
+                                
+    line_bot_api.reply_message(
+        event.reply_token,
+        TemplateSendMessage(
+            alt_text="Follow Event",
+            template=button_template_message
+        )
+    )
+
 @handler.add(linebotModels.MessageEvent, message=linebotModels.TextMessage)
 def message_text(event):
     if event.message.text == 'push':