diff --git a/modules/chatMember.sh b/modules/chatMember.sh index ba32967..c7fc95b 100644 --- a/modules/chatMember.sh +++ b/modules/chatMember.sh @@ -5,26 +5,31 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # -#### $$VERSION$$ v1.25-dev-14-g2fe6d4b +#### $$VERSION$$ v1.30-dev-0-gd521d35 # will be automatically sourced from bashbot # source once magic, function named like file eval "$(basename "${BASH_SOURCE[0]}")(){ :; }" -LEAVE_URL=${URL}'/leaveChat' -KICK_URL=${URL}'/kickChatMember' -UNBAN_URL=${URL}'/unbanChatMember' +LEAVE_URL="${URL}"'/leaveChat' +KICK_URL="${URL}"'/kickChatMember' +UNBAN_URL="${URL}"'/unbanChatMember' GETMEMBER_URL=${URL}'/getChatMember' -# usage: status="$(get_chat_member_status "chat" "user")" -# $1 chat # $2 user -get_chat_member_status() { - sendJson "$1" '"user_id":'"$2"'' "${GETMEMBER_URL}" - # shellcheck disable=SC2154 - JsonGetString '"result","status"' <<< "${res}" +# manage chat functions ------- +# $1 chat, $2 title +set_chat_title() { + sendJson "$1" '"title": "'"$2"'"' "${URL}/setChatTitle" } +# $1 chat, $2 title +set_chat_description() { + sendJson "$1" '"description": "'"$2"'"' "${URL}/setChatDescription" +} + + +# manage chat member functions ------- kick_chat_member() { sendJson "$1" 'user_id: '"$2"'' "${KICK_URL}" } @@ -37,6 +42,17 @@ leave_chat() { sendJson "$1" "" "${LEAVE_URL}" } + +# bashbot specific functions --------- + +# usage: status="$(get_chat_member_status "chat" "user")" +# $1 chat # $2 user +get_chat_member_status() { + sendJson "$1" '"user_id":'"$2"'' "${GETMEMBER_URL}" + # shellcheck disable=SC2154 + JsonGetString '"result","status"' <<< "${res}" +} + user_is_creator() { # empty is false ... [[ "${1:--}" == "${2:-+}" || "$(get_chat_member_status "$1" "$2")" == "creator" ]] && return 0