add admin checks to mycommands

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2020-05-16 22:10:12 +02:00
parent 93f49665aa
commit 96fda449b5

View File

@ -8,7 +8,7 @@
# #### if you start to develop your own bot, use the clean version of this file: # #### if you start to develop your own bot, use the clean version of this file:
# #### mycommands.clean # #### mycommands.clean
# #
#### $$VERSION$$ v0.94-0-gaaa71c8 #### $$VERSION$$ v0.94-2-g93f4966
# #
# uncomment the following lines to overwrite info and help messages # uncomment the following lines to overwrite info and help messages
@ -32,6 +32,9 @@ export FILE_REGEX="${BASHBOT_ETC}/.*"
# set to "yes" and give your bot admin privilegs to remove service messaes from groups # set to "yes" and give your bot admin privilegs to remove service messaes from groups
export SILENCER="no" export SILENCER="no"
# messages for admin only commands
NOTADMIN="Sorry, this command is allowed for admin or owner only"
NOTBOTADMIN="Sorry, this command is allowed for bot owner only"
if [ "$1" = "startbot" ];then if [ "$1" = "startbot" ];then
################### ###################
@ -63,6 +66,25 @@ else
fi fi
fi fi
# pre-check admin only commands
case "${MESSAGE}" in
# must be private, group admin, or botadmin
'/run_'*|'stop_'*)
send_action "${CHAT[ID]}" "typing"
if ! user_is_admin "${CHAT[ID]}" "${USER[ID]}" ; then
send_normal_message "${CHAT[ID]}" "${NOTADMIN}"; return 1
fi
# ok, now lets process the real command
;;
# must be botadmin
'/echo'*)
send_action "${CHAT[ID]}" "typing"
if ! user_is_botadmin "${USER[ID]}" ; then
send_markdown_message "${CHAT[ID]}" "*${NOTBOTADMIN}*"; return 1
fi
;;
esac
case "${MESSAGE}" in case "${MESSAGE}" in
################## ##################
# example commands, replace thm by your own # example commands, replace thm by your own