mirror of
https://github.com/reality/dbot.git
synced 2024-12-25 04:02:39 +01:00
parent
3130350f58
commit
0ccd0c6301
@ -35,7 +35,7 @@ var api = function(dbot) {
|
|||||||
callback(false, user, profile);
|
callback(false, user, profile);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
callback(true, null, null);
|
callback(true, user, null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -45,6 +45,22 @@ var api = function(dbot) {
|
|||||||
}.bind(this));
|
}.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){
|
'getAllProfiles': function(callback){
|
||||||
var profiles = [];
|
var profiles = [];
|
||||||
this.db.scan('profiles', function(profile){
|
this.db.scan('profiles', function(profile){
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"ignorable": false,
|
"ignorable": false,
|
||||||
"dbType": "memory",
|
"dbType": "redis",
|
||||||
"help": "https://github.com/reality/depressionbot/blob/master/modules/profile/README.md",
|
"help": "https://github.com/reality/depressionbot/blob/master/modules/profile/README.md",
|
||||||
"schema": {
|
"schema": {
|
||||||
"profile": {
|
"profile": {
|
||||||
|
@ -3,14 +3,27 @@ var _ = require('underscore')._;
|
|||||||
var profile = function(dbot) {
|
var profile = function(dbot) {
|
||||||
|
|
||||||
this.onLoad = function(){
|
this.onLoad = function(){
|
||||||
var api = this.api;
|
|
||||||
var schema = this.config.schema;
|
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
|
// Add API Hooks
|
||||||
dbot.api.command.addHook('~setaliasparent', this.api.renameProfile);
|
dbot.api.event.addHook('new_user', this.api.createProfile);
|
||||||
|
|
||||||
//TODO(@samstudio8) Profile Merging
|
//TODO(@samstudio8) Profile Merging
|
||||||
//dbot.api.command.addHook('~mergeusers', this.api.mergeProfile);
|
//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