|
1 | 1 | use std::collections::BTreeSet;
|
2 | 2 | use std::fmt;
|
3 | 3 |
|
4 |
| -use crate::config::RFC_BOT_MENTION; |
| 4 | +use crate::config::RFC_BOT_MENTIONS; |
5 | 5 | use crate::error::{DashError, DashResult};
|
6 | 6 | use crate::teams::{RfcbotConfig, TeamLabel};
|
7 | 7 |
|
@@ -218,8 +218,12 @@ fn from_invocation_line<'a>(
|
218 | 218 | setup: &'a RfcbotConfig,
|
219 | 219 | command: &'a str,
|
220 | 220 | ) -> DashResult<RfcBotCommand<'a>> {
|
221 |
| - let mut tokens = command |
222 |
| - .trim_start_matches(RFC_BOT_MENTION) |
| 221 | + // Strip bot mention prefix |
| 222 | + let mention_stripped = RFC_BOT_MENTIONS |
| 223 | + .iter() |
| 224 | + .fold(command, |acc, mention| acc.trim_start_matches(mention)); |
| 225 | + |
| 226 | + let mut tokens = mention_stripped |
223 | 227 | .trim()
|
224 | 228 | .trim_start_matches(':')
|
225 | 229 | .trim()
|
@@ -271,7 +275,7 @@ impl<'a> RfcBotCommand<'a> {
|
271 | 275 | command
|
272 | 276 | .lines()
|
273 | 277 | .map(str::trim)
|
274 |
| - .filter(|&l| l.starts_with(RFC_BOT_MENTION)) |
| 278 | + .filter(|&l| RFC_BOT_MENTIONS.iter().any(|m| l.starts_with(m))) |
275 | 279 | .map(move |l| from_invocation_line(setup, l))
|
276 | 280 | .filter_map(Result::ok)
|
277 | 281 | }
|
@@ -658,4 +662,11 @@ somemoretext";
|
658 | 662 | some_text!("@bob"),
|
659 | 663 | RfcBotCommand::FeedbackRequest("bob")
|
660 | 664 | );
|
| 665 | + |
| 666 | + #[test] |
| 667 | + fn accepts_rust_rfcbot_alias() { |
| 668 | + let body = "@rust-rfcbot: fcp cancel"; |
| 669 | + let with_alias = ensure_take_singleton(parse_commands(body)); |
| 670 | + assert_eq!(with_alias, RfcBotCommand::FcpCancel); |
| 671 | + } |
661 | 672 | }
|
0 commit comments