Bottr-js / Bottr

🤖 The world's simplest framework for creating Bots
http://bottr.co
MIT License
938 stars 86 forks source link

Utility for creating canned responses #58

Closed tanhauhau closed 7 years ago

tanhauhau commented 7 years ago

Example usage of code would be:

const greetings = require('./lib/utility/response/greetings');
bot.on('message_received', function(message, session) {
  session.send(greetings.get());
});

Or create your own canned response

ackowledge.js

const CannedResponse = require('./lib/utility/response/canned-response');
class Ackowledge extends CannedResponse {
    constructor() {
        super('Sure thing.', 'I\'ll do it for you', 'Roger that');
    }
}

mybot.js

const ackowledge = require('./ackowledge');
bot.hear('cook', function(message, session) {
  session.send(ackowledge.get()); // Roger that
});
coveralls commented 7 years ago

Coverage Status

Coverage increased (+0.7%) to 87.556% when pulling 9db02aa9206303bbb78ef731687f641ac1a4eff1 on tanhauhau:canned-response into 4787b918b318b9a56c27ebb53b971fb1a0e08681 on Bottr-js:master.

jcampbell05 commented 7 years ago

This is a cool idea! I'm wondering If we could build it out into our own i83n module for Bottr ?

I could imagine allowing people to provide multiple translations in the yaml file and the framework switching between them.

jcampbell05 commented 7 years ago

Merged this in :) I'll do some more refining in another PR as I think there is still a bit more we could do with this :)