mirror of
https://github.com/reality/dbot.git
synced 2024-11-27 06:19:24 +01:00
Announce module
This commit is contained in:
parent
ef1e514c54
commit
14bb252a73
38
modules/announce/announce.js
Normal file
38
modules/announce/announce.js
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/**
|
||||||
|
* Name: Announce
|
||||||
|
* Description: Announce things every now and again
|
||||||
|
*/
|
||||||
|
var _ = require('underscore')._;
|
||||||
|
|
||||||
|
var announce = function(dbot) {
|
||||||
|
this.announces = dbot.config.modules.announce.announces;
|
||||||
|
this.lineCount = 0;
|
||||||
|
this.lastAnnounce = {};
|
||||||
|
_.each(dbot.config.servers, function(v, k) {
|
||||||
|
this.lastAnnounce[k] = {};
|
||||||
|
_.each(this.announces[k], function(announce, channel) {
|
||||||
|
this.lastAnnounce[k][channel] = announce.distance;
|
||||||
|
}, this)
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
this.listener = function(event) {
|
||||||
|
if(_.has(this.lastAnnounce[event.server], event.channel)) {
|
||||||
|
this.lastAnnounce[event.server][event.channel]--;
|
||||||
|
if(this.lastAnnounce[event.server][event.channel] == 0) {
|
||||||
|
var announce = this.config.announces[event.server][event.channel];
|
||||||
|
this.lastAnnounce[event.server][event.channel] = announce.distance;
|
||||||
|
|
||||||
|
dbot.api.quotes.getQuote(announce.category, function(quote) {
|
||||||
|
if(quote) {
|
||||||
|
dbot.say(event.server, event.channel, quote);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.bind(this);
|
||||||
|
this.on = 'PRIVMSG';
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.fetch = function(dbot) {
|
||||||
|
return new announce(dbot);
|
||||||
|
};
|
10
modules/announce/config.json
Normal file
10
modules/announce/config.json
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"announces": {
|
||||||
|
"aberwiki": {
|
||||||
|
"#test": {
|
||||||
|
"category": "test",
|
||||||
|
"distance": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user