2020-12-23 15:59:38 +00:00
|
|
|
#!/bin/bash
|
2021-01-21 08:22:14 +00:00
|
|
|
# shellcheck disable=SC1090,SC2034
|
2020-12-23 15:59:38 +00:00
|
|
|
#===============================================================================
|
|
|
|
#
|
2020-12-24 10:41:40 +00:00
|
|
|
# FILE: bin/send_message.sh
|
2020-12-23 15:59:38 +00:00
|
|
|
#
|
2021-01-15 11:45:53 +00:00
|
|
|
USAGE='send_edit_message.sh [-h|--help] [format|caption] "CHAT[ID]" "MESSAGE[ID]" "message ...." [debug]'
|
2020-12-23 15:59:38 +00:00
|
|
|
#
|
|
|
|
# DESCRIPTION: replace a message in the given user/group
|
|
|
|
#
|
2021-01-15 11:45:53 +00:00
|
|
|
# OPTIONS: format - normal, markdown, html or caption for file caption (optional)
|
2020-12-25 17:27:48 +00:00
|
|
|
# CHAT[ID] - ID number of CHAT or BOTADMIN to send to yourself
|
2020-12-23 15:59:38 +00:00
|
|
|
# MESSAGE[ID] - message to replace
|
|
|
|
# message - message to send in specified format
|
|
|
|
# if no format is given send_normal_message() format is used
|
|
|
|
#
|
|
|
|
# -h - display short help
|
|
|
|
# --help - this help
|
|
|
|
#
|
|
|
|
# Set BASHBOT_HOME to your installation directory
|
|
|
|
#
|
|
|
|
# LICENSE: WTFPLv2 http://www.wtfpl.net/txt/copying/
|
|
|
|
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
|
|
|
|
# CREATED: 23.12.2020 16:52
|
|
|
|
#
|
2021-01-21 08:22:14 +00:00
|
|
|
#### $$VERSION$$ v1.31-dev-14-g749eee7
|
2020-12-23 15:59:38 +00:00
|
|
|
#===============================================================================
|
|
|
|
|
|
|
|
####
|
|
|
|
# parse args
|
|
|
|
SEND="edit_normal_message"
|
|
|
|
case "$1" in
|
2021-01-07 12:15:18 +00:00
|
|
|
"nor"*|"tex"*)
|
2020-12-23 15:59:38 +00:00
|
|
|
SEND="edit_normal_message"
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
"mark"*)
|
|
|
|
SEND="edit_markdownv2_message"
|
|
|
|
shift
|
|
|
|
;;
|
2021-01-15 11:45:53 +00:00
|
|
|
"htm"*)
|
2020-12-23 15:59:38 +00:00
|
|
|
SEND="edit_html_message"
|
|
|
|
shift
|
|
|
|
;;
|
2021-01-15 11:45:53 +00:00
|
|
|
"cap"*)
|
|
|
|
SEND="edit_message_caption"
|
|
|
|
shift
|
|
|
|
;;
|
2020-12-23 15:59:38 +00:00
|
|
|
esac
|
|
|
|
|
2020-12-25 17:27:48 +00:00
|
|
|
# set bashbot environment
|
2021-01-10 14:51:16 +00:00
|
|
|
source "${0%/*}/bashbot_env.inc.sh" "${4:-debug}" # $4 debug
|
2021-01-21 08:22:14 +00:00
|
|
|
print_help
|
2020-12-25 17:27:48 +00:00
|
|
|
|
2020-12-23 15:59:38 +00:00
|
|
|
####
|
|
|
|
# ready, do stuff here -----
|
2020-12-25 17:27:48 +00:00
|
|
|
if [ "$1" == "BOTADMIN" ]; then
|
2020-12-25 18:16:54 +00:00
|
|
|
CHAT="${BOT_ADMIN}"
|
2020-12-25 17:27:48 +00:00
|
|
|
else
|
|
|
|
CHAT="$1"
|
|
|
|
fi
|
2020-12-23 15:59:38 +00:00
|
|
|
|
|
|
|
# send message in selected format
|
2020-12-25 17:27:48 +00:00
|
|
|
"${SEND}" "${CHAT}" "$2" "$3"
|
2020-12-23 15:59:38 +00:00
|
|
|
|
|
|
|
# output send message result
|
2021-01-21 08:22:14 +00:00
|
|
|
print_result
|