現在,slackのinteractive Componentsの勉強をしています.
python
1import json 2 3from slackclient import SlackClient 4 5# Your app's Slack bot user token 6SLACK_BOT_TOKEN = os.environ["SLACK_BOT_TOKEN"] 7SLACK_VERIFICATION_TOKEN = os.environ["SLACK_VERIFICATION_TOKEN"] 8 9# Slack client for Web API requests 10slack_client = SlackClient(SLACK_BOT_TOKEN) 11 12# Flask webserver for incoming traffic from Slack 13app = Flask(__name__) 14 15# Helper for verifying that requests came from Slack 16def verify_slack_token(request_token): 17 if SLACK_VERIFICATION_TOKEN != request_token: 18 print("Error: invalid verification token!") 19 print("Received {} but was expecting {}".format(request_token, SLACK_VERIFICATION_TOKEN)) 20 return make_response("Request contains invalid Slack verification token", 403) 21 22# The endpoint Slack will load your menu options from 23@app.route("/", methods=["POST"]) 24def message_options(): 25 # Parse the request payload 26 form_json = json.loads(request.form["payload"]) 27 28 # Verify that the request came from Slack 29 verify_slack_token(form_json["token"]) 30 31 # Dictionary of menu options which will be sent as JSON 32 menu_options = { 33 "options": [ 34 { 35 "text": "Cappuccino", 36 "value": "cappuccino" 37 }, 38 { 39 "text": "Latte", 40 "value": "latte" 41 } 42 ] 43 } 44 45 # Load options dict as JSON and respond to Slack 46 return Response(json.dumps(menu_options), mimetype='application/json') 47# Start the Flask server 48if __name__ == "__main__": 49 app.run()
requirements.txtは以下のようになります
aiohttp==3.6.2 async-timeout==3.0.1 attrs==19.3.0 certifi==2019.11.28 chardet==3.0.4 Click==7.0 Flask==1.1.1 gunicorn==20.0.4 idna==2.8 itsdangerous==1.1.0 Jinja2==2.10.3 MarkupSafe==1.1.1 multidict==4.6.1 pipenv==2018.11.26 slackclient==2.5.0 SQLAlchemy==1.3.11 virtualenv==16.7.8 virtualenv-clone==0.5.3 Werkzeug==0.16.0 yarl==1.4.2
なぜ,デプロイ後ModuleNotFoundError:No module named 'slackclient'が発生するのでしょうか?
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/12/20 07:21