#!/usr/bin/haserl <%in p/common.cgi %> <% page_title="Telegram" config_file=/etc/webui/telegram.conf params="enabled token channel interval caption crontab document heif proxy" if [ "$REQUEST_METHOD" = "POST" ]; then for p in $params; do eval telegram_${p}=\$POST_telegram_${p} done if [ "$telegram_enabled" = "true" ]; then [ -z "$telegram_token" ] && set_error_flag "Telegram token cannot be empty." [ -z "$telegram_channel" ] && set_error_flag "Telegram channel cannot be empty." fi if [ -z "$error" ]; then rm -f "$config_file" for p in $params; do echo "telegram_${p}=\"$(eval echo \$telegram_${p})\"" >> "$config_file" done sed -i /telegram/d /etc/crontabs/root if [ "$telegram_enabled" = "true" ] && [ "$telegram_crontab" = "true" ]; then echo "*/${telegram_interval} * * * * /usr/sbin/telegram" >> /etc/crontabs/root fi redirect_back "success" "Telegram config updated." fi redirect_to "$SCRIPT_NAME" fi [ -e "$config_file" ] && include $config_file [ -z "$telegram_crontab" ] && telegram_crontab="true" [ -z "$telegram_interval" ] && telegram_interval="15" %> <%in p/header.cgi %>
<% field_switch "telegram_enabled" "Enable Telegram" "eval" %>
<% field_text "telegram_token" "Token" "Telegram bot authentication token." %> <% field_text "telegram_channel" "Channel" "Channel to post the images to." %> <% field_string "telegram_interval" "Interval" "eval" "15 30 60 120" "Minutes between submissions." %> <% field_text "telegram_caption" "Caption" "Location or short description." %>
<% field_switch "telegram_crontab" "Add to Crontab" "eval" "Send pictures timed by interval." %> <% field_switch "telegram_document" "Send as document" "eval" "Attach picture as general file." %> <% field_switch "telegram_heif" "Use HEIF format" "eval" "Requires H265 codec on Video0." %> <% field_switch "telegram_proxy" "Use SOCKS5" "eval" "Configure proxy access." %>
<% [ -e "$config_file" ] && ex "cat $config_file" %> <% ex "grep telegram /etc/crontabs/root" %>
<% button_submit %>
<%in p/footer.cgi %>