]> git.cworth.org Git - turbot/commitdiff
Give turbot/events.py the same dispatch-table treatment
authorCarl Worth <cworth@cworth.org>
Tue, 13 Oct 2020 23:46:39 +0000 (16:46 -0700)
committerCarl Worth <cworth@cworth.org>
Tue, 13 Oct 2020 23:52:53 +0000 (16:52 -0700)
Just like the previous two commits.

turbot/events.py
turbot_lambda/turbot_lambda.py

index 25fdffbb5d7612a081a4c312e77bb86296867568..dcb2d0d1532de359affe053e385d98faf10db354 100644 (file)
@@ -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
+}
index 5420b33dc36726a7e63423f4bb08a678a5beea11..b6f4a36049360a4e154ac6bf1e6ca3217df8af69 100644 (file)
@@ -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):