Skip to content

Add kick extension and user management services#18

Merged
chrisdedman merged 20 commits into
mainfrom
mod-kick
Jul 3, 2026
Merged

Add kick extension and user management services#18
chrisdedman merged 20 commits into
mainfrom
mod-kick

Conversation

@chrisdedman

Copy link
Copy Markdown
Contributor

Added the kick extension for managing user removal from rooms and spaces, along with service modules for user management (which can be used for other moderation extension such as ban, mute, etc)

@chrisdedman chrisdedman requested a review from PenguinBoi12 June 16, 2026 00:20
@chrisdedman chrisdedman self-assigned this Jun 16, 2026

@PenguinBoi12 PenguinBoi12 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

In general it's good, there's going to be refactor needed eventually when adding support for Space but for now the services are fine.

There's one big issue though... There's no permission check on the command. This means everyone can run kick anyone through that command. I think in general we want to restrict this extension to admin/moderator only through a check if possible. It's a good time to implement reusable permission check for Ada (perhaps it could even be added as part of the default checks in matrix.py directly eventually).

I'm not sure why you used getattr everywhere, you want to avoid using that as much as possible unless it's absolutely necessary, which is rare.

It would be great to have tests.

Comment thread bot/extensions/moderation/kick_extension.py Outdated
Comment thread bot/extensions/moderation/kick_extension.py Outdated
Comment thread bot/extensions/moderation/kick_service.py Outdated
Comment thread bot/extensions/moderation/kick_service.py Outdated
Comment thread bot/extensions/moderation/space_service.py Outdated
Comment thread bot/extensions/moderation/space_service.py Outdated
Comment thread bot/extensions/moderation/space_service.py Outdated
Comment thread bot/extensions/moderation/space_service.py Outdated
Comment thread bot/extensions/moderation/space_service.py Outdated
@chrisdedman chrisdedman requested a review from PenguinBoi12 June 17, 2026 02:15
Comment thread bot/permissions.py
Comment thread bot/extensions/moderation/space_service.py Outdated
Comment thread bot/extensions/moderation/space_service.py Outdated
Comment thread bot/extensions/moderation/space_service.py Outdated
Comment thread bot/extensions/moderation/space_service.py Outdated
Comment thread bot/extensions/moderation/tests/test_kick_extension.py Outdated
…st coverage for kick_from_rooms and kick_from_context
@chrisdedman chrisdedman requested a review from PenguinBoi12 July 3, 2026 00:17

@PenguinBoi12 PenguinBoi12 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The only thing I'd change is the is_moderator to make it use can_user_kick but for now it should work fine and we can update it in another PR

Otherwise the rest looks good to me. 🦭

Comment thread bot/permissions.py
power_levels = ctx.room.matrix_room.power_levels
sender_level = power_levels.get_user_level(ctx.sender)

return sender_level >= power_levels.defaults.kick

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

There's a can_user_kick method in power levels

Screenshot_20260702_203906_Firefox.jpg

@chrisdedman chrisdedman merged commit bc56c97 into main Jul 3, 2026
3 checks passed
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