Created
October 25, 2019 17:42
-
-
Save agoodkind/7bb460a2f947f354e032985fd95fec8c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask | |
from slackeventsapi import SlackEventAdapter | |
from slack import WebClient | |
app = Flask(__name__) | |
SLACK_SIGNING_SECRET = None | |
slack_events_adapter = SlackEventAdapter(SLACK_SIGNING_SECRET, "/slack/events", app) | |
slack_client = WebClient(SLACK_BOT_TOKEN) | |
@slack_events_adapter.on("app_mention") | |
def handle_mention(event_data): | |
message = event_data["event"] | |
if message.get("subtype") is None: | |
channel = message["channel"] | |
text = "Hello <@%s>: lets get this bread" % message["user"] | |
data = dict( | |
channel=channel, | |
text=text | |
) | |
slack_client.api_call("chat.postMessage", data=data) | |
@app.route("/") | |
def hello(): | |
return "Hello World!\n" | |
if __name__ == '__main__': | |
app.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment