From 90663a51cc7ce2c222a827c4c9191670e1972ac9 Mon Sep 17 00:00:00 2001 From: YoursFunny Date: Mon, 21 Sep 2026 17:36:44 +0800 Subject: [PATCH] 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. --- crates/xmedia-bot/src/handlers/commands.rs | 14 +++++++++++--- crates/xmedia-bot/src/handlers/mod.rs | 20 +------------------- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/crates/xmedia-bot/src/handlers/commands.rs b/crates/xmedia-bot/src/handlers/commands.rs index 0e8c549..8eec7df 100644 --- a/crates/xmedia-bot/src/handlers/commands.rs +++ b/crates/xmedia-bot/src/handlers/commands.rs @@ -2,12 +2,12 @@ //! registration. URL/inline/callback flows live in their own modules. 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::state::ChatData; use teloxide::RequestError; use teloxide::prelude::*; -use teloxide::types::{ChatId, Message, Recipient}; +use teloxide::types::{ChatId, Message, ParseMode, Recipient, ReplyParameters}; use teloxide::utils::command::{BotCommands, ParseError}; #[derive(BotCommands, Clone)] @@ -630,7 +630,15 @@ pub(crate) async fn execute_command( ); // HTML report: the caption renders inside a
// exactly as it will appear in the sent media message. - reply_html(bot, message.chat.id.0, message.id, report).await?; + // `::` disambiguates from the + // MediaSender trait's same-named method (see + // media_sender.rs). + ::send_message(bot, ChatId(message.chat.id.0), report) + .parse_mode(ParseMode::Html) + .reply_parameters( + ReplyParameters::new(message.id).allow_sending_without_reply(), + ) + .await?; } } } diff --git a/crates/xmedia-bot/src/handlers/mod.rs b/crates/xmedia-bot/src/handlers/mod.rs index dd0e10e..18be1f8 100644 --- a/crates/xmedia-bot/src/handlers/mod.rs +++ b/crates/xmedia-bot/src/handlers/mod.rs @@ -27,7 +27,7 @@ use crate::media_sender::MediaSender; use commands::{Command, execute_command}; use teloxide::RequestError; use teloxide::prelude::*; -use teloxide::types::{ChatId, Message, MessageId, ParseMode, ReplyParameters}; +use teloxide::types::{ChatId, Message, MessageId}; use teloxide::utils::command::BotCommands; use urls::{URL_JOBS, extract_urls}; @@ -45,24 +45,6 @@ pub(crate) async fn reply( .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 `
` 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 { - // `::` disambiguates from the MediaSender trait's - // same-named method (see media_sender.rs). - ::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 → /// forward) together: the normalized cache key (`twitter:123…`, `pixiv:123`, /// `bsky:handle/rkey`, `bilibili:123…`) instead of the raw URL, so logs stay