mirror of
https://github.com/tgbot-collection/ytdlbot.git
synced 2025-02-25 07:44:13 +08:00
membership check #198
This commit is contained in:
parent
218b1d5ec9
commit
7bf4331274
2 changed files with 9 additions and 3 deletions
|
@ -33,8 +33,9 @@ OWNER = os.getenv("OWNER", "BennyThink")
|
|||
|
||||
# limitation settings
|
||||
AUTHORIZED_USER: "str" = os.getenv("AUTHORIZED_USER", "")
|
||||
# membership requires: the format could be username/chat_id of channel or group
|
||||
REQUIRED_MEMBERSHIP: "str" = os.getenv("REQUIRED_MEMBERSHIP", "")
|
||||
# membership requires: the format could be username(without @ sign)/chat_id of channel or group.
|
||||
# You need to add the bot to this group/channel as admin
|
||||
REQUIRED_MEMBERSHIP: "str" = os.getenv("REQUIRED_MEMBERSHIP", "mikuri520")
|
||||
|
||||
# celery related
|
||||
ENABLE_CELERY = os.getenv("ENABLE_CELERY", False)
|
||||
|
|
|
@ -84,7 +84,12 @@ def private_use(func):
|
|||
# TODO bug fix # 198 membership check
|
||||
if REQUIRED_MEMBERSHIP:
|
||||
try:
|
||||
if app.get_chat_member(REQUIRED_MEMBERSHIP, chat_id).status != "member":
|
||||
if app.get_chat_member(REQUIRED_MEMBERSHIP, chat_id).status not in [
|
||||
"creator",
|
||||
"administrator",
|
||||
"member",
|
||||
"owner",
|
||||
]:
|
||||
raise UserNotParticipant()
|
||||
else:
|
||||
logging.info("user %s check passed for group/channel %s.", chat_id, REQUIRED_MEMBERSHIP)
|
||||
|
|
Loading…
Reference in a new issue