option to ignore commands for other bots if admin

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2020-12-14 20:35:45 +01:00
parent d1f2bc8137
commit 4442382a10
4 changed files with 25 additions and 6 deletions

View File

@ -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
##################

View File

@ -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

View File

@ -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!

View File

@ -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