mirror of
https://github.com/TheFunny/TelegramTwitterMediaBot.git
synced 2026-09-23 23:32:05 +00:00
handlers: skip inline fetches for non-post queries
Inline queries fire per keystroke and each fetch runs the 3-attempt retry loop; a user typing any text was pumping requests into X/Pixiv/BSky and risking rate-limit bans. Queries now pass only if cache_key recognizes them as a supported post URL.
This commit is contained in:
@@ -775,6 +775,12 @@ pub async fn inline_query_handler(bot: Bot, query: InlineQuery) -> Result<(), Re
|
||||
if query.query.is_empty() {
|
||||
return respond(());
|
||||
}
|
||||
// Telegram fires an inline query on every keystroke; only run a fetch
|
||||
// (3 attempts!) for something that is actually a supported post URL, so
|
||||
// typing does not hammer the source sites.
|
||||
if x_media::site::cache_key(&query.query).is_none() {
|
||||
return respond(());
|
||||
}
|
||||
log::info!("inline query: {}", query.query);
|
||||
match x_media::site::fetch(&query.query).await {
|
||||
Ok(Some(fetched)) => {
|
||||
|
||||
Reference in New Issue
Block a user