blob: 39ff3f0a6504304a7ffd2f76731d166482dba14b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
#!/usr/bin/env perl
package plugin::timezone;
use strict;
use warnings;
use DateTime;
my %config;
sub configure {
my $self = $_[0];
my $cref = $_[1];
%config = %$cref;
return $self;
}
sub message {
my ($self, $logger, $me, $who, $where, $raw_what, $what, $irc) = @_;
my $who_nick = ( split /!/, $who )[0];
my @known_zones = (keys %{$config{timezone}});
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: Syntax: %time [nick]";
}
}
}
1;
|