Context¶
For each command invoked, the first argument is always a Context
instance, which holds a lot of
metadata, and a few utility functions to help you write commands.
A lot of the time, these are the three main attributes you'll be using:
Context.room
(nio.MatrixRoom
) - the room the command was invoked in.Context.message
(nio.RoomMessageText
) - the message that invoked this command.Context.respond
- a utility class to help you respond to the command.
Command Context¶
Event-based context for a command callback
original_response
property
¶
original_response: Optional[RoomSendResponse]
The result of Context.reply(), if it exists.
respond
async
¶
respond(*args, **kwargs) -> ContextualResponse
Responds to the current event.
See niobot.NioBot.send_message for more information.
Contextual Response¶
Context class for managing replies.
Usage of this function is not required, however it is a useful utility.
original_event
async
¶
original_event() -> Optional[RoomMessage]
Fetches the current event for this response
reply
async
¶
reply(*args, **kwargs) -> ContextualResponse
Replies to the current response.
This does NOT reply to the original invoking message.
See niobot.NioBot.send_message for more information. You do not need to provide the room.
edit
async
¶
Edits the current response.
See niobot.NioBot.edit_message for more information. You do not need to provide the room or event_id.