Slacky - A minimalistic slackbot.
API
middleware
Middleware should have the function signature of next, event, data
.
Example (Tip: Don't want your middleware to run on all events?)
bot;
- middleware
- .use(fn) ⇒
this
- .run(done) ⇒
this
- .use(fn) ⇒
this
middleware.use(fn) ⇒ Add middleware to the bot.
Kind: static method of middleware
Returns: this
- Current bot
Param | Type | Description |
---|---|---|
fn | function |
Middleware function |
Example
bot;
this
middleware.run(done) ⇒ Execute middleware
Kind: static method of middleware
Returns: this
- Current bot
Param | Type | Description |
---|---|---|
... | Any |
Arguments to be passed to middleware |
done | function |
Function to be called after middleware has executed |
plugin
Plugins add many different pieces of functionality to a bot without having to manage everything in one repository.
Example
const plugin = { ... Add listeners or functionality ... ;};bot;
Example (You can also pass options to plugins by specifiying a `register` function (the plugin) and an `options` object.)
const plugin = { console; // 4 ;};bot
Example (`register` also can take an array of plugins.)
bot
plugin.register(plugins, callback)
Register plugins to the bot.
Kind: static method of plugin
Param | Type | Description |
---|---|---|
plugins | Array | Object | function |
One or more plugins to register. |
plugins.register | function |
Options to pass to the plugin |
plugins.options | Object |
Options to pass to the plugin |
callback | function |
router
router.listen(pattern, callback)
Listen
Kind: static method of router
Param | Type | Description |
---|---|---|
pattern | RegExp | String |
Pattern to match incoming messages to. |
callback | function |
Example
<caption>Listen takes either a string or regular expression and a callback The callback is calledwhenever a message matching that string/regexp is seen The callback is called with the routemessage body and a respond ;
Example (You can also use capture groups in a regular expression. They are returned as `route.matches`.)
bot;
router.route(path)
Given a message, trigger the first applicable listener.
Kind: static method of router
Param | Type | Description |
---|---|---|
path | String |
Message to match. |