Skip to content

Change /unmute command so that the exception on permissions is dropped#52

Open
keobox wants to merge 1 commit into
pythonitalia:masterfrom
keobox:fix_stale_users
Open

Change /unmute command so that the exception on permissions is dropped#52
keobox wants to merge 1 commit into
pythonitalia:masterfrom
keobox:fix_stale_users

Conversation

@keobox
Copy link
Copy Markdown

@keobox keobox commented Jun 4, 2026

Why

I've 4 stale users sitting in a muted state forever in the @PythonMilano telegram channel.

Behavior

I'm experiencing This.
The captcha for new user maybe was not displayed, but for sure is not displayed if a user leave the group and then tries to subscribe again.
New users are subscribed but muted meaning that the default permission are overridden by exceptions for them. I suspect that the exception are not cleared from the bot database once a user unsubscribe. Another bug is that the /unmute command does not remove the exception, the result looks like a user is muted forever.

How to test it

In the https://t.me/PythonMilano there are currently 4 stale users, I know this people personally and I want to un-mute them even if they do not clicked the captcha.

@MattiaFailla MattiaFailla self-requested a review June 4, 2026 17:05
Comment on lines -365 to -367
can_change_info=False,
can_change_info=True,
can_invite_users=True,
can_pin_messages=False,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pinning messages and changing group-related info are not privileges granted to normal users: I'd revert this change.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will re-introduce the bug

  • restrictChatMember with can_pin_messages=True does NOT mean "this user can pin messages." It means "remove the per-user restriction on this permission" the user falls back to group defaults.
  • restrictChatMember with can_pin_messages=False means "explicitly restrict this user from pinning, regardless of group defaults."

This creates/keeps a per-user exception.

The Telegram Bot API docs are explicit:
"Pass True for all permissions to lift restrictions from a user."

If even one permission is False, Telegram keeps the per-user restriction record which is exactly the bug we're seeing (users appear restricted in the member list, /unmute "succeeds" but changes nothing visible).

See https://core.telegram.org/bots/api#restrictchatmember

Comment on lines +135 to +137
can_change_info=True,
can_invite_users=True,
can_pin_messages=False,
can_pin_messages=True,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Must be reverted in here too.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants