import requests
import json
import os
+from types import SimpleNamespace
import turbot.actions
import turbot.commands
slack_bot_token = response['Parameter']['Value']
slack_client = WebClient(slack_bot_token)
+db = boto3.resource('dynamodb')
+
+turb = SimpleNamespace()
+turb.slack_client = slack_client
+turb.db = db
+
def error(message):
"""Generate an error response for a Slack request
type = body['event']['type']
if type in turbot.events.events:
- return turbot.events.events[type](slack_client, body)
+ return turbot.events.events[type](turb, body)
return error("Unknown event type: {}".format(type))
def turbot_interactive_or_slash_command(event, context):
args = body['text'][0]
if command in turbot.commands.commands:
- return turbot.commands.commands[command](slack_client, body, args)
+ return turbot.commands.commands[command](turb, body, args)
return error("Command {} not implemented".format(command))