Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/python_italy_bot/handlers/moderation.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,14 +362,16 @@ async def _handle_unmute(update: Update, context: ContextTypes.DEFAULT_TYPE) ->
can_send_polls=True,
can_send_other_messages=True,
can_add_web_page_previews=True,
can_change_info=False,
can_change_info=True,
can_invite_users=True,
can_pin_messages=False,
Comment on lines -365 to -367

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

can_pin_messages=True,
)

try:
await context.bot.restrict_chat_member(chat.id, user_id, full_perms)
await moderation_service.remove_mute(user_id, chat.id)
captcha_service: CaptchaService = context.bot_data["captcha_service"]
await captcha_service.verify_user_globally(user_id)
await message.reply_text(strings.UNMUTE_SUCCESS)
except Exception as e:
logger.warning("Unmute failed: %s", e)
Expand Down
4 changes: 2 additions & 2 deletions src/python_italy_bot/services/captcha.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ def get_full_permissions(self) -> ChatPermissions:
can_send_polls=True,
can_send_other_messages=True,
can_add_web_page_previews=True,
can_change_info=False,
can_change_info=True,
can_invite_users=True,
can_pin_messages=False,
can_pin_messages=True,
Comment on lines +135 to +137

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.

)

def is_secret_command(self, text: str) -> bool:
Expand Down