--- /dev/null
+def home(user_id, body):
+ """Returns a view to be published as the turbot home tab for user_id
+
+ The body argument is a dictionary as provided by the Slack request.
+ The return value is a dictionary suitable to be published to the
+ Slack views_publish API."""
+
+ return {
+ "type": "home",
+ "blocks": [
+ {
+ "type": "section",
+ "text": {
+ "type": "mrkdwn",
+ "text": "A simple stack of blocks for the simple sample Block Kit Home tab."
+ }
+ },
+ {
+ "type": "actions",
+ "elements": [
+ {
+ "type": "button",
+ "text": {
+ "type": "plain_text",
+ "text": "Action A",
+ "emoji": True
+ }
+ },
+ {
+ "type": "button",
+ "text": {
+ "type": "plain_text",
+ "text": "Action B",
+ "emoji": True
+ }
+ }
+ ]
+ }
+ ]
+ }
from urllib.parse import parse_qs
from turbot.rot import rot
+from turbot import views
from slack import WebClient
import boto3
import requests
return error("Unknown event type: {}".format(type))
def app_home_opened_handler(body):
- slack_client.views_publish(user_id=body['event']['user'],
- view={
- "type": "home",
- "blocks": [
- {
- "type": "section",
- "text": {
- "type": "mrkdwn",
- "text": "A simple stack of blocks for the simple sample Block Kit Home tab."
- }
- },
- {
- "type": "actions",
- "elements": [
- {
- "type": "button",
- "text": {
- "type": "plain_text",
- "text": "Action A",
- "emoji": True
- }
- },
- {
- "type": "button",
- "text": {
- "type": "plain_text",
- "text": "Action B",
- "emoji": True
- }
- }
- ]
- }
- ]
- })
+ user_id = body['event']['user']
+ view = views.home(user_id, body)
+ slack_client.views_publish(user_id=user_id, view=view)
return "OK"
def turbot_interactive_or_slash_command(event, context):