Permalink
Browse files

Simple 'clock?' module for aloha.

  • Loading branch information...
1 parent 1195515 commit a5ea4453af9d5c0a0bdd79b217004976c9def07e vasily.chekalkin committed Sep 28, 2010
Showing with 30 additions and 0 deletions.
  1. +30 −0 lib/Bot/BasicBot/Pluggable/Module/Clock.pm
@@ -0,0 +1,30 @@
+package Bot::BasicBot::Pluggable::Module::Clock;
+use strict;
+use warnings;
+use Bot::BasicBot::Pluggable::Module;
+use base 'Bot::BasicBot::Pluggable::Module';
+
+our $VERSION = 0.01;
+use POSIX qw{ strftime tzset };
+
+my %tz = (
+ SYD => 'Australia/Sydney',
+ UTC => 'UTC',
+);
+
+sub said {
+ my ( $self, $message, $priority ) = @_;
+ return unless ( $priority == 2 );
+
+ ( my $msg_body = $message->{'body'} ) =~ s/^\s+//;
+ if ($msg_body eq 'clock?') {
+ my @dates;
+ while (my ($name, $tz) = each %tz) {
+ local $ENV{TZ} = $tz;
+ push @dates, strftime("$name: %a, %H:%M %Z", localtime());
+ }
+ $self->reply($message, join(' / ', @dates));
+ }
+}
+
+1;

0 comments on commit a5ea445

Please sign in to comment.