Skip to content

Nuke unwanted reactions #210

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 11 commits into from
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# CHANGELOG

`@rfcbot` is Rust's automated process manager for RFCs, tracking issues, etc.
As such, this application does not follow semver of any form.

However, we do maintain this changelog explaining high level changes to the way
rfcbot behaves so that the people who develop rfcbot or interact with it can
understand the bot better.

## Changes

+ The bot will now optionally (per configuration in `rfcbot.toml`) remove
unwanted reactions from RFC (and PR..) readers.
These include 👎, 😕 on the `rust-lang/rfcs` and `rust-lang/rust` repositories.
58 changes: 24 additions & 34 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ rocket = "0.3.3"
rocket_codegen = "0.3.3"
rocket_contrib = "0.3.3"
rust-crypto = "0.2.36"
serde = "1.0"
serde_derive = "1.0"
serde = "1.0.59"
serde_derive = "1.0.59"
serde_json = "1.0"
toml = "0.4"
url = "1.4"
urlencoded = "0.5"
arrayvec = "0.4.7"

[dependencies.chrono]
features = ["serde"]
Expand Down
18 changes: 18 additions & 0 deletions rfcbot.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
[prohibited_reactions]

[prohibited_reactions."rust-lang/rfcs".issue]
down_vote = true
confused = true

[prohibited_reactions."rust-lang/rfcs".comment]
down_vote = true
confused = true

[prohibited_reactions."rust-lang/rust".issue]
down_vote = true
confused = true

[prohibited_reactions."rust-lang/rust".comment]
down_vote = true
confused = true

[fcp_behaviors]

[fcp_behaviors."rust-lang/rfcs"]
Expand Down
23 changes: 6 additions & 17 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,26 +71,17 @@ pub fn init() -> Result<Config, Vec<&'static str>> {
.collect::<BTreeMap<_, _>>();

let db_url = vars.remove(DB_URL).unwrap();
let db_pool_size = vars.remove(DB_POOL_SIZE).unwrap();
let db_pool_size = match db_pool_size.parse::<u32>() {
Ok(size) => size,
Err(_) => return Err(vec![DB_POOL_SIZE]),
};
let db_pool_size = vars.remove(DB_POOL_SIZE).unwrap().parse::<u32>();
let db_pool_size = ok_or!(db_pool_size, throw!(vec![DB_POOL_SIZE]));

let gh_token = vars.remove(GITHUB_TOKEN).unwrap();
let gh_ua = vars.remove(GITHUB_UA).unwrap();

let gh_interval = vars.remove(GITHUB_INTERVAL).unwrap();
let gh_interval = match gh_interval.parse::<u64>() {
Ok(interval) => interval,
Err(_) => return Err(vec![GITHUB_INTERVAL]),
};
let gh_interval = vars.remove(GITHUB_INTERVAL).unwrap().parse::<u64>();
let gh_interval = ok_or!(gh_interval, throw!(vec![GITHUB_INTERVAL]));

let post_comments = vars.remove(POST_COMMENTS).unwrap();
let post_comments = match post_comments.parse::<bool>() {
Ok(pc) => pc,
Err(_) => return Err(vec![POST_COMMENTS]),
};
let post_comments = vars.remove(POST_COMMENTS).unwrap().parse::<bool>();
let post_comments = ok_or!(post_comments, throw!(vec![POST_COMMENTS]));

let webhook_secrets = vars.remove(GITHUB_WEBHOOK_SECRETS).unwrap();
let webhook_secrets = webhook_secrets.split(',').map(String::from).collect();
Expand All @@ -106,11 +97,9 @@ pub fn init() -> Result<Config, Vec<&'static str>> {
})

} else {

Err(vars.iter()
.filter(|&(_, v)| v.is_err())
.map(|(&k, _)| k)
.collect())

}
}
Loading