2013-01-22 21:44:45 +01:00
|
|
|
var _ = require('underscore')._;
|
|
|
|
|
|
|
|
var commands = function(dbot){
|
2013-01-24 23:44:41 +01:00
|
|
|
var commands = {
|
2013-01-22 21:44:45 +01:00
|
|
|
|
2013-01-24 23:44:41 +01:00
|
|
|
"~getprop": function(event){
|
2013-01-22 21:44:45 +01:00
|
|
|
if(event.params[1]){
|
2013-01-25 20:57:04 +01:00
|
|
|
var primary = dbot.api.users.resolveUser(event.server, event.user);
|
|
|
|
var res = dbot.db.profiles[event.server][primary.toLowerCase()].profile[event.params[1]];
|
2013-01-22 21:44:45 +01:00
|
|
|
if(res){
|
|
|
|
event.reply(res);
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
event.reply("Nope.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2013-01-24 23:44:41 +01:00
|
|
|
"~setprop": function(event){
|
2013-01-23 23:55:06 +01:00
|
|
|
if(event.input[1] && event.input[2]){
|
|
|
|
if(_.has(this.config.schema.profile, event.input[1])){
|
2013-01-25 20:57:04 +01:00
|
|
|
var primary = dbot.api.users.resolveUser(event.server, event.user);
|
|
|
|
dbot.db.profiles[event.server][primary.toLowerCase()].profile[event.input[1]] = event.input[2];
|
2013-01-23 20:13:10 +01:00
|
|
|
event.reply("Property set, maybe?");
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
event.reply("Invalid property. Go home.");
|
|
|
|
}
|
2013-01-22 21:44:45 +01:00
|
|
|
}
|
2013-01-25 20:57:04 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
"~profile": function(event){
|
|
|
|
if(event.params[1]){
|
|
|
|
var primary = dbot.api.users.resolveUser(event.server, event.params[1]);
|
|
|
|
if(_.has(dbot.db.profiles[event.server], primary.toLowerCase())){
|
2013-04-14 06:02:00 +02:00
|
|
|
event.reply(dbot.api.web.getUrl("profile/"+event.server+"/"+primary.toLowerCase()));
|
2013-01-25 20:57:04 +01:00
|
|
|
}
|
|
|
|
else{
|
|
|
|
event.reply("No profile found for "+event.params[1]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
event.message = '~profile ' + event.user;
|
|
|
|
event.action = 'PRIVMSG';
|
|
|
|
event.params = event.message.split(' ');
|
|
|
|
dbot.instance.emit(event);
|
|
|
|
}
|
2013-01-22 21:44:45 +01:00
|
|
|
}
|
2013-01-23 23:55:06 +01:00
|
|
|
};
|
2013-01-24 23:44:41 +01:00
|
|
|
commands['~setprop'].regex = [/~setprop ([^ ]+) (.+)/, 3];
|
2013-01-23 23:55:06 +01:00
|
|
|
|
2013-01-24 23:44:41 +01:00
|
|
|
return commands;
|
2013-01-22 21:44:45 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
exports.fetch = function(dbot){
|
|
|
|
return commands(dbot);
|
|
|
|
};
|