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-10-23 21:53:14 +02:00
|
|
|
'~get': function(event){
|
2013-01-22 21:44:45 +01:00
|
|
|
if(event.params[1]){
|
2013-04-20 23:51:36 +02:00
|
|
|
if(_.has(this.config.schema.profile, event.params[1])){
|
|
|
|
this.api.getProperty(event.server, event.user, event.params[1], function(reply){
|
|
|
|
event.reply(reply);
|
|
|
|
});
|
2013-06-27 20:43:52 +02:00
|
|
|
} else {
|
|
|
|
event.reply('Invalid property. Go home.');
|
2013-01-22 21:44:45 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2013-10-23 21:53:14 +02:00
|
|
|
'~set': 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-04-20 23:51:36 +02:00
|
|
|
this.api.setProperty(event.server, event.user, event.input[1], event.input[2], function(reply){
|
|
|
|
event.reply(reply);
|
|
|
|
});
|
2013-06-27 20:43:52 +02:00
|
|
|
} else {
|
|
|
|
event.reply('Invalid property. Go home.');
|
2013-01-23 20:13:10 +01:00
|
|
|
}
|
2013-01-22 21:44:45 +01:00
|
|
|
}
|
2013-01-25 20:57:04 +01:00
|
|
|
},
|
2013-06-27 20:43:52 +02:00
|
|
|
|
|
|
|
'~profile': function(event) {
|
|
|
|
var user = event.params[1] || event.user;
|
|
|
|
event.reply(dbot.api.web.getUrl('profile/' + event.server + '/' + user));
|
|
|
|
}
|
2013-01-23 23:55:06 +01:00
|
|
|
};
|
2013-12-29 19:38:24 +01:00
|
|
|
commands['~set'].regex = [/set ([^ ]+) (.+)/, 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);
|
|
|
|
};
|