Skip to content

Commit

Permalink
Create Dad Joke.js (#335)
Browse files Browse the repository at this point in the history
Parser to get a joke from icanhazdadjoke.com
  • Loading branch information
eriemer1 authored Sep 30, 2024
1 parent 4fcd204 commit 82340d2
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Parsers/Dad Joke.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
activation_example:!dad
regex:!dad
flags:gmi
*/

var prompt = current.text.replace(/!dad/gmi, "").trim().substring(0, 1000);
var dadJoke = new sn_ws.RESTMessageV2();
dadJoke.setEndpoint('https://icanhazdadjoke.com/');
dadJoke.setHttpMethod("GET");
dadJoke.setRequestHeader("Accept","text/plain");
var chatResponse = dadJoke.execute();
var chatResponseBody = chatResponse.getBody();

new x_snc_slackerbot.Slacker().send_chat(current, chatResponseBody, false);

0 comments on commit 82340d2

Please sign in to comment.