telegram-bot-bash/bin/send_buttons.sh

55 lines
1.6 KiB
Bash
Raw Normal View History

2021-01-19 20:58:50 +00:00
#!/bin/bash
2021-01-21 08:22:14 +00:00
# shellcheck disable=SC1090,SC2034
2021-01-19 20:58:50 +00:00
#===============================================================================
#
# FILE: bin/send_message.sh
#
USAGE='send_message.sh [-h|--help] "CHAT[ID]" "message" "text|url" ...'
2021-01-19 20:58:50 +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
# text|url - buttons to send, each button as "text|url" pair or
2021-01-24 12:52:44 +00:00
# "url" not http(s):// or tg:// is sent as callback_data
# "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
#
# 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-03-04 12:58:04 +00:00
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
2021-01-19 20:58:50 +00:00
#===============================================================================
####
# parse args
SEND="send_inline_keyboard"
# set bashbot environment
source "${0%/*}/bashbot_env.inc.sh" "debug"
2021-01-22 20:22:16 +00:00
print_help "$1"
2021-01-19 20:58:50 +00:00
####
# ready, do stuff here -----
if [ "$1" == "BOTADMIN" ]; then
2021-03-03 12:40:51 +00:00
CHAT="${BOTADMIN}"
2021-01-19 20:58:50 +00:00
else
CHAT="$1"
fi
2021-01-22 07:18:17 +00:00
MESSAGE="$2"
shift 2
2021-01-19 20:58:50 +00:00
# send message in selected format
2021-01-22 07:18:17 +00:00
"${SEND}" "${CHAT}" "${MESSAGE}" "$(_button_row "$@")"
2021-01-19 20:58:50 +00:00
# output send message result
2021-01-21 08:22:14 +00:00
print_result