From 4442382a107b8767e8c21b762ef227ad9c80ea8f Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Mon, 14 Dec 2020 20:35:45 +0100 Subject: [PATCH] option to ignore commands for other bots if admin --- bashbot.sh | 4 ++-- commands.sh | 14 ++++++++++++-- mycommands.sh | 7 ++++++- mycommands.sh.clean | 6 +++++- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/bashbot.sh b/bashbot.sh index b8ab8bf..a7dd306 100755 --- a/bashbot.sh +++ b/bashbot.sh @@ -11,7 +11,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # -#### $$VERSION$$ v1.2-dev2-15-g3496a21 +#### $$VERSION$$ v1.2-dev2-20-gd1f2bc8 # # Exit Codes: # - 0 success (hopefully) @@ -305,7 +305,7 @@ declare -rx BOTTOKEN URL ME_URL UPD_URL GETFILE_URL declare -ax CMD declare -Ax UPD BOTSENT USER MESSAGE URLS CONTACT LOCATION CHAT FORWARD REPLYTO VENUE iQUERY declare -Ax SERVICE NEWMEMBER LEFTMEMBER PINNED MIGRATE -export res CAPTION +export res CAPTION ME ################## diff --git a/commands.sh b/commands.sh index 7d36256..24d091d 100644 --- a/commands.sh +++ b/commands.sh @@ -15,7 +15,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # -#### $$VERSION$$ v1.2-dev2-17-gdfe9c7e +#### $$VERSION$$ v1.2-dev2-20-gd1f2bc8 # # adjust your language setting here, e.g. when run from other user or cron. @@ -65,8 +65,9 @@ fi #---------------------------- # this file *MUST* not edited! # copy "mycommands.sh.dist" to "mycommands.sh" and change the values there -# defaults to no inline and nonsense home dir +# defaults to no inline, all commands and nonsense home dir export INLINE="0" +export MEONLY="0" export FILE_REGEX="${BASHBOT_ETC}/.*" @@ -85,6 +86,15 @@ if [ -z "${1}" ] || [[ "${1}" == *"debug"* ]];then # regular (global) commands ... # your commands are in mycommands() else + + ################### + # if is bashbot is group admin it get commands sent to other bots + # set MEONLY=1 to ignore commands for other bots + if [[ "${MEONLY}" != "0" && "${MESSAGE}" == "/"* && "${MESSAGE%% *}" == *"@"* ]]; then + # here we have a command with @xyz_bot added, check if it's our bot + MYCHECK="${MESSAGE%% *}" + [ "${MYCHECK}" != "${MYCHECK%%@${ME}}" ] && return + fi ################### # user defined commands must placed in mycommands diff --git a/mycommands.sh b/mycommands.sh index 4123065..4e8c3d0 100644 --- a/mycommands.sh +++ b/mycommands.sh @@ -9,7 +9,7 @@ # #### mycommands.clean # # shellcheck disable=SC1117 -#### $$VERSION$$ v1.2-dev2-18-g84b893c +#### $$VERSION$$ v1.2-dev2-20-gd1f2bc8 # # uncomment the following lines to overwrite info and help messages @@ -25,6 +25,11 @@ export res="" # Set INLINE to 1 in order to receive inline queries. # To enable this option in your bot, send the /setinline command to @BotFather. export INLINE="0" + +# if your bot is group admin it get commands sent to other bots +# Set MEONLY to 1 to ignore commands sent to other bots +export MEONLY="0" + # Set to .* to allow sending files from all locations # NOTE: this is a regex, not shell globbing! you must use a valid egex, # '.' matches any character and '.*' matches all remaining charatcers! diff --git a/mycommands.sh.clean b/mycommands.sh.clean index ab0f196..74fa44e 100644 --- a/mycommands.sh.clean +++ b/mycommands.sh.clean @@ -4,7 +4,7 @@ # files: mycommands.sh.clean # copy to mycommands.sh and add all your commands and functions here ... # -#### $$VERSION$$ v1.2-dev2-18-g84b893c +#### $$VERSION$$ v1.2-dev2-20-gd1f2bc8 # ########## @@ -21,6 +21,10 @@ export res="" # To enable this option in your bot must also send the /setinline command to @BotFather. export INLINE="0" +# if your bot is group admin it get commands sent to other bots +# Set MEONLY to 1 to ignore commands sent to other bots +export MEONLY="0" + # NOTE: this is a regex, not shell globbing! you must use a valid egex, # '.' matches any character and '.*' matches all remaining charatcers! # additionally you must escape special characters with '\', e.g. '\. \? \[ \*" to match them literally