The crontab matcher is a bit different to other matchers. This matcher doesn't take a message as an input, it takes a cron timing instead. It allows you to schedule skills to be called on an interval instead of being triggered by messages.
from opsdroid.matchers import match_crontab from opsdroid.message import Message @match_crontab('* * * * *', timezone="Europe/London") async def mycrontabskill(opsdroid, config, message): # Get the default connector connector = opsdroid.default_connector # Get the default room for that connector room = connector.default_room # Create an empty message to respond to message = Message("", None, room, connector) # Respond await message.respond('Hey')
The above skill would be called every minute. As the skill is being triggered by something other than a message the
message argument being passed in will be set to
None, this means you need to create an empty message to respond to. You will also need to know which connector, and possibly which room, to send the message back to. For this you can use the
opsdroid.default_connector.default_room properties to get some sensible defaults.
You can also set the timezone that the skill crontab is aligned with. This is useful if you want to have different timezones between skills. This kwarg is optional, if not set it will default to the timezone specified in the root of the configuration or failing that UTC.