From f863aa9e420a452951da9e50f47647e5621c090b Mon Sep 17 00:00:00 2001 From: Pavel Loginov Date: Wed, 17 Mar 2021 23:19:06 +0600 Subject: [PATCH] v5.0.2.0 Changelog: https://haproxy-wi.org/changelog.py#5_0_2 --- app/options.py | 5 +++++ app/templates/ajax/load_telegram.html | 10 +++++++--- inc/users.js | 19 +++++++++++++++++++ 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/app/options.py b/app/options.py index 050a480..598dd4b 100644 --- a/app/options.py +++ b/app/options.py @@ -3099,3 +3099,8 @@ if form.getvalue('loadopenvpn'): openvpn_sess=openvpn_sess, openvpn_configs=openvpn_configs) print(template) + +if form.getvalue('check_telegram'): + telegram_id = form.getvalue('check_telegram') + mess = 'Test message from HAProxy-WI' + funct.telegram_send_mess(mess, telegram_channel_id=telegram_id) \ No newline at end of file diff --git a/app/templates/ajax/load_telegram.html b/app/templates/ajax/load_telegram.html index fe187f0..c8c32b5 100644 --- a/app/templates/ajax/load_telegram.html +++ b/app/templates/ajax/load_telegram.html @@ -7,10 +7,11 @@ Token - Channel name + Channel name {% if page != "servers.py" %} - Group + Group {% endif %} + @@ -22,7 +23,7 @@ {% set id = 'telegram-chanel-' + telegram.0|string() %} - {{ input(id, value=telegram.2) }} + {{ input(id, value=telegram.2, size='30') }} {% if page != "servers.py" %} @@ -38,6 +39,9 @@ {% endif %} + + + diff --git a/inc/users.js b/inc/users.js index 9d6ca13..f536109 100644 --- a/inc/users.js +++ b/inc/users.js @@ -2207,6 +2207,7 @@ function loadchecker() { } else { $('#checker').html(data); $( "select" ).selectmenu(); + $("button").button(); $.getScript('/inc/users.js'); $.getScript(awesome); } @@ -2232,4 +2233,22 @@ function loadopenvpn() { } } ); } +function checkTelegram(telegram_id) { + $.ajax({ + url: "options.py", + data: { + check_telegram: telegram_id, + token: $('#token').val() + }, + type: "POST", + success: function (data) { + data = data.replace(/\s+/g, ' '); + if (data.indexOf('error:') != '-1' || data.indexOf('error_code') != '-1') { + toastr.error(data); + } else { + toastr.success('Test message has been sent'); + } + } + } ); +}