3
0
mirror of https://github.com/reality/dbot.git synced 2024-12-26 04:32:37 +01:00
dbot/modules/profile/profile.js

33 lines
966 B
JavaScript
Raw Normal View History

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(){
var api = this.api;
var schema = this.config.schema;
// Ensure all known users have a profile
_.each(dbot.api.users.getAllUsers(), function(server, serverName){
_.each(server, function(primary, primaryi){
api.createProfile(serverName, primary);
});
});
dbot.save();
// Add API Hooks
dbot.api.command.addHook('~setaliasparent', this.api.renameProfile);
dbot.api.command.addHook('~mergeusers', this.api.mergeProfile);
2013-01-29 00:40:32 +01:00
dbot.api.event.addHook('new_user', this.api.createProfile);
};
};
exports.fetch = function(dbot) {
return new profile(dbot);
};