@@ -116,19 +116,21 @@ after register_with_hub => sub ($self, @) {
116116};
117117
118118sub handle_manual_assignment ($self , $event ) {
119- my ($username , $rotor_name , $from , $to );
119+ my ($username , $rotor_name , $from , $to , $force );
120120
121121 my $ymd_re = qr { [0-9]{4} - [0-9]{2} - [0-9]{2} } x ;
122- if ($event -> text =~ / ^assign rotor (\S +) to (\S +) on ($ymd_re )\z / ) {
122+ if ($event -> text =~ / ^assign rotor (\S +) to (\S +) on ($ymd_re ) ( \/ f(?:orce))? \z / ) {
123123 $rotor_name = $1 ;
124124 $username = $2 ;
125125 $from = parse_date_for_user($3 , $event -> from_user);
126126 $to = parse_date_for_user($3 , $event -> from_user);
127- } elsif ($event -> text =~ / ^assign rotor (\S +) to (\S +) from ($ymd_re ) to ($ymd_re )\z / ) {
127+ $force = $4 ;
128+ } elsif ($event -> text =~ / ^assign rotor (\S +) to (\S +) from ($ymd_re ) to ($ymd_re ) (\/ f(?:orce))?\z / ) {
128129 $rotor_name = $1 ;
129130 $username = $2 ;
130131 $from = parse_date_for_user($3 , $event -> from_user);
131132 $to = parse_date_for_user($4 , $event -> from_user);
133+ $force = $5 ;
132134 } else {
133135 return ;
134136 }
@@ -164,24 +166,34 @@ sub handle_manual_assignment ($self, $event) {
164166 my (@okay , @errors );
165167
166168 for my $date (@dates ) {
167- my $debug = [];
168- if ($self -> availability_checker-> user_is_available_on($assign_to , $date , $debug )) {
169- push @okay , $date ;
169+ if ($force ) {
170+ # Remove any 'unavailable on' overrides
171+ $self -> availability_checker-> set_user_available_on(
172+ $assign_to ,
173+ $date ,
174+ );
170175 } else {
171- push @errors , @$debug ;
176+ my $debug = [];
177+ if ($self -> availability_checker-> user_is_available_on($assign_to , $date , $debug )) {
178+ push @okay , $date ;
179+ } else {
180+ push @errors , @$debug ;
181+ }
172182 }
173183 }
174184
175185 @dates = @okay ;
176186
177187 unless (@dates ) {
178188 $event -> reply(" $username was not available for any of those dates:\n " . join (" \n " , @errors ));
189+ $event -> reply(" retry with /force at the end to override" );
179190
180191 return ;
181192 }
182193
183194 if (@errors ) {
184195 $event -> reply(" $username was not available for these dates:\n " . join (" \n " , @errors ));
196+ $event -> reply(" retry with /force at the end to override" );
185197 }
186198
187199 $self -> availability_checker-> update_manual_assignments({
0 commit comments