forked from GitHub/dbot
tz
This commit is contained in:
parent
6838e269b2
commit
0536ce1efa
@ -17,9 +17,19 @@ var commands = function(dbot){
|
|||||||
'~set': function(event){
|
'~set': 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])){
|
||||||
this.api.setProperty(event.server, event.user, event.input[1], event.input[2], function(reply){
|
if(event.input[1] === 'timezone') { // eugh
|
||||||
event.reply(reply);
|
if(moment.tz.zone(event.input[2]) !== null) {
|
||||||
});
|
this.api.setProperty(event.server, event.user, event.input[1], event.input[2], function(reply){
|
||||||
|
event.reply(reply);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
event.reply('Invalid timezone! See the pretty graph here: http://momentjs.com/timezone/');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.api.setProperty(event.server, event.user, event.input[1], event.input[2], function(reply){
|
||||||
|
event.reply(reply);
|
||||||
|
});
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
event.reply('Invalid property. Go home.');
|
event.reply('Invalid property. Go home.');
|
||||||
}
|
}
|
||||||
@ -29,6 +39,25 @@ var commands = function(dbot){
|
|||||||
'~profile': function(event) {
|
'~profile': function(event) {
|
||||||
var user = event.params[1] || event.user;
|
var user = event.params[1] || event.user;
|
||||||
event.reply(dbot.api.web.getUrl('profile/' + event.server + '/' + user));
|
event.reply(dbot.api.web.getUrl('profile/' + event.server + '/' + user));
|
||||||
|
},
|
||||||
|
|
||||||
|
'~time': function(event) {
|
||||||
|
dbot.api.users.getProfile(event.server, event.params[1], function(err, user, profile) {
|
||||||
|
if(!err) {
|
||||||
|
var tz = profile.profile.timezome;
|
||||||
|
if(tz) {
|
||||||
|
event.reply('The time for ' + event.params[1] + ' is ' + moment().tz(tz).format('HH:mm:ss on DD/MM/YYYY'));
|
||||||
|
} else {
|
||||||
|
event.reply(user.currentNick + ' needs to set a timezone with ~timezone');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(!user) {
|
||||||
|
event.reply('No idea who that is mate');
|
||||||
|
} else {
|
||||||
|
event.reply(user.currentNick + ' needs to set a timezone with ~timezone');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
commands['~set'].regex = [/set ([^ ]+) (.+)/, 3];
|
commands['~set'].regex = [/set ([^ ]+) (.+)/, 3];
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
"name": null,
|
"name": null,
|
||||||
"tagline": null,
|
"tagline": null,
|
||||||
"avatar": null,
|
"avatar": null,
|
||||||
|
"timezone": null,
|
||||||
"bio": null,
|
"bio": null,
|
||||||
"lastfm": null,
|
"lastfm": null,
|
||||||
"steam": null,
|
"steam": null,
|
||||||
|
Loading…
Reference in New Issue
Block a user