From 3653500f09e47643cef512d2588bde9ad3764d15 Mon Sep 17 00:00:00 2001 From: Gregory Lee Bartholomew Date: Sep 13 2022 00:59:21 +0000 Subject: Enforce correct topic for show testdays and show schedule Closes #21 --- diff --git a/bot/commands.pm b/bot/commands.pm index d018455..fada338 100644 --- a/bot/commands.pm +++ b/bot/commands.pm @@ -8,7 +8,7 @@ BEGIN { chomp(our @TOPICS = <$TOPICS>); close $TOPICS; - our $TOPIC = 0; + our $TOPIC = -1; } require commands::fedocal; @@ -142,7 +142,7 @@ my sub _sched { # - appends the list of cards from kanban when appropreate # this is a private subroutine my sub _topic { - my $tpc = $TOPICS[$TOPIC++]; + my $tpc = $TOPICS[++$TOPIC]; my $ret = String::Tagged->new($tpc); return '' unless $tpc; @@ -210,9 +210,17 @@ sub show { $text .= KEY if ($what eq 'agreed' && @crd); } } elsif ($what eq 'schedule') { - $text .= commands::schedule::show(); + if ($TOPICS[$TOPIC] =~ m{the release schedule}m) { + $text .= commands::schedule::show(); + } else { + $text .= 'error: wrong topic'; + } } elsif ($what eq 'testdays') { - $text .= commands::fedocal::tdays(); + if ($TOPICS[$TOPIC] =~ m{upcoming test days}m) { + $text .= commands::fedocal::tdays(); + } else { + $text .= 'error: wrong topic'; + } } return $text;