refactor(handlers): inline reply_html into its only caller

The /debug arm was the sole caller; the HTML parse mode and reply decoration
move there with the Requester-disambiguation comment.
This commit is contained in:
2026-09-21 17:36:44 +08:00
parent 7ecb61399d
commit 90663a51cc
2 changed files with 12 additions and 22 deletions
+11 -3
View File
@@ -2,12 +2,12 @@
//! registration. URL/inline/callback flows live in their own modules. //! registration. URL/inline/callback flows live in their own modules.
use super::urls::{PostSend, url_media}; use super::urls::{PostSend, url_media};
use super::{CHAT_STORE, CONFIG, LINK_CACHE, log_key, reply, reply_html}; use super::{CHAT_STORE, CONFIG, LINK_CACHE, log_key, reply};
use crate::ctx::AppContext; use crate::ctx::AppContext;
use crate::state::ChatData; use crate::state::ChatData;
use teloxide::RequestError; use teloxide::RequestError;
use teloxide::prelude::*; use teloxide::prelude::*;
use teloxide::types::{ChatId, Message, Recipient}; use teloxide::types::{ChatId, Message, ParseMode, Recipient, ReplyParameters};
use teloxide::utils::command::{BotCommands, ParseError}; use teloxide::utils::command::{BotCommands, ParseError};
#[derive(BotCommands, Clone)] #[derive(BotCommands, Clone)]
@@ -630,7 +630,15 @@ pub(crate) async fn execute_command(
); );
// HTML report: the caption renders inside a <blockquote> // HTML report: the caption renders inside a <blockquote>
// exactly as it will appear in the sent media message. // exactly as it will appear in the sent media message.
reply_html(bot, message.chat.id.0, message.id, report).await?; // `<Bot as Requester>::` disambiguates from the
// MediaSender trait's same-named method (see
// media_sender.rs).
<Bot as Requester>::send_message(bot, ChatId(message.chat.id.0), report)
.parse_mode(ParseMode::Html)
.reply_parameters(
ReplyParameters::new(message.id).allow_sending_without_reply(),
)
.await?;
} }
} }
} }
+1 -19
View File
@@ -27,7 +27,7 @@ use crate::media_sender::MediaSender;
use commands::{Command, execute_command}; use commands::{Command, execute_command};
use teloxide::RequestError; use teloxide::RequestError;
use teloxide::prelude::*; use teloxide::prelude::*;
use teloxide::types::{ChatId, Message, MessageId, ParseMode, ReplyParameters}; use teloxide::types::{ChatId, Message, MessageId};
use teloxide::utils::command::BotCommands; use teloxide::utils::command::BotCommands;
use urls::{URL_JOBS, extract_urls}; use urls::{URL_JOBS, extract_urls};
@@ -45,24 +45,6 @@ pub(crate) async fn reply(
.map(|_| ()) .map(|_| ())
} }
/// Reply to a message by id with HTML parse mode (same reply decoration as
/// [`reply`]). Used by `/test`, whose report is an HTML message (the caption
/// is wrapped in a `<blockquote>` to show it exactly as it will render).
pub(crate) async fn reply_html(
bot: &Bot,
chat_id: i64,
reply_to: MessageId,
text: String,
) -> Result<i64, RequestError> {
// `<Bot as Requester>::` disambiguates from the MediaSender trait's
// same-named method (see media_sender.rs).
<Bot as Requester>::send_message(bot, ChatId(chat_id), text)
.parse_mode(ParseMode::Html)
.reply_parameters(ReplyParameters::new(reply_to).allow_sending_without_reply())
.await
.map(|message| message.id.0 as i64)
}
/// Log prefix tying the whole lifecycle of one link (fetch → send → cache → /// Log prefix tying the whole lifecycle of one link (fetch → send → cache →
/// forward) together: the normalized cache key (`twitter:123…`, `pixiv:123`, /// forward) together: the normalized cache key (`twitter:123…`, `pixiv:123`,
/// `bsky:handle/rkey`, `bilibili:123…`) instead of the raw URL, so logs stay /// `bsky:handle/rkey`, `bilibili:123…`) instead of the raw URL, so logs stay