-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
47 lines (41 loc) · 1.39 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/**
* Commands Plugin for Unibot
* @param {Object} options [description]
* db: {mongoose} the mongodb connection
* bot: {irc} the irc bot
* web: {connect} a connect + connect-rest webserver
* config: {object}
* @return {Function} init function to access shared resources
*/
module.exports = function init(options){
var mongoose = options.db;
var bot = options.bot;
var webserver = options.web;
var config = options.config;
webserver.get('/example', function(req, res, next){
res.sendFile(__dirname + '/index.html');
});
webserver.get('/example/:channel', function(req, res, next) {
// mongoose.model(...).findOne({ channel: req.params.channel }, function(err, example){
res.send({ example: 'Hello World!'});
// });
});
return function plugin(channel){
// Executed once per channel
// channel.join(function(who){ /* do something */ });
// channel.leave(function(who, reason){ /* do something */ });
// regexpattern, callback
/* @TODO: SYNTAX COMING SOON:
channel.message('^hi unibot', function(from, matches){
channel.say('Hello ' + from); // in-channel reply
channel.say('Hello', from); // private reply
});
*/
return {
'^hi unibot': function(from, matches){
channel.say('Hello ' + from); // in-channel reply
channel.say('Hello', from); // private reply
}
};
};
};