diff --git a/src/github.rs b/src/github.rs index e47dbaa..019dbbb 100644 --- a/src/github.rs +++ b/src/github.rs @@ -36,6 +36,7 @@ pub struct GithubLabel { pub struct GithubUser { pub id: usize, pub login: String, + pub r#type: String, } #[derive(Deserialize, Debug)] diff --git a/src/main.rs b/src/main.rs index e76c154..e136030 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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, @@ -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, d2: DateTime) -> String {