Skip to content

Commit c6d3961

Browse files
committed
Improve message format
1 parent 97a9301 commit c6d3961

File tree

4 files changed

+19
-11
lines changed

4 files changed

+19
-11
lines changed

src/chat/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use crate::{
1717
error::Error,
1818
github::{self, GitHubInfo},
1919
repo::{cache::query_cache_commit, resources::RepoResources},
20-
utils::push_empty_line,
20+
utils::empty_or_start_new_line,
2121
};
2222

2323
pub mod paths;
@@ -290,7 +290,7 @@ pub async fn merged_pr_to_commit(
290290
let comment = format!(
291291
"{title}{comment}",
292292
title = pr.title.as_deref().unwrap_or("untitled"),
293-
comment = push_empty_line(&settings.notify.comment),
293+
comment = empty_or_start_new_line(&settings.notify.comment),
294294
);
295295
let commit_settings = CommitSettings {
296296
url: Some(settings.url),

src/main.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,9 +372,17 @@ async fn list_for_admin(bot: Bot, msg: &Message) -> Result<(), CommandError> {
372372

373373
let repos = repo::list().await?;
374374
for repo in repos {
375-
result.push('*');
375+
result.push_str("\\- *");
376376
result.push_str(&markdown::escape(&repo));
377377
result.push_str("*\n");
378+
let settings_json = {
379+
let resources = repo::resources(&repo).await?;
380+
let settings = resources.settings.read().await;
381+
serde_json::to_string(&*settings).map_err(Error::Serde)?
382+
};
383+
result.push_str(" ");
384+
result.push_str(&markdown::escape(&settings_json));
385+
result.push('\n');
378386
}
379387
if result.is_empty() {
380388
result.push_str("(nothing)\n");
@@ -441,7 +449,7 @@ async fn list_for_normal(bot: Bot, msg: &Message) -> Result<(), CommandError> {
441449
if result.is_empty() {
442450
result.push_str("\\(nothing\\)\n");
443451
}
444-
reply_to_msg(&bot, msg, result)
452+
reply_to_msg(&bot, msg, markdown::expandable_blockquote(&result))
445453
.parse_mode(ParseMode::MarkdownV2)
446454
.disable_link_preview(true)
447455
.await?;

src/message.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::{
1010
condition::Action,
1111
error::Error,
1212
repo::{pr_issue_url, resources::RepoResources},
13-
utils::push_empty_line,
13+
utils::empty_or_start_new_line,
1414
};
1515

1616
pub fn commit_check_message(
@@ -75,7 +75,7 @@ pub fn commit_check_message_detail(
7575
.as_ref()
7676
.map(|u| format!("\n{}", markdown::escape(u.as_str())))
7777
.unwrap_or_default(),
78-
notify = push_empty_line(&settings.notify.notify_markdown()),
78+
notify = empty_or_start_new_line(&settings.notify.notify_markdown()),
7979
new = markdown_list(result.new.iter()),
8080
all = markdown_list(result.all.iter())
8181
)
@@ -98,7 +98,7 @@ pub async fn pr_issue_merged_message(
9898
Ok(format!(
9999
"{pretty_id} merged as `{commit}`{notify}",
100100
pretty_id = pr_issue_id_pretty(resources, id).await?,
101-
notify = push_empty_line(&settings.notify.notify_markdown()),
101+
notify = empty_or_start_new_line(&settings.notify.notify_markdown()),
102102
))
103103
}
104104

@@ -110,7 +110,7 @@ pub async fn pr_issue_closed_message(
110110
Ok(format!(
111111
"{pretty_id} has been closed{notify}",
112112
pretty_id = pr_issue_id_pretty(resources, id).await?,
113-
notify = push_empty_line(&settings.notify.notify_markdown()),
113+
notify = empty_or_start_new_line(&settings.notify.notify_markdown()),
114114
))
115115
}
116116

@@ -140,7 +140,7 @@ pub fn branch_check_message(
140140
",
141141
repo = markdown::escape(repo),
142142
branch = markdown::escape(branch),
143-
notify = push_empty_line(&settings.notify.notify_markdown()),
143+
notify = empty_or_start_new_line(&settings.notify.notify_markdown()),
144144
)
145145
}
146146

src/utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ where
2121
.reply_parameters(ReplyParameters::new(msg.id))
2222
}
2323

24-
pub fn push_empty_line(s: &str) -> String {
24+
pub fn empty_or_start_new_line(s: &str) -> String {
2525
let trimmed = s.trim().to_string();
2626
if trimmed.is_empty() {
2727
trimmed
2828
} else {
29-
let mut result = "\n\n".to_string();
29+
let mut result = "\n".to_string();
3030
result.push_str(&trimmed);
3131
result
3232
}

0 commit comments

Comments
 (0)