mirror of
https://github.com/TheFunny/TelegramTwitterMediaBot.git
synced 2026-10-23 04:12:16 +00:00
refactor(state): add ChatData::format_for for the per-site caption format
Four call sites (cache hit, fresh fetch, startup refetch, /debug preview) spelled out the same message_format.get(...).cloned().unwrap_or_default(); the accessor names the lookup and keeps the empty-format contract in one place.
This commit is contained in:
@@ -23,6 +23,14 @@ pub struct ChatData {
|
||||
pub message_format: HashMap<String, String>,
|
||||
}
|
||||
|
||||
impl ChatData {
|
||||
/// The chat's caption format for `site`, empty when it has none — the
|
||||
/// built-in caption then applies (`caption_from_fields`).
|
||||
pub fn format_for(&self, site: &str) -> String {
|
||||
self.message_format.get(site).cloned().unwrap_or_default()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, Default)]
|
||||
pub struct EditMessage {
|
||||
pub url: String,
|
||||
|
||||
Reference in New Issue
Block a user