2013-01-22 20:44:45 +00:00
|
|
|
var _ = require('underscore')._;
|
|
|
|
|
|
|
|
var profile = function(dbot) {
|
|
|
|
|
|
|
|
this.onLoad = function(){
|
|
|
|
var schema = this.config.schema;
|
|
|
|
|
2013-01-25 15:13:12 +00:00
|
|
|
// Add API Hooks
|
2013-04-21 16:10:24 +01:00
|
|
|
dbot.api.event.addHook('new_user', this.api.createProfile);
|
|
|
|
|
2013-10-24 20:31:49 +00:00
|
|
|
dbot.instance.addPreEmitHook(function(event, callback) {
|
|
|
|
if(!event.rUser) return callback();
|
2014-09-05 12:06:10 +00:00
|
|
|
this.api.getProfileByUser(event.rUser, function(uProfile) {
|
2013-10-24 20:31:49 +00:00
|
|
|
if(uProfile) {
|
|
|
|
event.rProfile = uProfile.profile;
|
|
|
|
}
|
2014-09-05 12:06:10 +00:00
|
|
|
callback();
|
2013-10-24 20:31:49 +00:00
|
|
|
}.bind(this));
|
|
|
|
}.bind(this));
|
|
|
|
|
2013-04-20 22:51:36 +01:00
|
|
|
//TODO(@samstudio8) Profile Merging
|
|
|
|
//dbot.api.command.addHook('~mergeusers', this.api.mergeProfile);
|
2013-01-22 20:44:45 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.fetch = function(dbot) {
|
|
|
|
return new profile(dbot);
|
|
|
|
};
|