Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

telegram message_thread_id workaround #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions telegram/telegram-notify
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
# 31/01/2023, v2.3 - Fix for image and document sending, thanks to jacklul
# 01/02/2023, v2.4 - Add --debug and --position option, idea from z3r0l1nk
# 03/02/2023, v2.5 - Add --audio option and code rewrite
# 27/10/2024, v2.6 - Add --thread option (message_thread_id)
# ---------------------------------------------------

# initialise variables
Expand Down Expand Up @@ -299,6 +300,7 @@ do
"--quiet") QUIET="true"; shift; ;;
"--config") shift; FILE_CONF="$1"; shift; ;;
"--user") shift; ARG_USER_ID="$1"; shift; ;;
"--thread") shift; ARG_THREAD_ID="$1"; shift; ;;
"--key") shift; ARG_API_KEY="$1"; shift; ;;
"--success") ICON=$(get_unicode_string "\U2705"); shift; ;;
"--warning") ICON=$(get_unicode_string "\U26A0"); shift; ;;
Expand Down Expand Up @@ -329,13 +331,15 @@ then
# use defaults from config
API_KEY=$(read_config "API_KEY")
USER_ID=$(read_config "USER_ID")
THREAD_ID=$(read_config "THREAD_ID")
SOCKS_PROXY=$(read_config "SOCKS_PROXY")
else
warning "Configuration file missing ${FILE_CONF}"
fi

# overwrite defaults from config file with more specific command line arguments if provided
[ "${ARG_USER_ID}" != "" ] && USER_ID=${ARG_USER_ID}
[ "${ARG_THREAD_ID}" != "" ] && THREAD_ID=${ARG_THREAD_ID}
[ "${ARG_API_KEY}" != "" ] && API_KEY=${ARG_API_KEY}

# check API key and User ID
Expand Down Expand Up @@ -387,6 +391,9 @@ ARR_OPTIONS=( "--silent" "--insecure" )
# if needed, socks5 option
[ "${SOCKS_PROXY}" != "" ] && ARR_OPTIONS=( "${ARR_OPTIONS[@]}" "--socks5-hostname" "${SOCKS_PROXY}" )

# add thread_id, if defined
[ "${THREAD_ID}" != "" ] && ARR_OPTIONS=( "${ARR_OPTIONS[@]}" "--data" "message_thread_id=${THREAD_ID}" )

case "${TYPE}" in

# text
Expand Down Expand Up @@ -454,6 +461,7 @@ esac
# if there is a message to send
if [ ${#ARR_OPTIONS[@]} -gt 0 ]
then
echo curl "${ARR_OPTIONS[@]}"
# send message
RESULT=$(curl "${ARR_OPTIONS[@]}")

Expand Down