diff options
author | David Phillips <david@sighup.nz> | 2018-04-10 11:26:22 +1200 |
---|---|---|
committer | David Phillips <david@sighup.nz> | 2018-04-10 11:26:22 +1200 |
commit | 67f53466bc435b976dc1a4dd76fb1ba45b85c55f (patch) | |
tree | 559809b4458863d2d42c1ccfe4aa56b510bf0d48 | |
parent | 4dbb9752708ca966d668022caeb0f3fbe88cec04 (diff) | |
download | idalius-67f53466bc435b976dc1a4dd76fb1ba45b85c55f.tar.xz |
Improve matching in timezone.pm
-rw-r--r-- | plugin/timezone.pm | 18 |
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]"; } } } |