Factory: Telegram message on question and failed

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Richard ZinkandClaude Sonnet 5.5 committed 2026-11-19 10:22:21 +01:00
1 parent 45503de195
commit ccad2c1f6e
4 files changed
+42

No files matched your search

+9
View File
@@ -260,6 +260,15 @@ fn user(app: &App, user_id: &str) -> Result<User> {
app.store.user(user_id)?.filter(|u| !u.disabled).ok_or_else(|| anyhow!("account disabled"))
}
/// Send a message (HTML-escaped) to the user's paired Telegram chat; silent when there is none.
pub async fn notify_user(app: &App, user_id: &str, text: &str) {
let s = load(app, user_id);
let (true, Some(chat)) = (!s.token.is_empty(), s.chat_id) else { return };
if let Err(e) = (Bot { token: s.token }).send(chat, &esc(text), None).await {
tracing::warn!("telegram: notification not sent: {e:#}");
}
}
/// The user reads German (language preference of the web UI).
pub fn german(app: &App, user_id: &str) -> bool {
let prefs: Value = app.store.user_setting(user_id, "prefs").unwrap_or_default();