2021-01-19 20:58:50 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#===============================================================================
|
|
|
|
#
|
|
|
|
# FILE: bin/send_message.sh
|
|
|
|
#
|
2021-01-19 22:35:26 +00:00
|
|
|
USAGE='send_message.sh [-h|--help] "CHAT[ID]" "message" "text|url" ...'
|
2021-01-19 20:58:50 +00:00
|
|
|
#
|
2021-01-19 22:35:26 +00:00
|
|
|
# DESCRIPTION: send a send buttons in a row to the given user/group
|
2021-01-19 20:58:50 +00:00
|
|
|
#
|
|
|
|
# OPTIONS: CHAT[ID] - ID number of CHAT or BOTADMIN to send to yourself
|
|
|
|
# message - message to send
|
2021-01-20 15:21:46 +00:00
|
|
|
# text|url - buttons to send, each button as "text|url" pair or
|
|
|
|
# "url" only to show url as text also, "" starts new row
|
2021-01-19 20:58:50 +00:00
|
|
|
#
|
|
|
|
# -h - display short help
|
|
|
|
# --help - this help
|
|
|
|
#
|
2021-01-20 15:21:46 +00:00
|
|
|
# EXAMPLE: 2 buttons on 2 rows, first shows Amazon, second the url as text
|
|
|
|
# send_buttons.sh "Amazon|https://www.amazon.com" "" "https://mydealz.de" ...
|
|
|
|
#
|
2021-01-19 20:58:50 +00:00
|
|
|
# Set BASHBOT_HOME to your installation directory
|
|
|
|
#
|
|
|
|
# LICENSE: WTFPLv2 http://www.wtfpl.net/txt/copying/
|
|
|
|
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
|
|
|
|
# CREATED: 18.01.2021 11:34
|
|
|
|
#
|
2021-01-20 15:21:46 +00:00
|
|
|
#### $$VERSION$$ v1.31-dev-10-gf95b6c2
|
2021-01-19 20:58:50 +00:00
|
|
|
#===============================================================================
|
|
|
|
|
|
|
|
####
|
|
|
|
# parse args
|
|
|
|
SEND="send_inline_keyboard"
|
|
|
|
case "$1" in
|
|
|
|
'')
|
|
|
|
printf "missing arguments\n"
|
|
|
|
;&
|
|
|
|
"-h"*)
|
|
|
|
printf 'usage: %s\n' "${USAGE}"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
'--h'*)
|
|
|
|
sed -n '3,/###/p' <"$0"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# set bashbot environment
|
|
|
|
# shellcheck disable=SC1090
|
2021-01-19 22:35:26 +00:00
|
|
|
source "${0%/*}/bashbot_env.inc.sh" "debug"
|
2021-01-19 20:58:50 +00:00
|
|
|
|
|
|
|
####
|
|
|
|
# ready, do stuff here -----
|
|
|
|
if [ "$1" == "BOTADMIN" ]; then
|
|
|
|
CHAT="${BOT_ADMIN}"
|
|
|
|
else
|
|
|
|
CHAT="$1"
|
|
|
|
fi
|
2021-01-19 22:35:26 +00:00
|
|
|
TEXT="$2"
|
|
|
|
shift 2
|
2021-01-19 20:58:50 +00:00
|
|
|
|
|
|
|
# send message in selected format
|
2021-01-19 22:35:26 +00:00
|
|
|
"${SEND}" "${CHAT}" "${TEXT}" "$(_button_row "$@")"
|
2021-01-19 20:58:50 +00:00
|
|
|
|
|
|
|
# output send message result
|
|
|
|
jssh_printDB "BOTSENT" | sort -r
|
|
|
|
|