Skip to content

Commit 2098adf

Browse files
committed
support mentioning rust-rfcbot
1 parent 423aadb commit 2098adf

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
>
77
> The new account used by the bot is [rust-rfcbot](https://github.com/rust-rfcbot).
88
>
9-
> You still need to ping the old account, i.e. `@rfcbot`.
9+
> You can mention either `@rfcbot` or `@rust-rfcbot`.
1010
1111
[rfcbot](https://github.com/rfcbot) manages asynchronous decision making on Rust issues and PRs. Status of Final Comment Periods can be viewed on [the relevant dashboard page](http://rfcbot.rs).
1212

@@ -16,10 +16,11 @@ While its intended usage is for RFCs, you can use its tracking on any issue or p
1616

1717
## Usage
1818

19-
rfcbot accepts commands in GitHub comments. All commands take the form:
19+
rfcbot accepts commands in GitHub comments. All commands take one of the following forms:
2020

2121
```
2222
@rfcbot COMMAND [PARAMS]
23+
@rust-rfcbot COMMAND [PARAMS]
2324
```
2425

2526
Each command must start on its own line, but otherwise the bot doesn't care if there's other text in the comment. This is valid:

src/config.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
use std::collections::BTreeMap;
3333
use std::env;
3434

35-
pub const RFC_BOT_MENTION: &str = "@rfcbot";
35+
/// All valid mention handles that should trigger rfcbot.
36+
pub const RFC_BOT_MENTIONS: [&str; 2] = ["@rfcbot", "@rust-rfcbot"];
3637
pub const GH_ORGS: [&str; 3] = ["rust-lang", "rust-lang-nursery", "rust-lang-deprecated"];
3738

3839
lazy_static! {

src/github/command.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::collections::BTreeSet;
22
use std::fmt;
33

4-
use crate::config::RFC_BOT_MENTION;
4+
use crate::config::RFC_BOT_MENTIONS;
55
use crate::error::{DashError, DashResult};
66
use crate::teams::{RfcbotConfig, TeamLabel};
77

@@ -218,8 +218,12 @@ fn from_invocation_line<'a>(
218218
setup: &'a RfcbotConfig,
219219
command: &'a str,
220220
) -> 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
223227
.trim()
224228
.trim_start_matches(':')
225229
.trim()
@@ -271,7 +275,7 @@ impl<'a> RfcBotCommand<'a> {
271275
command
272276
.lines()
273277
.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)))
275279
.map(move |l| from_invocation_line(setup, l))
276280
.filter_map(Result::ok)
277281
}
@@ -658,4 +662,11 @@ somemoretext";
658662
some_text!("@bob"),
659663
RfcBotCommand::FeedbackRequest("bob")
660664
);
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+
}
661672
}

0 commit comments

Comments
 (0)