Skip to content

Instantly share code, notes, and snippets.

@morria
Created November 13, 2018 13:39
Show Gist options
  • Save morria/30f2f0413a9853c58499fd861d9ff758 to your computer and use it in GitHub Desktop.
Save morria/30f2f0413a9853c58499fd861d9ff758 to your computer and use it in GitHub Desktop.
module.exports = function(controller) {
controller.hears(['^go'], 'direct_message,direct_mention,ambient', function(bot, message) {
bot.createConversation(message, function(err, convo) {
if (!err) {
convo.say('I cant hear or see, but you said ' + message.event.text);
// console.log(message);
convo.activate();
}
});
});
controller.hears(['Look (.*)'], 'direct_message,direct_mention,ambient', function(bot, message) {
var LookObjType = message.match[1]; //match[1] is the (.*) group. match[0] is the entire group (Look (.*).
if (LookObjType === 'plant') {
return bot.reply(message, 'You look at your next project; The plant is relatively still for now. It is sitting in the environmental module where its root-pod is affixed to the Ipomoea quamoclit mobility tool. Above it is a a well-maintained Vibrio harveyi culture, glowing brightly down onto the appreciative leaves below. Time to get to work.');
}
else if(LookObjType === 'light') {
return bot.reply(message, 'You look at the light glowing above the plant. It is a small, translucent organic pod attached to a vine growing out of the ceiling. Inside is a bright mass of Vibrio harveyi, a bacteria that has been amplified through selective breeding to produce photosynthesis-capable lumens in laboratory conditions. The culture is fed from a small tube emerging from a vessel to its left, a fermented concoction of high-nutrient biomatter.');
}
else {
return bot.reply(message, 'You look around for something else, but all that is here is the plant you\'re working on and the light-pod above it.');
// console.log(message);
}
});
controller.hears('Begin the experiment', 'direct_message,direct_mention,ambient', function(bot, message) {
bot.startConversation(message, function(err, convo) {
convo.ask({
attachments:[
{
title: 'Do you want to begin the evolutionary behavioral induction process?',
callback_id: '123',
attachment_type: 'default',
actions: [
{
"name":"yes",
"text": "Yes",
"value": "yes",
"type": "button",
},
{
"name":"no",
"text": "No",
"value": "no",
"type": "button",
}
]
}
]
},[
{
pattern: "yes",
callback: function(reply, convo) {
convo.say('The root-pod and bacterial light source begin to rotate relative to each other at rapidly increasing speed. The system is ready for behavioral induction input.');
convo.next();
// do something awesome here.
}
},
{
pattern: "no",
callback: function(reply, convo) {
convo.say('The organisms are prepared for behavioral induction when you are ready to begin.');
convo.next();
}
},
{
default: true,
callback: function(reply, convo) {
// do nothing
}
}
]);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment