Skip to content

ajberasategui/donramos

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

How to add your Hear.

Create under src/hears a js file. You can use src/hears/test.js as example.

Your module MUST export 2 properties and 1 function.
It MAY also export the following properties:
  • init: (optional) This function will be called with controlle (botkit bot controller for donramos) and db (jfs module storage object). This function is called before registering the hear, so you may you use to interact with the controller and the data storage to retrieve data needed for your hear callback.
  • usage: Explains how to use your hear.
  • whatItDoes: Explains what your hear does.
Example
let config = require('../config');

module.exports = {
    init: init,
    msg: '(test)*'+'(.*)',
    env: config.HEAR_ENVS.MENTION_AND_DIRECT,
    usage: '@donramos quien va a [tu accion]',
    whatItDoes: 'Elige un presente en RG aleatoriamiente para hacer lo que indiques',
    responseCallback: responseCallback
};

let enteradoCount = 0;
let usersInRG = [];

function init(controller, db) {
    db.get('usersInRG')
        .then(function(users){
            usersInRG = users;
        });
}

function responseCallback(bot, message) {
    if (enteradoCount > 2) {
        bot.reply(message, "Hay, creo que le habla a Ud.!");
        enteradoCount = 0;
    } else {
        bot.reply(message, "Enterado!");
        enteradoCount++;
    }
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published