# Type: Input # Category: Common # Description: Shows holidays for a ywar # Author: Andriy Lesyuk new Orangutan::Context( response => [ '^(?:Please )?show(?: ukrainian)?(?: state)? holidays(?: (?:for|in) ([0-9]{4}))?!*\.*$', ], handler => sub { my ($context, $creator, $item, $year) = @_; my $time = time; if (defined($year)) { my ($day, $mon, $curyear) = (localtime($time))[3..5]; if (($curyear + 1900) != $year) { $time = POSIX::mktime(0, 0, 0, $day, $mon, $year - 1900); } } my $message = Orangutan::Context::Random( 'I know about the following holidays', 'Holidays are' ); $message .= ":\n"; my $date = new Orangutan::Date($time); my $holidays = $date->GetHolidays; foreach my $holiday (@{$holidays}) { my $wday = (localtime(@{$holiday}[2]))[6]; $message .= sprintf("%s, %s %d - %s\n", $Orangutan::Date::weekdays[$wday], $Orangutan::Date::months[@{$holiday}[0]->[1]-1], @{$holiday}[0]->[0], @{$holiday}[1]); } $creator->SendMessage($message); } ); # kate: syntax perl