mycommands.sh: autoblock example

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2021-04-04 11:22:34 +02:00
parent ecaecfee6f
commit 9b6aba0586
2 changed files with 28 additions and 2 deletions

View File

@ -13,7 +13,7 @@
# License: WTFPLv2 http://www.wtfpl.net/txt/copying/ # License: WTFPLv2 http://www.wtfpl.net/txt/copying/
# Author: KayM (gnadelwartz), kay@rrr.de # Author: KayM (gnadelwartz), kay@rrr.de
# #
#### $$VERSION$$ v1.5-0-g8adca9b #### $$VERSION$$ v1.51-dev-17-gecaecfe
####################################################### #######################################################
# shellcheck disable=SC1117 # shellcheck disable=SC1117
@ -324,8 +324,21 @@ else
# func="$1" err="$2" chat="$3" user="$4" emsg="$5" remaining args # func="$1" err="$2" chat="$3" user="$4" emsg="$5" remaining args
bashbotError_403() { bashbotError_403() {
log_debug "custom errorProcessing error 403: FUNC=$1 CHAT=$3 USER=${4:-no-user} MSGID=$6 ERTXT=$5" log_debug "custom errorProcessing error 403: FUNC=$1 CHAT=$3 USER=${4:-no-user} MSGID=$6 ERTXT=$5"
local user="$4"; [[ -z "$4" && -n "$3" ]] && user="$3"
if [ -n "${user}" ]; then
# block chat/user
case "$6" in
*"blocked"*)
jssh_insertKeyDB "${user}" "User blocked bot on (LANG=C date)" "${BLOCKEDFILE}";;
*"kicked"*)
jssh_insertKeyDB "${user}" "Bot kicked from chat on (LANG=C date)" "${BLOCKEDFILE}";;
*)
jssh_insertKeyDB "${user}" "Reason: $6 on (LANG=C date)" "${BLOCKEDFILE}";;
esac
fi
} }
########################### ###########################
# place your processing functions here -------------- # place your processing functions here --------------

View File

@ -10,7 +10,7 @@
# License: WTFPLv2 http://www.wtfpl.net/txt/copying/ # License: WTFPLv2 http://www.wtfpl.net/txt/copying/
# Author: KayM (gnadelwartz), kay@rrr.de # Author: KayM (gnadelwartz), kay@rrr.de
# #
#### $$VERSION$$ v1.5-0-g8adca9b #### $$VERSION$$ v1.51-dev-17-gecaecfe
####################################################### #######################################################
# shellcheck disable=SC1117 # shellcheck disable=SC1117
@ -126,4 +126,17 @@ else
done <<<"${result}" done <<<"${result}"
} }
###########################
# example error processing
# called when delete Message failed
# func="$1" err="$2" chat="$3" user="$4" emsg="$5" remaining args
bashbotError_delete_message() {
log_debug "custom errorProcessing delete_message: ERR=$2 CHAT=$3 MSGID=$6 ERTXT=$5"
}
# called when error 403 is returned (and no func processing)
# func="$1" err="$2" chat="$3" user="$4" emsg="$5" remaining args
bashbotError_403() {
log_debug "custom errorProcessing error 403: FUNC=$1 CHAT=$3 USER=${4:-no-user} MSGID=$6 ERTXT=$5"
}
fi fi