From 3fee4ba343009c49038bf7148f442e02ecaea87a Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 13 Oct 2020 16:46:39 -0700 Subject: [PATCH] Give turbot/events.py the same dispatch-table treatment Just like the previous two commits. --- turbot/events.py | 4 ++++ turbot_lambda/turbot_lambda.py | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/turbot/events.py b/turbot/events.py index 25fdffb..dcb2d0d 100644 --- a/turbot/events.py +++ b/turbot/events.py @@ -5,3 +5,7 @@ def app_home_opened(slack_client, body): view = turbot.views.home(user_id, body) slack_client.views_publish(user_id=user_id, view=view) return "OK" + +events = { + "app_home_opened": app_home_opened +} diff --git a/turbot_lambda/turbot_lambda.py b/turbot_lambda/turbot_lambda.py index 5420b33..b6f4a36 100644 --- a/turbot_lambda/turbot_lambda.py +++ b/turbot_lambda/turbot_lambda.py @@ -98,8 +98,8 @@ def url_verification_handler(body): def event_callback_handler(body): type = body['event']['type'] - if type == 'app_home_opened': - return turbot.events.app_home_opened(slack_client, body) + if type in turbot.events.events: + return turbot.events.events[type](slack_client, body) return error("Unknown event type: {}".format(type)) def turbot_interactive_or_slash_command(event, context): -- 2.43.0