mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2025-02-05 11:58:24 +00:00
botadmin is also an admin, better default for /start command
This commit is contained in:
parent
f13a2d05cc
commit
93f49665aa
@ -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$$ v0.94-0-gaaa71c8
|
||||
#### $$VERSION$$ v0.94-1-gf13a2d0
|
||||
#
|
||||
|
||||
# adjust your language setting here, e.g.when run from other user or cron.
|
||||
@ -104,7 +104,7 @@ if [ -z "${1}" ] || [[ "${1}" == *"debug"* ]];then
|
||||
'/start'*)
|
||||
send_action "${CHAT[ID]}" "typing"
|
||||
user_is_botadmin "${USER[ID]}" && send_markdown_message "${CHAT[ID]}" "You are *BOTADMIN*."
|
||||
if _is_botadmin || _is_allowed "start" ; then
|
||||
if user_is_admin "${CHAT[ID]}" "${USER[ID]}" || user_is_allowed "${USER[ID]}" "start" ; then
|
||||
send_markdown_message "${CHAT[ID]}" "${bashbot_help}"
|
||||
else
|
||||
send_normal_message "${CHAT[ID]}" "You are not allowed to start Bot."
|
||||
@ -115,7 +115,7 @@ if [ -z "${1}" ] || [[ "${1}" == *"debug"* ]];then
|
||||
send_markdown_message "${CHAT[ID]}" "${bashbot_help}"
|
||||
;;
|
||||
'/leavechat'*) # bot leave chat if user is admin in chat
|
||||
if user_is_botadmin "${USER[ID]}" ; then
|
||||
if user_is_admin "${CHAT[ID]}" "${USER[ID]}" || user_is_allowed "${USER[ID]}" "leave" ; then
|
||||
send_markdown_message "${CHAT[ID]}" "*LEAVING CHAT...*"
|
||||
leave_chat "${CHAT[ID]}"
|
||||
fi
|
||||
|
@ -5,7 +5,7 @@
|
||||
# This file is public domain in the USA and all free countries.
|
||||
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
|
||||
#
|
||||
#### $$VERSION$$ v0.94-0-gaaa71c8
|
||||
#### $$VERSION$$ v0.94-1-gf13a2d0
|
||||
|
||||
# source once magic, function named like file
|
||||
eval "$(basename "${BASH_SOURCE[0]}")(){ :; }"
|
||||
@ -45,6 +45,7 @@ user_is_admin() {
|
||||
[ "$1" = "$2" ] && return 0
|
||||
local me; me="$(get_chat_member_status "$1" "$2")"
|
||||
if [ "${me}" = "creator" ] || [ "${me}" = "administrator" ]; then return 0; fi
|
||||
user_is_botadmin "$2" && return 0
|
||||
return 1
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user