mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2024-12-31 22:01:46 +00:00
overhaul chatMember
This commit is contained in:
parent
4b3363f603
commit
1666cac184
@ -5,7 +5,7 @@
|
|||||||
# This file is public domain in the USA and all free countries.
|
# This file is public domain in the USA and all free countries.
|
||||||
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
|
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
|
||||||
#
|
#
|
||||||
#### $$VERSION$$ v0.98-pre2-10-gae4610a
|
#### $$VERSION$$ v0.98-pre2-14-g4b3363f
|
||||||
|
|
||||||
# will be automatically sourced from bashbot
|
# will be automatically sourced from bashbot
|
||||||
|
|
||||||
@ -37,23 +37,23 @@ leave_chat() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
user_is_creator() {
|
user_is_creator() {
|
||||||
if [ "${1:--}" = "${2:-+}" ] || [ "$(get_chat_member_status "$1" "$2")" = "creator" ]; then return 0; fi
|
# empty is false ...
|
||||||
|
[[ "${1:--}" == "${2:-+}" || "$(get_chat_member_status "$1" "$2")" == "creator" ]] && return 0
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
user_is_admin() {
|
user_is_admin() {
|
||||||
[ "$1" = "$2" ] && return 0
|
[ "${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
|
user_is_botadmin "$2" && return 0
|
||||||
|
local me; me="$(get_chat_member_status "$1" "$2")"
|
||||||
|
[[ "${me}" =~ ^creator$|^administrator$ ]] && return 0
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
user_is_botadmin() {
|
user_is_botadmin() {
|
||||||
local admin; admin="$(getConfigKey "botadmin")"
|
local admin; admin="$(getConfigKey "botadmin")"; [ -z "${admin}" ] && return 1
|
||||||
[ "${admin}" = "${1}" ] && return 0
|
[[ "${admin}" == "${1}" || "${admin}" == "${2}" ]] && return 0
|
||||||
[ "${admin}" = "${2}" ] && return 0
|
#[[ "${admin}" = "@*" ]] && [[ "${admin}" = "${2}" ]] && return 0
|
||||||
[[ "${admin}" = "@*" ]] && [[ "${admin}" = "${2}" ]] && return 0
|
|
||||||
if [ "${admin}" = "?" ]; then setConfigKey "botadmin" "${1:-?}"; return 0; fi
|
if [ "${admin}" = "?" ]; then setConfigKey "botadmin" "${1:-?}"; return 0; fi
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user