2013-10-16 17:12:05 +02:00
|
|
|
var _ = require('underscore')._,
|
|
|
|
databank = require('databank');
|
|
|
|
|
|
|
|
var api = function(dbot) {
|
|
|
|
var api = {
|
|
|
|
'getUserStats': function(id, callback) {
|
|
|
|
this.db.read('user_stats', id, function(err, uStats) {
|
|
|
|
callback(uStats);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
'createUserStats': function(id, callback) {
|
|
|
|
var uStats = {
|
|
|
|
'id': id,
|
|
|
|
'lines': 0,
|
2013-10-17 05:59:29 +02:00
|
|
|
'words': 0,
|
|
|
|
'capitals': 0,
|
|
|
|
'curses': 0,
|
2013-10-17 05:06:17 +02:00
|
|
|
'channels': {},
|
|
|
|
'creation': new Date().getTime()
|
2013-10-16 17:12:05 +02:00
|
|
|
};
|
|
|
|
this.db.save('user_stats', id, uStats, function(err, uStats) {
|
|
|
|
callback(uStats);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
'getChannelStats': function(id, callback) {
|
|
|
|
this.db.read('channel_stats', id, function(err, cStats) {
|
|
|
|
callback(cStats);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
'createChannelStats': function(id, callback) {
|
|
|
|
var cStats = {
|
|
|
|
'id': id,
|
2013-10-17 05:06:17 +02:00
|
|
|
'lines': 0,
|
2013-10-17 05:59:29 +02:00
|
|
|
'words': 0,
|
|
|
|
'capitals': 0,
|
|
|
|
'curses': 0,
|
2013-10-17 05:06:17 +02:00
|
|
|
'creation': new Date().getTime()
|
2013-10-16 17:12:05 +02:00
|
|
|
};
|
|
|
|
this.db.save('channel_stats', id, cStats, function(err, cStats) {
|
|
|
|
callback(cStats);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
return api;
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.fetch = function(dbot) {
|
|
|
|
return api(dbot);
|
|
|
|
};
|