mirror of
https://github.com/reality/dbot.git
synced 2024-11-27 22:39:26 +01:00
46 lines
1.1 KiB
JavaScript
46 lines
1.1 KiB
JavaScript
|
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,
|
||
|
'channels': {}
|
||
|
};
|
||
|
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,
|
||
|
'lines': 0
|
||
|
};
|
||
|
this.db.save('channel_stats', id, cStats, function(err, cStats) {
|
||
|
callback(cStats);
|
||
|
});
|
||
|
}
|
||
|
};
|
||
|
|
||
|
return api;
|
||
|
};
|
||
|
|
||
|
exports.fetch = function(dbot) {
|
||
|
return api(dbot);
|
||
|
};
|