@@ -122,34 +122,18 @@ macro_rules! command_handlers {
122
122
}
123
123
}
124
124
125
- // TODO: parse multiple commands and diff them
126
- let mut input = Input :: new( & body, & ctx. username) ;
127
- let command = input. next( ) ;
128
-
129
- if let Some ( previous) = event. comment_from( ) {
130
- let mut prev_input = Input :: new( & previous, & ctx. username) ;
131
- let prev_command = prev_input. next( ) ;
132
- if command == prev_command {
133
- log:: info!(
134
- "skipping unmodified command: {:?} -> {:?}" ,
135
- prev_command,
136
- command
137
- ) ;
138
- return ;
139
- } else {
140
- log:: debug!(
141
- "executing modified command: {:?} -> {:?}" ,
142
- prev_command,
143
- command
144
- ) ;
145
- }
146
- }
147
-
148
- let command = match command {
149
- Some ( command) => command,
150
- None => return ,
125
+ let input = Input :: new( & body, & ctx. username) ;
126
+ let commands = if let Some ( previous) = event. comment_from( ) {
127
+ let prev_commands = Input :: new( & previous, & ctx. username) . collect:: <Vec <_>>( ) ;
128
+ input. filter( |cmd| !prev_commands. contains( cmd) ) . collect:: <Vec <_>>( )
129
+ } else {
130
+ input. collect( )
151
131
} ;
152
132
133
+ if commands. is_empty( ) {
134
+ return ;
135
+ }
136
+
153
137
let config = match config {
154
138
Ok ( config) => config,
155
139
Err ( e @ ConfigurationError :: Missing ) => {
@@ -163,30 +147,32 @@ macro_rules! command_handlers {
163
147
}
164
148
} ;
165
149
166
- match command {
167
- $(
168
- Command :: $enum( Ok ( command) ) => {
169
- if let Some ( config) = & config. $name {
170
- $name:: handle_command( ctx, config, event, command)
171
- . await
172
- . unwrap_or_else( |err| errors. push( HandlerError :: Other ( err) ) ) ;
173
- } else {
150
+ for command in commands {
151
+ match command {
152
+ $(
153
+ Command :: $enum( Ok ( command) ) => {
154
+ if let Some ( config) = & config. $name {
155
+ $name:: handle_command( ctx, config, event, command)
156
+ . await
157
+ . unwrap_or_else( |err| errors. push( HandlerError :: Other ( err) ) ) ;
158
+ } else {
159
+ errors. push( HandlerError :: Message ( format!(
160
+ "The feature `{}` is not enabled in this repository.\n \
161
+ To enable it add its section in the `triagebot.toml` \
162
+ in the root of the repository.",
163
+ stringify!( $name)
164
+ ) ) ) ;
165
+ }
166
+ }
167
+ Command :: $enum( Err ( err) ) => {
174
168
errors. push( HandlerError :: Message ( format!(
175
- "The feature `{}` is not enabled in this repository. \n \
176
- To enable it add its section in the `triagebot.toml` \
177
- in the root of the repository." ,
178
- stringify! ( $name )
169
+ "Parsing {} command in [comment]({}) failed: {}" ,
170
+ stringify! ( $name ) ,
171
+ event . html_url ( ) . expect ( "has html url" ) ,
172
+ err
179
173
) ) ) ;
180
- }
174
+ } ) *
181
175
}
182
- Command :: $enum( Err ( err) ) => {
183
- errors. push( HandlerError :: Message ( format!(
184
- "Parsing {} command in [comment]({}) failed: {}" ,
185
- stringify!( $name) ,
186
- event. html_url( ) . expect( "has html url" ) ,
187
- err
188
- ) ) ) ;
189
- } ) *
190
176
}
191
177
}
192
178
}
0 commit comments