+ support for self-hosted telegram-bot-api instances
This commit is contained in:
parent
8952aca3f7
commit
c8f9970487
11
tg.sh
11
tg.sh
|
@ -2,6 +2,7 @@
|
||||||
TELEGRAM_TOKEN=""
|
TELEGRAM_TOKEN=""
|
||||||
PARSE_MODE="MarkdownV2"
|
PARSE_MODE="MarkdownV2"
|
||||||
ESCAPE_ALL=false
|
ESCAPE_ALL=false
|
||||||
|
API_URL="https://api.telegram.org"
|
||||||
|
|
||||||
# _escape_text(input_text)
|
# _escape_text(input_text)
|
||||||
function _escape() {
|
function _escape() {
|
||||||
|
@ -38,32 +39,32 @@ function tg_send() {
|
||||||
-F caption="$text" \
|
-F caption="$text" \
|
||||||
-F parse_mode=$PARSE_MODE \
|
-F parse_mode=$PARSE_MODE \
|
||||||
-F $type_snake=$5 \
|
-F $type_snake=$5 \
|
||||||
"https://api.telegram.org/bot${TELEGRAM_TOKEN}/send${type}"
|
"${API_URL}/bot${TELEGRAM_TOKEN}/send${type}"
|
||||||
else
|
else
|
||||||
curl -s \
|
curl -s \
|
||||||
-F chat_id=$1 \
|
-F chat_id=$1 \
|
||||||
-F caption="$text" \
|
-F caption="$text" \
|
||||||
-F parse_mode=$PARSE_MODE \
|
-F parse_mode=$PARSE_MODE \
|
||||||
-F $type_snake=@$3 \
|
-F $type_snake=@$3 \
|
||||||
"https://api.telegram.org/bot${TELEGRAM_TOKEN}/send${type}"
|
"${API_URL}/bot${TELEGRAM_TOKEN}/send${type}"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
curl -s \
|
curl -s \
|
||||||
-F chat_id=$1 \
|
-F chat_id=$1 \
|
||||||
-F text="$text" \
|
-F text="$text" \
|
||||||
-F parse_mode=$PARSE_MODE \
|
-F parse_mode=$PARSE_MODE \
|
||||||
"https://api.telegram.org/bot${TELEGRAM_TOKEN}/sendMessage"
|
"${API_URL}/bot${TELEGRAM_TOKEN}/sendMessage"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# tg_get_me()
|
# tg_get_me()
|
||||||
function 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)
|
# tg_get_messages(offset, timeout)
|
||||||
function _tg_get_updates() {
|
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() {
|
function _on_msg() {
|
||||||
|
|
Loading…
Reference in a new issue