- requirements.txt - Procfile - runtime.txt
httplib2 slacker Flask==0.12
web: python app.py
from flask import Flask from flask import request from flask import make_response app = Flask(__name__) # @app.route('/webhook') def hello_slack(): # request_json = request.get_json(silent=True, force=True) # dict , # request_json -> response_body_json ... response_body = json.dumps(response_body_json) # response = make_response(response_body) response.headers['Content-Type'] = 'application/json' # return response if __name__ == '__main__': port = int(os.getenv('PORT', 5000)) app.run(debug=False, port=port, host='0.0.0.0')
https://YOUR_APP_NAME.herokuapp.com/webhookand you can create your own slak application that will * do-something-useful * . It remains to validate it for the events API (that is, the most useful API - API notifying us of any events). Slack itself is just a special challenge-request from our endpoint, from which you need to get the code and put it in response. Now in the settings of the slak application in the Event Subscriptions section we select the events we need and that's all. Events will fall to the same address. As soon as you do everything you want with the input data, you need to support the authorization of other users. To do this, you will need another endpoint, for example / auth , to which the slak will send a request as soon as the new user wants to install his application. After receiving such a request, you need to remove the code from it and send it to the POST on slack.com/api/oauth.access together with the application credits, and respond to the request itself with any successful response or redirect to the page you want to show to the user after logging in .
language: python python: - "3.6" script: python3 -m unittest discover
In the script section, we tell Trevis what to do after the latest version of the source code has been downloaded. This command (which you should run locally more often) will find the unit tests in our project and run them out.
Source: https://habr.com/ru/post/334678/