Catchall¶
The catchall
matcher is a special case which is called only when no other skills were matched.
This matcher catches everything - messages and events, if you want to catch only messages you can set the flag messages_only
to True
.
It is useful for displaying a help message to the user to show available commands that the bot replies to, for example:
… py:function:: match_catchall(func=None, messages_only=False)
- module:
opsdroid.matchers
Return catch-all match decorator.
Decorator that runs the function only if no other skills were matched for a message
- type messages_only:
- param messages_only:
Whether to match only on messages, or on all events. Defaults to False.
- type messages_only:
bool
- returns:
Decorated Function
Example¶
from opsdroid.skill import Skill
from opsdroid.matchers import match_catchall
class HelpMessageSkill(Skill):
@match_catchall
async def help_handler(self, message):
# Called when no other skills were matched