From 9b6aba058689f432cc55dd940805870c522ad716 Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Sun, 4 Apr 2021 11:22:34 +0200 Subject: [PATCH] mycommands.sh: autoblock example --- mycommands.sh | 15 ++++++++++++++- mycommands.sh.clean | 15 ++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/mycommands.sh b/mycommands.sh index d17f1c7..c3a05f4 100644 --- a/mycommands.sh +++ b/mycommands.sh @@ -13,7 +13,7 @@ # License: WTFPLv2 http://www.wtfpl.net/txt/copying/ # Author: KayM (gnadelwartz), kay@rrr.de # -#### $$VERSION$$ v1.5-0-g8adca9b +#### $$VERSION$$ v1.51-dev-17-gecaecfe ####################################################### # shellcheck disable=SC1117 @@ -324,8 +324,21 @@ else # 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" + 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 -------------- diff --git a/mycommands.sh.clean b/mycommands.sh.clean index 4cb32bf..156e876 100644 --- a/mycommands.sh.clean +++ b/mycommands.sh.clean @@ -10,7 +10,7 @@ # License: WTFPLv2 http://www.wtfpl.net/txt/copying/ # Author: KayM (gnadelwartz), kay@rrr.de # -#### $$VERSION$$ v1.5-0-g8adca9b +#### $$VERSION$$ v1.51-dev-17-gecaecfe ####################################################### # shellcheck disable=SC1117 @@ -126,4 +126,17 @@ else 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