forked from GitHub/dbot
parent
3130350f58
commit
0ccd0c6301
@ -35,7 +35,7 @@ var api = function(dbot) {
|
||||
callback(false, user, profile);
|
||||
}
|
||||
else{
|
||||
callback(true, null, null);
|
||||
callback(true, user, null);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -45,6 +45,22 @@ var api = function(dbot) {
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
'getProfileByUUID': function(uuid, callback){
|
||||
if(uuid){
|
||||
this.db.read('profiles', uuid, function(err, profile){
|
||||
if(!err){
|
||||
callback(false, uuid, profile);
|
||||
}
|
||||
else{
|
||||
callback(true, uuid, null);
|
||||
}
|
||||
});
|
||||
}
|
||||
else{
|
||||
callback(true, null, null);
|
||||
}
|
||||
},
|
||||
|
||||
'getAllProfiles': function(callback){
|
||||
var profiles = [];
|
||||
this.db.scan('profiles', function(profile){
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"ignorable": false,
|
||||
"dbType": "memory",
|
||||
"dbType": "redis",
|
||||
"help": "https://github.com/reality/depressionbot/blob/master/modules/profile/README.md",
|
||||
"schema": {
|
||||
"profile": {
|
||||
|
@ -3,14 +3,27 @@ var _ = require('underscore')._;
|
||||
var profile = function(dbot) {
|
||||
|
||||
this.onLoad = function(){
|
||||
var api = this.api;
|
||||
var schema = this.config.schema;
|
||||
|
||||
// Ensure all users have a profile
|
||||
dbot.api.users.getAllUsers(function(users){
|
||||
if(users){
|
||||
_.each(users, function(user){
|
||||
this.api.getProfileByUUID(user.id, function(err, uuid, profile){
|
||||
// If function returns an error and uuid, create a new profile
|
||||
if(err && uuid){
|
||||
this.api.createProfile(user);
|
||||
}
|
||||
}.bind(this));
|
||||
}.bind(this));
|
||||
}
|
||||
}.bind(this));
|
||||
|
||||
// Add API Hooks
|
||||
dbot.api.command.addHook('~setaliasparent', this.api.renameProfile);
|
||||
dbot.api.event.addHook('new_user', this.api.createProfile);
|
||||
|
||||
//TODO(@samstudio8) Profile Merging
|
||||
//dbot.api.command.addHook('~mergeusers', this.api.mergeProfile);
|
||||
dbot.api.event.addHook('new_user', this.api.createProfile);
|
||||
};
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user