From c8f9970487cde9a8886383354132dacc4520077b Mon Sep 17 00:00:00 2001 From: Dominika Liberda Date: Sun, 3 Apr 2022 17:42:49 +0200 Subject: [PATCH] + support for self-hosted telegram-bot-api instances --- tg.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tg.sh b/tg.sh index 14721fb..2a611fc 100755 --- a/tg.sh +++ b/tg.sh @@ -2,6 +2,7 @@ TELEGRAM_TOKEN="" PARSE_MODE="MarkdownV2" ESCAPE_ALL=false +API_URL="https://api.telegram.org" # _escape_text(input_text) function _escape() { @@ -38,32 +39,32 @@ function tg_send() { -F caption="$text" \ -F parse_mode=$PARSE_MODE \ -F $type_snake=$5 \ - "https://api.telegram.org/bot${TELEGRAM_TOKEN}/send${type}" + "${API_URL}/bot${TELEGRAM_TOKEN}/send${type}" else curl -s \ -F chat_id=$1 \ -F caption="$text" \ -F parse_mode=$PARSE_MODE \ -F $type_snake=@$3 \ - "https://api.telegram.org/bot${TELEGRAM_TOKEN}/send${type}" + "${API_URL}/bot${TELEGRAM_TOKEN}/send${type}" fi else curl -s \ -F chat_id=$1 \ -F text="$text" \ -F parse_mode=$PARSE_MODE \ - "https://api.telegram.org/bot${TELEGRAM_TOKEN}/sendMessage" + "${API_URL}/bot${TELEGRAM_TOKEN}/sendMessage" fi } # tg_get_me() function tg_get_me() { - curl -s "https://api.telegram.org/bot${TELEGRAM_TOKEN}/getMe" + curl -s "${API_URL}/bot${TELEGRAM_TOKEN}/getMe" } # tg_get_messages(offset, timeout) function _tg_get_updates() { - curl -s "https://api.telegram.org/bot${TELEGRAM_TOKEN}/getUpdates?offset=$1&timeout=p" | jq -c '.result[]' + curl -s "${API_URL}/bot${TELEGRAM_TOKEN}/getUpdates?offset=$1&timeout=p" | jq -c '.result[]' } function _on_msg() {