# Type:        Input
# Category:    Task
# Description: Allows to cancel current task
# Author:      Andriy Lesyuk <s-andy@andriylesyuk.com>

new Orangutan::Context(
    response => '^(?:Remove|delete|drop|cancel)(?: (?:my|the))?(?: current)?(?: task)?!*\.*$',
    handler => sub {
        my ($context, $user, $item) = @_;

        my $task = $user->GetTask;
        if ($task) {
            if ($user->RemoveTask) {
                $user->FireEvent('task', 'cancel', $task);
                $main::config->Context('Ok')->Tell($user);
            } else {
                $user->SendMessage("Oops... I can't remove it... :S");
            }
        } else {
            $user->SendMessage([
                'You did not tell me you are working on something or I already did...',
                'But you are not doing anything...',
                'Nothing to remove!..'
            ]);
        }
    },
    help => {
        title    => 'How can I remove the current task?',
        question => '^(?:How )?(?:(?:can|do) I |to )(?:remove|drop|delete) (?:(?:my|the) )?(?:current )?task\?*!*\.*$',
        answer   => "Some sample queries showing how to remove the current task:\n".
                    " o Drop current task\n".
                    " o Delete my task\n".
                    " o Remove task\n".
                    "Please note that you can't remove finished tasks!",
        weight   => 660
    }
);
# kate: syntax perl