easy-slack-bot
v0.2.0
Published
Easy Slack bot package.
Downloads
9
Maintainers
Readme
easy-slack-bot
Node.js based, modular Slack bot framework.
INSTALLATION
$ npm install easy-slack-bot --save
EXAMPLE
See sample files in "example" directory.
USAGE
Simple index.js:
var SlackBot = require("easy-slack-bot"),
BotItems = __dirname + "/items",
BotOptions = {
Slack: {
SLACK_TOKEN: "slack-bot-token"
}
};
new SlackBot(BotItems, BotOptions);
Simple items/hello.js item:
module.exports = function( bot )
{
// https://api.slack.com/methods/chat.postMessage
var params = {
icon_emoji: ':robot_face:'
};
return
{
// Get message
// https://rawgit.com/sipimokus/easy-slack-bot/master/docs/interfaces/islackbotsmessage.html
// https://rawgit.com/sipimokus/easy-slack-bot/master/docs/interfaces/iitemsonmessagecallback.html
message: function( message, callBack )
{
// Detecting word in message
if ( message.natural.indexOf("hello") > -1 )
{
// Answer message
callBack("Hello world!", params);
return true;
}
return false;
}
};
};