telegram: restore SPLINTER_TG_MARKDOWN after a status notify
This commit is contained in:
1 parent
6b51f48335
commit
9a6b282388
1 file changed
+18
-3
+18
-3
@@ -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
|
||||
|
||||
Reference in new issue
Block a user