]> git.cworth.org Git - turbot/blobdiff - turbot_lambda/turbot_lambda.py
Add list of active hunts to the turbot Home tab
[turbot] / turbot_lambda / turbot_lambda.py
index b6f4a36049360a4e154ac6bf1e6ca3217df8af69..b34c6f7cd209100264b9429161b6461279007e28 100644 (file)
@@ -4,6 +4,7 @@ import boto3
 import requests
 import json
 import os
+from types import SimpleNamespace
 
 import turbot.actions
 import turbot.commands
@@ -23,6 +24,12 @@ response = ssm.get_parameter(Name='SLACK_BOT_TOKEN', WithDecryption=True)
 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
 
@@ -99,7 +106,7 @@ def event_callback_handler(body):
     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):
@@ -167,6 +174,6 @@ def turbot_slash_command(body):
     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))