Skip to content

Commit

Permalink
Orpheus can detect haiku
Browse files Browse the repository at this point in the history
  • Loading branch information
maxwofford committed Mar 2, 2022
1 parent 84c22e2 commit c2e6eba
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 0 deletions.
64 changes: 64 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"chrono-node": "^2.2.4",
"dotenv": "^10.0.0",
"form-data": "^3.0.0",
"haiku-detect": "^1.1.0",
"humanize-duration": "^3.20.1",
"isomorphic-unfetch": "^3.0.0",
"js-yaml": "^3.13.1",
Expand Down
4 changes: 4 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import interactionClubInit from "./interactions/clubInit";
import interactionReportForm from "./interactions/reportForm";
import interactionReportFormSubmit from "./interactions/reportFormSubmit";
import interactionEmail from "./interactions/email";
import interactionHaiku from "./interactions/haiku";

export const bugsnagClient = bugsnag(process.env.BUGSNAG_API_KEY);

Expand Down Expand Up @@ -181,6 +182,9 @@ controller.hears(
// catch-all for direct messages
controller.hears(".*", "direct_message,indirect_mention,direct_mention", interactionCatchall);

// catch-all for any message in slack
controller.hears(".*", "ambient", interactionHaiku);

// controller.hears(".*", "mention,direct_message,indirect_mention,direct_mention", interactionGamelab)

controller.on("view_submission", async (bot, message) => {
Expand Down
12 changes: 12 additions & 0 deletions src/interactions/haiku.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { transcript } from "../utils"
import { format } from "haiku-detect"

const interactionHaiku = (bot, message) => {
const { text, user } = message
const haikuLines = format(text)
if (haikuLines.length == 3) {
bot.replyInThread(message, transcript('haiku', { haikuLines, user }))
}
}

export default interactionHaiku
5 changes: 5 additions & 0 deletions src/utils/transcript.yml
Original file line number Diff line number Diff line change
Expand Up @@ -734,4 +734,9 @@ gamelab:
<https://hackclub.slack.com/archives/C0P5NE354/p1644606215597029|HELP!!!1!>
melabEmoji: gamelab
warningEmoji: warning
haiku: |
> ${this.haikuLines[0]}
> ${this.haikuLines[1]}
> ${this.haikuLines[2]}
_– a haiku by <@${this.user}>_
statusCheck: pong!

0 comments on commit c2e6eba

Please sign in to comment.