From: Carl Worth Date: Tue, 13 Oct 2020 23:27:59 +0000 (-0700) Subject: Move app_home_opened function down into turbot/events.py X-Git-Url: https://git.cworth.org/git?p=turbot;a=commitdiff_plain;h=930800b1d8b6da514bcaded09c27036fef73623e Move app_home_opened function down into turbot/events.py More movement out of turbot_lambda.py to keep the code neater. --- diff --git a/turbot/events.py b/turbot/events.py new file mode 100644 index 0000000..25fdffb --- /dev/null +++ b/turbot/events.py @@ -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" diff --git a/turbot_lambda/turbot_lambda.py b/turbot_lambda/turbot_lambda.py index ece58d6..d3db66f 100644 --- a/turbot_lambda/turbot_lambda.py +++ b/turbot_lambda/turbot_lambda.py @@ -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.