Skip to content

Instantly share code, notes, and snippets.

@sizovs
Created July 2, 2017 18:21
Show Gist options
  • Save sizovs/0f2ea5b0ed0ca49026c0175b5d4ba2fb to your computer and use it in GitHub Desktop.
Save sizovs/0f2ea5b0ed0ca49026c0175b5d4ba2fb to your computer and use it in GitHub Desktop.
const request = require("request");
module.exports = controller => {
controller.on('slash_command', (bot, message) => {
if (message.command != "/pic") {
return;
}
request.get("http://random.cat/meow", (error, response, body) => {
const url = JSON.parse(body).file;
bot.reply(message, {
attachments: [
{
title: "Fabulous cat",
image_url: url
},
{
title: "Would you recommend this cat to your customers?",
callback_id: "cat_recommendation",
actions: [
{
name: "recommend",
text: "Definitely",
type: "button",
value: "yes"
},
{
name: "recommend",
text: "Hell no!",
type: "button",
value: "no"
}
]
}
]
});
});
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment