REQUIRED_MEMBERSHIP fix

banned user is still in the list

fix #187
This commit is contained in:
Benny 2023-01-20 20:22:45 +01:00
parent d9eb0490c5
commit d0e32bba60
No known key found for this signature in database
GPG key ID: 6CD0DBDA5235D481

View file

@ -75,8 +75,10 @@ def private_use(func):
# membership check
if REQUIRED_MEMBERSHIP:
try:
app.get_chat_member(REQUIRED_MEMBERSHIP, chat_id)
logging.info("user %s check passed for group/channel %s.", chat_id, REQUIRED_MEMBERSHIP)
if app.get_chat_member(REQUIRED_MEMBERSHIP, chat_id).status != "member":
raise UserNotParticipant()
else:
logging.info("user %s check passed for group/channel %s.", chat_id, REQUIRED_MEMBERSHIP)
except UserNotParticipant:
logging.warning("user %s is not a member of group/channel %s", chat_id, REQUIRED_MEMBERSHIP)
message.reply_text(bot_text.membership_require, quote=True)