# Type: Input # Category: Common # Description: Responds on greeting # Author: Andriy Lesyuk new Orangutan::Context( response => [ '^H(?:i|ello|ey)(?: Orangutan)?[^a-z]*!*\.*$' ], handler => sub { my ($context, $user, $item) = @_; my $greeted = $user->GetField('greeted'); if (!defined($greeted)) { $main::config->Context('Hi')->Tell($user); $user->SetField('greeted', 1); } elsif ($greeted == 1) { $user->SendMessage('Hi, again... :)'); $user->SetField('greeted', 2); } }, schedule => sub { my ($context, $scheduler, $arg) = @_; if ($arg eq 'forget') { foreach my $username ($main::users->GetUsers) { my $user = $main::users->GetUser($username); $user->UnsetField('greeted'); } } my ($hour, $day, $month, $year) = (localtime(time))[2..5]; if ($hour >= 6) { ($day, $month, $year) = (localtime(time + 86400))[3..5]; } my $time = POSIX::mktime(0, 0, 6, $day, $month, $year); $scheduler->Schedule($time, $context, 'forget'); } ); # kate: syntax perl