Code as follows:
var Flint = require('node-flint');
// define flint setup
var config = {
// url to access this app's webservice
baseUrl: 'http://sparkbot-lperera3.c9users.io',
// port that local server listens on
localPort: process.env.PORT,
// spark account email
sparkEmail: 'lperera@la-networks.com',
// spark api token
sparkToken: 'MDA2ZDk1YTQtOWUzNy00ODA3LTk3MDYtMWE2MjJhZDg5ZjQ3NDRlN2RhNzAtNmVh'
};
// init flint framework
var flint = new Flint(config);
// echo test
flint.hears('/echo', function(bot, trigger) {
bot.say(trigger.args.join(' '));
});
// add a person or people to room by email
flint.hears('/add', function(bot, trigger) {
var email = trigger.args;
if(email) bot.add(email);
});
// remove a person or people from room by email
flint.hears('/remove', function(bot, trigger) {
var email = trigger.args;
if(email) bot.remove(email);
});
// anytime someone says hello
flint.hears(/(^| )hello( |.|$)/i, function(bot, trigger) {
bot.say('Hello, %s!', trigger.person.displayName);
});
No comments:
Post a Comment