Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: add sendError to Responder #194

Merged
merged 2 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .devcontainer/.profile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# trust the repo
# fixes:
# - fatal: detected dubious ownership in repository at '/workspaces/bot-zero'.
git config --global --add safe.directory "$PWD"
9 changes: 8 additions & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
FROM mcr.microsoft.com/devcontainers/typescript-node:1-20-bullseye

# Install the npm packages globally
RUN npm install -g npm@10.7.0 \
RUN npm install -g npm@10.9.2 \
&& npm install -g npm-check-updates

COPY ./startup.sh /
RUN chmod +x /startup.sh

# Append the profile to the current .bashrc and .zshrc files
# this makes sure we keep the current behavior like colors and aliases
COPY ./.profile /tmp/.profile
RUN cat /tmp/.profile >> /home/node/.bashrc && \
cat /tmp/.profile >> /home/node/.zshrc && \
rm /tmp/.profile
5 changes: 0 additions & 5 deletions .devcontainer/startup.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
#!/bin/sh

# trust the repo
# fixes:
# - fatal: detected dubious ownership in repository at '/workspaces/bot-zero'.
git config --global --add safe.directory "$PWD"

# install NPM packages
echo ""
echo "Installing packages..."
Expand Down
2 changes: 1 addition & 1 deletion src/Bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class Bot {
*/
sendError(message, context) {
context.robot.logger.error(message);
context.send(message);
this.adapter.responder.sendError(context, message);
}

/**
Expand Down
9 changes: 9 additions & 0 deletions src/adapters/Responder.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ class Responder {
send(res, title, image, link) {
res.send(`${title}: ${image} - ${link}`);
}

/**
* Sends the error message to Hubot.
* @param {Hubot.Response} res the context.
* @param {string} message the error message.
*/
sendError(res, message) {
res.send(message);
}
}

exports.Responder = Responder;
Loading