var q = require("q");

/**
 * Auth (From cloudbees account):
 *     key_id
 *     secretKey
 */

module.exports = function (nigel, config, register) {

    function  getRandomInt (min, max) {
        return Math.floor(Math.random() * (max - min + 1)) - min;
    }

    register("*", [], "What's for lunch?!!", function (message, outputStream) {
        if (!message.match(/(options|add)/ig)) {
            outputStream.end(config.lunches[getRandomInt(0, config.lunches.length - 1)]);
        }
    });

    register("options", [], "List lunch options", function (message, outputStream) {
        outputStream.end(config.lunches.join(', '));
    });

    register("add", [], "Add a lunch option", function (message, outputStream) {
        config.lunches.push(message);
        outputStream.end("Added " + message);
    });
};
@@ -378,16 +378,23 @@
 ions%7Cadd
+%7Cremove
 )/ig)) %7B
@@ -822,11 +822,283 @@
 %0A    %7D);
+%0A%0A    register(%22remove%22, %5B%5D, %22Remove a lunch option%22, function (message, outputStream) %7B%0A        var idx = config.lunches.indexOf(message);%0A        if (idx %3E= 0) %7B%0A            config.lunches.splice(idx, 1);%0A        %7D%0A        outputStream.end(%22Removed %22 + message);%0A    %7D);
 %0A%7D;

remove lunch option