Timed save

This commit is contained in:
Luke Slater 2011-10-12 14:52:58 +01:00
parent 1d6e83b3c0
commit 065611bcff
3 changed files with 6 additions and 5 deletions

View File

@ -15,8 +15,6 @@ var kick = function(dbot) {
}
dbot.say(data.channel, data.kickee + '-- (' + data.kickee + ' has been kicked ' + dbot.db.kicks[data.kickee] + ' times)');
}
dbot.save();
},
on: 'KICK'

View File

@ -120,7 +120,6 @@ var quotes = function(dbot) {
addStack.push('realityonce');
rmAllowed = true;
dbot.instance.say(data.channel, '\'reality ' + once[1] + '.\' saved.');
dbot.save();
}
},

8
run.js
View File

@ -28,7 +28,7 @@ DBot.prototype.say = function(channel, data) {
};
DBot.prototype.save = function() {
fs.writeFile('db.json', JSON.stringify(this.db, null, ' '));
fs.writeFileSync('db.json', JSON.stringify(this.db, null, ' '));
};
DBot.prototype.reloadModules = function() {
@ -45,6 +45,11 @@ DBot.prototype.reloadModules = function() {
this.commands = {};
this.timers.clearTimers();
this.save();
this.timers.addTimer(1000 * 60 * 10, function() {
this.save();
});
var path = require.resolve('./snippets');
require.cache[path] = undefined;
require('./snippets');
@ -90,7 +95,6 @@ DBot.prototype.reloadModules = function() {
else {
this.commands[params[0]](data, params);
}
this.save();
} else {
var q = data.message.valMatch(/^~([\d\w\s]*)/, 2);
if(q) {