diff --git a/src/backend/telegram.c b/src/backend/telegram.c index a5b9f8b..aee3183 100644 --- a/src/backend/telegram.c +++ b/src/backend/telegram.c @@ -2111,9 +2111,24 @@ sp_telegram_notify(const struct sp_config *conf, const char *text, sp_buf_printf(err, "telegram: no token in %s", path); return -1; } - /* status text is not a chat answer: send it exactly as written */ - (void)setenv("SPLINTER_TG_MARKDOWN", "0", 0); - return send_message(token, chat, text, err); + /* status text is not a chat answer: send it exactly as written, but + * leave the process's markdown setting as it was for the chat */ + { + const char *old = getenv("SPLINTER_TG_MARKDOWN"); + char save[16]; + int had = old != NULL; + int rc; + + if (had) + snprintf(save, sizeof(save), "%s", old); + (void)setenv("SPLINTER_TG_MARKDOWN", "0", 1); + rc = send_message(token, chat, text, err); + if (had) + (void)setenv("SPLINTER_TG_MARKDOWN", save, 1); + else + (void)unsetenv("SPLINTER_TG_MARKDOWN"); + return rc; + } } int