mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-15 01:55:03 +00:00
Added web interface for the Telegram information.
This commit is contained in:
parent
2db57c9df9
commit
f253ea6578
1 changed files with 19 additions and 0 deletions
19
html.c
19
html.c
|
@ -306,6 +306,10 @@ d_char *html_top_controls(snac *snac, d_char *s)
|
|||
"<p>%s:<br>\n"
|
||||
"<input type=\"text\" name=\"email\" value=\"%s\"></p>\n"
|
||||
|
||||
"<p>%s:<br>\n"
|
||||
"<input type=\"text\" name=\"telegram_bot\" placeholder=\"Bot API key\" value=\"%s\"> "
|
||||
"<input type=\"text\" name=\"telegram_chat_id\" placeholder=\"Chat id\" value=\"%s\"></p>\n"
|
||||
|
||||
"<p>%s:<br>\n"
|
||||
"<input type=\"number\" name=\"purge_days\" value=\"%s\"></p>\n"
|
||||
|
||||
|
@ -332,6 +336,14 @@ d_char *html_top_controls(snac *snac, d_char *s)
|
|||
if (xs_is_null(cw))
|
||||
cw = "";
|
||||
|
||||
char *telegram_bot = xs_dict_get(snac->config, "telegram_bot");
|
||||
if (xs_is_null(telegram_bot))
|
||||
telegram_bot = "";
|
||||
|
||||
char *telegram_chat_id = xs_dict_get(snac->config, "telegram_chat_id");
|
||||
if (xs_is_null(telegram_chat_id))
|
||||
telegram_chat_id = "";
|
||||
|
||||
const char *purge_days = xs_dict_get(snac->config, "purge_days");
|
||||
if (!xs_is_null(purge_days) && xs_type(purge_days) == XSTYPE_NUMBER)
|
||||
purge_days = xs_number_str(purge_days);
|
||||
|
@ -364,6 +376,9 @@ d_char *html_top_controls(snac *snac, d_char *s)
|
|||
L("Always show sensitive content"),
|
||||
L("Email address for notifications"),
|
||||
email,
|
||||
L("Telegram notifications (bot key and chat id)"),
|
||||
telegram_bot,
|
||||
telegram_chat_id,
|
||||
L("Maximum days to keep posts (0: server settings)"),
|
||||
purge_days,
|
||||
L("Password (only to change it)"),
|
||||
|
@ -1578,6 +1593,10 @@ int html_post_handler(d_char *req, char *q_path, d_char *payload, int p_size,
|
|||
}
|
||||
if ((v = xs_dict_get(p_vars, "email")) != NULL)
|
||||
snac.config = xs_dict_set(snac.config, "email", v);
|
||||
if ((v = xs_dict_get(p_vars, "telegram_bot")) != NULL)
|
||||
snac.config = xs_dict_set(snac.config, "telegram_bot", v);
|
||||
if ((v = xs_dict_get(p_vars, "telegram_chat_id")) != NULL)
|
||||
snac.config = xs_dict_set(snac.config, "telegram_chat_id", v);
|
||||
if ((v = xs_dict_get(p_vars, "purge_days")) != NULL) {
|
||||
xs *days = xs_number_new(atof(v));
|
||||
snac.config = xs_dict_set(snac.config, "purge_days", days);
|
||||
|
|
Loading…
Reference in a new issue