From: Carl Worth Date: Tue, 13 Oct 2020 23:46:39 +0000 (-0700) Subject: Give turbot/events.py the same dispatch-table treatment X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=3fee4ba343009c49038bf7148f442e02ecaea87a;hp=9d0b128dcb0af08c9586d526e8ed1c01a57e6973;p=turbot Give turbot/events.py the same dispatch-table treatment Just like the previous two commits. --- 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):