Passive commands are command handlers that don't follow a strict syntax
!command <arguments>, but instead just match some regular expressions
anywhere in a message.
Passive commands are created using the
regex is a required argument. It can either be a string (in which case
maubot will compile it) or a pre-
re.compile'd Pattern object.
from typing import Tuple from maubot import Plugin, MessageEvent from maubot.handlers import command class PassiveBot(Plugin): @command.passive("cat") async def command(self, evt: MessageEvent, match: Tuple[str]) -> None: await evt.react("🐈️")
Like command handlers, the first parameter is the
MessageEvent object. In
addition to that, passive commands always have a second parameter. By default,
the parameter is a tuple where the first element is the full match, and the
following elements are individual capture groups. If the
multiple flag is set,
then the parameter is an array containing one or more such tuples.
This defines which field to run the regex against in the event content. The
parameter is a function that takes a single argument, the event object. The
default value will return
evt.content.body (i.e. the plaintext body of the
These work the same way as in