Skip to content

Commit

Permalink
Print user input back to slack on an error
Browse files Browse the repository at this point in the history
This helps a user start again from an error because they can copy and
paste from their initial input.
  • Loading branch information
jonathansick committed Jan 22, 2024
1 parent 7358bc4 commit edf1637
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/templatebotaide/events/handlers/technoteprerender.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ async def handle_technote_prerender(
logger=logger,
app=app,
)
await print_input(event, logger, app)
raise
# Fill in fields
render_ready_message["variables"][
Expand Down Expand Up @@ -168,6 +169,7 @@ async def handle_technote_prerender(
logger=logger,
app=app,
)
await print_input(event, logger, app)
raise

logger.info("Created repo", repo_info=repo_info)
Expand Down Expand Up @@ -205,6 +207,7 @@ async def handle_technote_prerender(
logger=logger,
app=app,
)
await print_input(event, logger, app)

# Add information to the render_ready message payload

Expand Down Expand Up @@ -259,3 +262,22 @@ def propose_number(series_numbers: List[int]) -> int:
return serial_number + 1

raise RuntimeError("propose_number should not be in this state.")


async def print_input(
event: Dict[str, Any], logger: BoundLogger, app: Application
) -> None:
"""Print the user input to Slack."""
message = (
"Here's what you sent me:\n\n"
"```\n"
f"{event['variables']}\n"
"```\n\n"
)
await post_message(
text=message,
channel=event["slack_channel"],
thread_ts=event["slack_thread_ts"],
logger=logger,
app=app,
)

0 comments on commit edf1637

Please sign in to comment.