Skip to content

Commit

Permalink
Merge pull request #37 from guardian/aa/bot-refinement
Browse files Browse the repository at this point in the history
feat: Use emoji to signal bot or human user
  • Loading branch information
akash1810 authored Oct 23, 2024
2 parents ffc4f08 + b08480d commit 3422cbc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pub struct GithubLabel {
pub struct GithubUser {
pub id: usize,
pub login: String,
pub r#type: String,
}

#[derive(Deserialize, Debug)]
Expand Down
20 changes: 8 additions & 12 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,15 +205,8 @@ async fn main() -> Result<(), Error> {
}

fn make_message(pull_request: GithubPullRequest, show_pr_age: bool) -> String {
let prefix = if pull_request.user.login.contains("[bot]") {
"🤖🤖🤖 ".to_string()
} else {
"".to_string()
};

let message = format!(
"{}<{}|{}#{}> - {}",
prefix,
"<{}|{}#{}> - {}",
pull_request.html_url.replace("https://", ""),
pull_request.head.repo.name,
pull_request.number,
Expand All @@ -226,10 +219,13 @@ fn make_message(pull_request: GithubPullRequest, show_pr_age: bool) -> String {
"".to_string()
};

format!(
"{}{} \n\nby {}\n",
message, age_output, pull_request.user.login
)
let user = if pull_request.user.r#type.to_lowercase() == "bot" {
format!("🤖 {}", pull_request.user.login)
} else {
format!("👤 {}", pull_request.user.login)
};

format!("{}{} \n\n{}\n", message, age_output, user)
}

fn get_age(d1: DateTime<Utc>, d2: DateTime<Utc>) -> String {
Expand Down

0 comments on commit 3422cbc

Please sign in to comment.