# Type: Input # Category: Extra # Description: Allows users to set their status to free # Author: Andriy Lesyuk sub IAmFree_Busy { my ($context, $user, $type, $status) = @_; if ($user->GetField('free')) { if ($type eq 'status') { if (!defined($status)) { $user->UnsetField('free'); } } elsif ($type eq 'task') { if ($status eq 'start') { $user->UnsetField('free'); } } } } new Orangutan::Context( response => [ '^I(?:\'| a)m free(?: now)?!*\.*', '^I(?:\'| a)m busy(?: now)?!*\.*', '^I(?:\'| a)m not free any more!*\.*' ], handler => sub { my ($context, $user, $item) = @_; if ($item == 1) { if ($user->GetTask) { $user->SendMessage([ "You can't be free while working on a task...", 'Free when working on task?.. No way!', "I don't believe you!" ]); } elsif ($user->GetField('free')) { $user->SendMessage([ 'You have already told', 'Lucky you...', 'I know' ]); } else { $user->SetField('free', 1); $user->SendMessage(['Ok', 'Okay', 'Got it', 'Cool', 'Good', 'Excellent']); } } else { if (!$user->GetField('free')) { $user->SendMessage([ 'You have already told', 'I know' ]); } else { $user->UnsetField('free'); $main::config->Context('Ok')->Tell($user); } } }, onstatus => \&IAmFree_Busy, ontask => \&IAmFree_Busy ); # kate: syntax perl