Skip to content

Commit

Permalink
fix: Fix sending done status
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadowRZ committed Nov 5, 2024
1 parent 4d7aee1 commit d0013c1
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions fuuka-bot/src/command/nixpkgs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ impl Context {
let result = fetch_nixpkgs_pr(client, &nixpkgs_pr.token, pr_number).await?;

if track {
if !self.room.is_direct().await? {
return Ok(Some(AnyMessageLikeEventContent::RoomMessage(
RoomMessageEventContent::text_plain(
"Tracking Nixpkgs PR is only avaliable in a DM!",
),
)));
}
let pr_info = result.clone();
let config = self.config.clone();
let http = self.http.clone();
Expand Down Expand Up @@ -69,9 +76,14 @@ impl Context {
}
}
TrackStatus::Done => {
room.send(RoomMessageEventContent::text_plain(format!(
"PR #{pr_number} OK!"
)));
if let Err(e) = room
.send(RoomMessageEventContent::text_plain(format!(
"PR #{pr_number} is now in all branches!"
)))
.await
{
tracing::warn!("Failed to send status: {e:?}");
}
return;
}
}
Expand Down Expand Up @@ -103,12 +115,14 @@ impl Context {
Ok(Some(AnyMessageLikeEventContent::RoomMessage(
RoomMessageEventContent::text_html(
format!(
"PR #{pr_number}: {title} https://github.com/NixOS/nixpkgs/pull/{pr_number}{in_branches}",
"{track_or_not}PR #{pr_number}: {title} https://github.com/NixOS/nixpkgs/pull/{pr_number}{in_branches}",
track_or_not = if track { "Tracking " } else { "" },
title = result.title,
in_branches = in_branches,
),
format!(
"<p><a href='https://github.com/NixOS/nixpkgs/pull/{pr_number}'>PR #{pr_number}: {title}</a>{in_branches}",
"<p>{track_or_not}<a href='https://github.com/NixOS/nixpkgs/pull/{pr_number}'>PR #{pr_number}: {title}</a>{in_branches}",
track_or_not = if track { "Tracking " } else { "" },
title = result.title,
in_branches = in_branches_html,
),
Expand Down

0 comments on commit d0013c1

Please sign in to comment.