2013-01-22 21:44:45 +01:00
|
|
|
var _ = require('underscore')._;
|
|
|
|
|
|
|
|
var profile = function(dbot) {
|
|
|
|
|
|
|
|
this.profiles = dbot.db.profiles;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Iterate over known user profiles and ensure they contain all the
|
|
|
|
* required properties as defined in the configuation.
|
|
|
|
*/
|
|
|
|
this.onLoad = function(){
|
2013-01-28 02:38:36 +01:00
|
|
|
var api = this.api;
|
2013-01-22 21:44:45 +01:00
|
|
|
var schema = this.config.schema;
|
|
|
|
|
|
|
|
// Ensure all known users have a profile
|
|
|
|
_.each(dbot.api.users.getAllUsers(), function(server, serverName){
|
2013-01-28 02:38:36 +01:00
|
|
|
_.each(server, function(primary, primaryi){
|
|
|
|
console.log(primary);
|
|
|
|
api.createProfile(serverName, primary);
|
2013-01-22 21:44:45 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
dbot.save();
|
2013-01-25 16:13:12 +01:00
|
|
|
|
|
|
|
// Add API Hooks
|
|
|
|
dbot.api.command.addHook('~setaliasparent', this.api.renameProfile);
|
|
|
|
dbot.api.command.addHook('~mergeusers', this.api.mergeProfile);
|
2013-01-22 21:44:45 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.fetch = function(dbot) {
|
|
|
|
return new profile(dbot);
|
|
|
|
};
|