mirror of
https://github.com/Sea-Haven-Industries/afterhours-shift-manager.git
synced 2026-09-30 07:53:11 +00:00
Slash command handlers (drop, pick, swap) were posting notifications to command["channel_id"] — wherever the command was run. If someone ran /oncall drop from a DM, the notification went there instead of the schedule channel. Pickup buttons didn't have this problem because body["channel"]["id"] is always the channel where the button lives. Added SHIFT_CHANNEL_PARAM to the SlackBotFunction env vars, read it on cold start, and route all slash command shift-change notifications to the configured schedule channel. Closes #21
This commit is contained in:
parent
1e90e0eaa2
commit
7b2275a430
3 changed files with 9 additions and 5 deletions
|
|
@ -78,7 +78,7 @@ def is_today(date_str: str) -> bool:
|
|||
return date_str == datetime.now(EASTERN).strftime("%Y-%m-%d")
|
||||
|
||||
|
||||
def create_app(bot_token: str, signing_secret: str) -> App:
|
||||
def create_app(bot_token: str, signing_secret: str, schedule_channel: str | None = None) -> App:
|
||||
app = App(
|
||||
token=bot_token,
|
||||
signing_secret=signing_secret,
|
||||
|
|
@ -110,11 +110,11 @@ def create_app(bot_token: str, signing_secret: str) -> App:
|
|||
elif text.startswith("register"):
|
||||
_handle_register(respond, schedule, user_id, text)
|
||||
elif text.startswith("pick"):
|
||||
_handle_pick(respond, schedule, user_id, text, channel_id, client)
|
||||
_handle_pick(respond, schedule, user_id, text, schedule_channel or channel_id, client)
|
||||
elif text.startswith("drop"):
|
||||
_handle_drop(respond, schedule, user_id, text, channel_id, client)
|
||||
_handle_drop(respond, schedule, user_id, text, schedule_channel or channel_id, client)
|
||||
elif text.startswith("swap"):
|
||||
_handle_swap(respond, schedule, user_id, text, channel_id, client)
|
||||
_handle_swap(respond, schedule, user_id, text, schedule_channel or channel_id, client)
|
||||
else:
|
||||
respond(text="Unknown command. Try `/oncall help`")
|
||||
|
||||
|
|
|
|||
|
|
@ -28,8 +28,11 @@ def _get_handler() -> SlackRequestHandler:
|
|||
signing_secret = ssm.get_parameter(
|
||||
Name=os.environ["SLACK_SIGNING_SECRET_PARAM"], WithDecryption=True
|
||||
)["Parameter"]["Value"]
|
||||
schedule_channel = ssm.get_parameter(
|
||||
Name=os.environ["SHIFT_CHANNEL_PARAM"], WithDecryption=True
|
||||
)["Parameter"]["Value"]
|
||||
|
||||
app = create_app(bot_token, signing_secret)
|
||||
app = create_app(bot_token, signing_secret, schedule_channel=schedule_channel)
|
||||
_slack_handler = SlackRequestHandler(app=app)
|
||||
return _slack_handler
|
||||
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ Resources:
|
|||
SHIFT_TABLE: !Ref ShiftTable
|
||||
SLACK_BOT_TOKEN_PARAM: /afterhours-shift-manager/slack-bot-token
|
||||
SLACK_SIGNING_SECRET_PARAM: /afterhours-shift-manager/slack-signing-secret
|
||||
SHIFT_CHANNEL_PARAM: /afterhours-shift-manager/channel-id
|
||||
SCHEDULER_FUNCTION_NAME: !Ref SchedulerFunctionName
|
||||
TZ: !Ref Timezone
|
||||
Policies:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue