telegram-bot-bash/bin/delete_message.sh

49 lines
1.2 KiB
Bash
Raw Normal View History

2021-01-05 12:06:14 +00:00
#!/bin/bash
2021-01-21 08:22:14 +00:00
# shellcheck disable=SC1090,SC2034
2021-01-05 12:06:14 +00:00
#===============================================================================
#
# FILE: bin/delete_message.sh
#
2021-01-09 21:14:44 +00:00
USAGE='delete_message.sh [-h|--help] "CHAT[ID]" "MESSAGE[ID]" [debug]'
2021-01-05 12:06:14 +00:00
#
# DESCRIPTION: delete a message in the given user/group
#
# OPTIONS: CHAT[ID] - ID number of CHAT or BOTADMIN
# MESSAGE[ID] - message to delete
#
# -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: 03.01.2021 15:37
#
2021-06-03 12:21:40 +00:00
#### $$VERSION$$ v1.51-0-g6e66a28
2021-01-05 12:06:14 +00:00
#===============================================================================
####
# parse args
DELETE="delete_message"
# set bashbot environment
source "${0%/*}/bashbot_env.inc.sh" "${3:-debug}" # $3 debug
2021-01-22 20:22:16 +00:00
print_help "$1"
2021-01-05 12:06:14 +00:00
####
# ready, do stuff here -----
if [ "$1" == "BOTADMIN" ]; then
2021-03-03 12:40:51 +00:00
CHAT="${BOTADMIN}"
2021-01-05 12:06:14 +00:00
else
CHAT="$1"
fi
# delete message
"${DELETE}" "${CHAT}" "$2"
[ "${BOTSENT[OK]}" = "true" ] && BOTSENT[ID]="$2"
# output send message result
2021-01-21 08:22:14 +00:00
print_result