aboutsummaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
authorDavid Phillips <david@sighup.nz>2018-04-10 11:26:22 +1200
committerDavid Phillips <david@sighup.nz>2018-04-10 11:26:22 +1200
commit67f53466bc435b976dc1a4dd76fb1ba45b85c55f (patch)
tree559809b4458863d2d42c1ccfe4aa56b510bf0d48 /plugin
parent4dbb9752708ca966d668022caeb0f3fbe88cec04 (diff)
downloadidalius-67f53466bc435b976dc1a4dd76fb1ba45b85c55f.tar.xz
Improve matching in timezone.pm
Diffstat (limited to 'plugin')
-rw-r--r--plugin/timezone.pm18
1 files changed, 11 insertions, 7 deletions
diff --git a/plugin/timezone.pm b/plugin/timezone.pm
index db6bada..39ff3f0 100644
--- a/plugin/timezone.pm
+++ b/plugin/timezone.pm
@@ -22,14 +22,18 @@ sub message {
my $who_nick = ( split /!/, $who )[0];
my @known_zones = (keys %{$config{timezone}});
- if ($what =~ /^%time\s(.+)$/) {
- my $nick = $1;
- if (grep {$_ eq $nick} @known_zones) {
- my $d = DateTime->now();
- $d->set_time_zone($config{timezone}->{$nick});
- return "$who_nick: $nick\'s clock reads $d";
+ if ($what =~ /^%time\s/) {
+ if ($what =~ /^%time\s+(.+?)\s*$/) {
+ my $nick = $1;
+ if (grep {$_ eq $nick} @known_zones) {
+ my $d = DateTime->now();
+ $d->set_time_zone($config{timezone}->{$nick});
+ return "$who_nick: $nick\'s clock reads $d";
+ } else {
+ return "$who_nick: I don't know what timezone $nick is in";
+ }
} else {
- return "$who_nick: I don't know what timezone $nick is in";
+ return "$who_nick: Syntax: %time [nick]";
}
}
}