mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2024-12-29 05:02:46 +00:00
new example command /unpin, fix user_is_allowed
This commit is contained in:
parent
5f602a9a14
commit
e13b9eb940
@ -62,6 +62,7 @@ You must use the function `user_is_allowed` to check if a user has the capabilit
|
|||||||
# GLOBAL commands start here, only edit messages
|
# GLOBAL commands start here, only edit messages
|
||||||
'/start'*)
|
'/start'*)
|
||||||
user_is_botadmin "${USER[ID]}" && send_markdown_message "${CHAT[ID]}" "You are *BOTADMIN*."
|
user_is_botadmin "${USER[ID]}" && send_markdown_message "${CHAT[ID]}" "You are *BOTADMIN*."
|
||||||
|
# true if: user is botadmin, user is group admin, user is allowed
|
||||||
if user_is_allowed "${USER[ID]}" "start" "${CHAT[ID]}" ; then
|
if user_is_allowed "${USER[ID]}" "start" "${CHAT[ID]}" ; then
|
||||||
bot_help "${CHAT[ID]}"
|
bot_help "${CHAT[ID]}"
|
||||||
else
|
else
|
||||||
@ -301,5 +302,5 @@ Note: If you disable automatic retry, se above, you disable also connection prob
|
|||||||
#### [Prev Getting started](2_usage.md)
|
#### [Prev Getting started](2_usage.md)
|
||||||
#### [Next Expert Use](4_expert.md)
|
#### [Next Expert Use](4_expert.md)
|
||||||
|
|
||||||
#### $$VERSION$$ v1.25-dev-23-g8be95a3
|
#### $$VERSION$$ v1.30-dev-9-g5f602a9
|
||||||
|
|
||||||
|
@ -422,9 +422,10 @@ fi
|
|||||||
*See also [Chat Member](https://core.telegram.org/bots/api/#chatmember)*
|
*See also [Chat Member](https://core.telegram.org/bots/api/#chatmember)*
|
||||||
|
|
||||||
##### user_is_allowed
|
##### user_is_allowed
|
||||||
Bashbot supports User Access Control, see [Advanced Usage](3_advanced.md)
|
`uers_is_allowed` checks if: user id botadmin, user is group admin or user is allowed to execute action..
|
||||||
|
Allowed actions are configured as User Access Control rules, see [Advanced Usage](3_advanced.md)
|
||||||
|
|
||||||
*usage:* user_is_allowed "${USER[ID]}" "what" "${CHAT[ID]}"
|
*usage:* user_is_allowed "${USER[ID]}" "action" "${CHAT[ID]}"
|
||||||
|
|
||||||
*example:*
|
*example:*
|
||||||
```bash
|
```bash
|
||||||
@ -1219,5 +1220,5 @@ The name of your bot is available as bash variable "$ME", there is no need to ca
|
|||||||
#### [Prev Best Practice](5_practice.md)
|
#### [Prev Best Practice](5_practice.md)
|
||||||
#### [Next Notes for Developers](7_develop.md)
|
#### [Next Notes for Developers](7_develop.md)
|
||||||
|
|
||||||
#### $$VERSION$$ v1.30-dev-1-ge1f2097
|
#### $$VERSION$$ v1.30-dev-9-g5f602a9
|
||||||
|
|
||||||
|
@ -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$$ v1.30-dev-4-gf573d63
|
#### $$VERSION$$ v1.30-dev-9-g5f602a9
|
||||||
|
|
||||||
# will be automatically sourced from bashbot
|
# will be automatically sourced from bashbot
|
||||||
|
|
||||||
@ -112,6 +112,7 @@ user_is_botadmin() {
|
|||||||
# $1 user # $2 key # $3 chat
|
# $1 user # $2 key # $3 chat
|
||||||
user_is_allowed() {
|
user_is_allowed() {
|
||||||
[ -z "$1" ] && return 1
|
[ -z "$1" ] && return 1
|
||||||
|
user_is_admin "$1" && return 0
|
||||||
# user can do everything
|
# user can do everything
|
||||||
grep -F -xq "$1:*:*" <"${BOTACL}" && return 0
|
grep -F -xq "$1:*:*" <"${BOTACL}" && return 0
|
||||||
[ -z "$2" ] && return 1
|
[ -z "$2" ] && return 1
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
# License: WTFPLv2 http://www.wtfpl.net/txt/copying/
|
# License: WTFPLv2 http://www.wtfpl.net/txt/copying/
|
||||||
# Author: KayM (gnadelwartz), kay@rrr.de
|
# Author: KayM (gnadelwartz), kay@rrr.de
|
||||||
#
|
#
|
||||||
#### $$VERSION$$ v1.25-dev-41-g37e4539
|
#### $$VERSION$$ v1.30-dev-9-g5f602a9
|
||||||
#######################################################
|
#######################################################
|
||||||
# shellcheck disable=SC1117
|
# shellcheck disable=SC1117
|
||||||
|
|
||||||
@ -124,6 +124,10 @@ else
|
|||||||
case "${MESSAGE}" in
|
case "${MESSAGE}" in
|
||||||
##################
|
##################
|
||||||
# example commands, replace thm by your own
|
# example commands, replace thm by your own
|
||||||
|
'/unpin'*) # unpin all messages if (bot)admin or allowed for user
|
||||||
|
user_is_allowed "${USER[ID]}" "unpin" "${CHAT[ID]}" &&\
|
||||||
|
unpinall_chat_messages "${CHAT[ID]}"
|
||||||
|
;;
|
||||||
'/echo'*) # example echo command
|
'/echo'*) # example echo command
|
||||||
send_normal_message "${CHAT[ID]}" "${MESSAGE}"
|
send_normal_message "${CHAT[ID]}" "${MESSAGE}"
|
||||||
;;
|
;;
|
||||||
|
Loading…
Reference in New Issue
Block a user