diff --git a/modules/profile/api.js b/modules/profile/api.js index 246b741..633c993 100644 --- a/modules/profile/api.js +++ b/modules/profile/api.js @@ -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); }, /** diff --git a/modules/profile/commands.js b/modules/profile/commands.js index efae49e..a402066 100644 --- a/modules/profile/commands.js +++ b/modules/profile/commands.js @@ -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]; diff --git a/modules/profile/config.json b/modules/profile/config.json index 109f7c0..24f5027 100644 --- a/modules/profile/config.json +++ b/modules/profile/config.json @@ -17,5 +17,5 @@ "timezone": null } }, - "dependencies": [ "quotes", "command" ] + "dependencies": [ "quotes", "users", "command" ] }