]> git.cworth.org Git - turbot/commitdiff
Move app_home_opened function down into turbot/events.py
authorCarl Worth <cworth@cworth.org>
Tue, 13 Oct 2020 23:27:59 +0000 (16:27 -0700)
committerCarl Worth <cworth@cworth.org>
Tue, 13 Oct 2020 23:27:59 +0000 (16:27 -0700)
More movement out of turbot_lambda.py to keep the code neater.

turbot/events.py [new file with mode: 0644]
turbot_lambda/turbot_lambda.py

diff --git a/turbot/events.py b/turbot/events.py
new file mode 100644 (file)
index 0000000..25fdffb
--- /dev/null
@@ -0,0 +1,7 @@
+import turbot.views
+
+def app_home_opened(slack_client, body):
+    user_id = body['event']['user']
+    view = turbot.views.home(user_id, body)
+    slack_client.views_publish(user_id=user_id, view=view)
+    return "OK"
index ece58d62f577ee3553926115e79f146adcd3dbd6..d3db66f8f8b587f7cee6fba99143dcd7febb6c83 100644 (file)
@@ -7,6 +7,7 @@ import os
 from turbot.rot import rot
 import turbot.views
 import turbot.actions
+import turbot.events
 
 ssm = boto3.client('ssm')
 
@@ -97,15 +98,9 @@ def event_callback_handler(body):
     type = body['event']['type']
 
     if type == 'app_home_opened':
-        return app_home_opened_handler(body)
+        return turbot.events.app_home_opened(slack_client, body)
     return error("Unknown event type: {}".format(type))
 
-def app_home_opened_handler(body):
-    user_id = body['event']['user']
-    view = turbot.views.home(user_id, body)
-    slack_client.views_publish(user_id=user_id, view=view)
-    return "OK"
-
 def turbot_interactive_or_slash_command(event, context):
     """Handler for Slack interactive things (buttons, shortcuts, etc.)
     as well as slash commands.