Skip to content

Checks

There are a few built in checks that you can make use of:

is_owner

is_owner(*extra_owner_ids)

Requires the sender owns the bot ([NioBot.owner_id][]), or is in extra_owner_ids.

Parameters:

Name Type Description Default
extra_owner_ids

A set of @localpart:homeserver.tld strings to check against.

()

Returns:

Type Description

True - the check passed.

Raises:

Type Description
NotOwner

The sender is not the owner of the bot and is not in the given IDs.

is_dm

is_dm(allow_dual_membership: bool = False)

Requires that the current room is a DM with the sender.

Parameters:

Name Type Description Default
allow_dual_membership bool

Whether to allow regular rooms, but only with the client and sender as members.

False

Returns:

Type Description

sender_has_power

sender_has_power(
    level: int, room_creator_bypass: bool = False
)

Requires that the sender has a certain power level in the current room before running the command.

Parameters:

Name Type Description Default
level int

The minimum power level

required
room_creator_bypass bool

If the room creator should bypass the check and always be allowed, regardless of level.

False

Returns:

Type Description

client_has_power

client_has_power(level: int)

Requires that the bot has a certain power level in the current room before running the command.

Parameters:

Name Type Description Default
level int

The minimum power level

required

Returns:

Type Description

from_homeserver

from_homeserver(*homeservers: str)

Requires that the sender is from one of the given homeservers.

Parameters:

Name Type Description Default
homeservers str

The homeservers to allowlist.

()

Returns:

Type Description