mirror of
https://github.com/reality/dbot.git
synced 2024-12-28 21:52:38 +01:00
Add ~profile command [Close #219]
This commit is contained in:
parent
78e0e60083
commit
e798882420
@ -11,8 +11,8 @@ var api = function(dbot) {
|
||||
if(!_.has(this.profiles, server)){
|
||||
this.profiles[server] = {};
|
||||
}
|
||||
this.profiles[server][primary] = {};
|
||||
_.defaults(this.profiles[server][primary], this.config.schema);
|
||||
this.profiles[server][primary.toLowerCase()] = {};
|
||||
_.defaults(this.profiles[server][primary.toLowerCase()], this.config.schema);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -5,7 +5,8 @@ var commands = function(dbot){
|
||||
|
||||
"~getprop": function(event){
|
||||
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){
|
||||
event.reply(res);
|
||||
}
|
||||
@ -18,13 +19,32 @@ var commands = function(dbot){
|
||||
"~setprop": function(event){
|
||||
if(event.input[1] && event.input[2]){
|
||||
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?");
|
||||
}
|
||||
else{
|
||||
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];
|
||||
|
@ -17,5 +17,5 @@
|
||||
"timezone": null
|
||||
}
|
||||
},
|
||||
"dependencies": [ "quotes", "command" ]
|
||||
"dependencies": [ "quotes", "users", "command" ]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user