forked from GitHub/dbot
Merge pull request #222 from SamStudio8/master
Add ~profile command [Close #219]
This commit is contained in:
commit
9a74077b98
@ -11,8 +11,8 @@ var api = function(dbot) {
|
|||||||
if(!_.has(this.profiles, server)){
|
if(!_.has(this.profiles, server)){
|
||||||
this.profiles[server] = {};
|
this.profiles[server] = {};
|
||||||
}
|
}
|
||||||
this.profiles[server][primary] = {};
|
this.profiles[server][primary.toLowerCase()] = {};
|
||||||
_.defaults(this.profiles[server][primary], this.config.schema);
|
_.defaults(this.profiles[server][primary.toLowerCase()], this.config.schema);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -5,7 +5,8 @@ var commands = function(dbot){
|
|||||||
|
|
||||||
"~getprop": function(event){
|
"~getprop": function(event){
|
||||||
if(event.params[1]){
|
if(event.params[1]){
|
||||||
var res = dbot.db.profiles[event.server][event.user.toLowerCase()].profile[event.params[1]];
|
var primary = dbot.api.users.resolveUser(event.server, event.user);
|
||||||
|
var res = dbot.db.profiles[event.server][primary.toLowerCase()].profile[event.params[1]];
|
||||||
if(res){
|
if(res){
|
||||||
event.reply(res);
|
event.reply(res);
|
||||||
}
|
}
|
||||||
@ -18,13 +19,32 @@ var commands = function(dbot){
|
|||||||
"~setprop": function(event){
|
"~setprop": function(event){
|
||||||
if(event.input[1] && event.input[2]){
|
if(event.input[1] && event.input[2]){
|
||||||
if(_.has(this.config.schema.profile, event.input[1])){
|
if(_.has(this.config.schema.profile, event.input[1])){
|
||||||
dbot.db.profiles[event.server][event.user.toLowerCase()].profile[event.input[1]] = event.input[2];
|
var primary = dbot.api.users.resolveUser(event.server, event.user);
|
||||||
|
dbot.db.profiles[event.server][primary.toLowerCase()].profile[event.input[1]] = event.input[2];
|
||||||
event.reply("Property set, maybe?");
|
event.reply("Property set, maybe?");
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
event.reply("Invalid property. Go home.");
|
event.reply("Invalid property. Go home.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"~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())){
|
||||||
|
event.reply("http://"+dbot.config.web.webHost+":"+dbot.config.web.webPort+"/profile/"+event.server+"/"+primary.toLowerCase());
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
commands['~setprop'].regex = [/~setprop ([^ ]+) (.+)/, 3];
|
commands['~setprop'].regex = [/~setprop ([^ ]+) (.+)/, 3];
|
||||||
|
@ -17,5 +17,5 @@
|
|||||||
"timezone": null
|
"timezone": null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dependencies": [ "quotes", "command" ]
|
"dependencies": [ "quotes", "users", "command" ]
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user