File tree Expand file tree Collapse file tree 4 files changed +39
-0
lines changed
Expand file tree Collapse file tree 4 files changed +39
-0
lines changed Original file line number Diff line number Diff line change 1+ web : python app.py
Original file line number Diff line number Diff line change 1+ #
2+ 文章名稱:Python Line Bot 如何一次傳給多人訊息?手把手教學 Part 6
3+
4+ 文章連結:https://shareboxnow.com/line-bot-python-part-6/
5+
6+ 程式碼位置:https://github.com/MarkwwLiu/PythonBasicTeaching/tree/master/LineBot/Chapter_5
Original file line number Diff line number Diff line change 1+ from flask import Flask , request , abort
2+ import json
3+ from linebot import (
4+ LineBotApi , WebhookHandler
5+ )
6+ from linebot .exceptions import (
7+ InvalidSignatureError
8+ )
9+ from linebot .models import *
10+
11+ app = Flask (__name__ )
12+
13+ # Channel Access Token
14+ line_bot_api = LineBotApi ({YOU_Channel_Access Token })
15+ # Channel Secret
16+ handler = WebhookHandler ({YOU_Channel_Secret })
17+
18+ user_id = {YOU_USER_ID }
19+
20+
21+ @app .route ("/broadcast_function/<string:broadcast_text_str>" )
22+ def broadcast_message (broadcast_text_str ):
23+ line_bot_api .broadcast (TextSendMessage (text = broadcast_text_str ))
24+ return 'OK'
25+
26+ import os
27+
28+ if __name__ == "__main__" :
29+ port = int (os .environ .get ('PORT' , 5000 ))
30+ app .run (host = '0.0.0.0' , port = port , debug = True )
Original file line number Diff line number Diff line change 1+ line-bot-sdk
2+ flask
You can’t perform that action at this time.
0 commit comments