Skip to content
This repository has been archived by the owner on Oct 10, 2021. It is now read-only.

Commit

Permalink
Add 'cancel' command to abort a scheduled or manual request for standup
Browse files Browse the repository at this point in the history
  • Loading branch information
markpasc committed Aug 14, 2010
1 parent 95fac6f commit e76dd62
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion Standup.pm
Expand Up @@ -72,11 +72,12 @@ sub help {
my $help = $message->{body};
$help =~ s{ \A help \s* }{}msx;

return q{My commands: standup, start, next, park, when} if !$help;
return q{My commands: standup, start, cancel, next, park, when} if !$help;

given ($help) {
when (/^standup$/) { return q{Tell me 'standup' to start a standup manually.} };
when (/^start$/) { return q{When starting a standup, tell me 'start' when everyone's arrived and I'll begin the standup.} };
when (/^cancel$/) { return q{When starting a standup, tell me 'cancel' (before we 'start') to forget about it.} };
when (/^next$/) { return q{During standup, tell me 'next' and I'll pick someone to go next. You can also tell me 'next <name>' to tell me <name> should go next.} };
when (/^park$/) { return q{During standup, tell me 'park <topic>' and I'll remind you about <topic> after we're done.} };
when (/^when$/) { return q{Tell me 'when' and I'll tell you when the next scheduled standup is.} };
Expand All @@ -101,6 +102,7 @@ sub said {
hello => q{hi},
standup => q{standup},
start => q{start},
cancel => q{cancel},
park => q{park},
q{when} => q{when_standup},
dump => q{dump_data},
Expand Down Expand Up @@ -226,6 +228,26 @@ sub start {
return $self->next_person($message, pick_last => 1);
}

sub cancel {
my ($self, $message) = @_;
my $state = $self->state_for_message($message);

return "The standup already started!"
if $state->{started};

if ($message->{channel} ne $state->{standup_channel}) {
my $who = $message->{who};
$self->say(
channel => $state->{standup_channel},
body => qq{Never mind, $who cancelled the standup.},
);
}

delete $self->{in_progress}->{ $state->{id} };

return "Cancelled.";
}

sub next_person {
my ($self, $message, %args) = @_;
my $logger = Log::Log4perl->get_logger( ref $self );
Expand Down

0 comments on commit e76dd62

Please sign in to comment.