Talk Bot API
- class nc_py_api.talk_bot.TalkBotMessage(raw_data: dict)[source]
Talk message received by bots.
- property actor_id: str
One of the attendee types followed by the
/
character and a unique identifier within the given type.For the users it is the Nextcloud user ID, for guests a sha1 value.
- property object_id: int
The message ID of the given message on the origin server.
It can be used to react or reply to the given message.
- property object_name: str
For normal written messages
message
, otherwise one of the knownsystem message identifiers
.
- property object_content: ObjectContent
Dictionary with a
message
andparameters
keys.
- property object_media_type: str
text/markdown
when the message should be interpreted as Markdown, otherwisetext/plain
.
- class nc_py_api.talk_bot.TalkBot(callback_url: str, display_name: str, description: str = '')[source]
A class that implements the TalkBot functionality.
- enabled_handler(enabled: bool, nc: NextcloudApp) None [source]
Handles the app
on
/off
event in the context of the bot.- Parameters:
enabled – Value that was passed to
/enabled
handler.nc – NextcloudApp class that was passed
/enabled
handler.
- send_message(message: str, reply_to_message: int | TalkBotMessage, silent: bool = False, token: str = '') tuple[Response, str] [source]
Send a message and returns a “reference string” to identify the message again in a “get messages” request.
- Parameters:
message – The message to say.
reply_to_message –
The message ID this message is a reply to.
Note
Only allowed when the message type is not
system
orcommand
.silent – Flag controlling if the message should create a chat notifications for the users.
token – Token of the conversation. Can be empty if
reply_to_message
isTalkBotMessage
.
- Returns:
Tuple, where fist element is
httpx.Response
and second is a “reference string”.- Raises:
ValueError – in case of an invalid usage.
RuntimeError – in case of a broken installation.
- react_to_message(message: int | TalkBotMessage, reaction: str, token: str = '') Response [source]
React to a message.
- Parameters:
message – Message ID or
TalkBotMessage
to react to.reaction – A single emoji.
token – Token of the conversation. Can be empty if
message
isTalkBotMessage
.
- Raises:
ValueError – in case of an invalid usage.
RuntimeError – in case of a broken installation.
- delete_reaction(message: int | TalkBotMessage, reaction: str, token: str = '') Response [source]
Removes reaction from a message.
- Parameters:
message – Message ID or
TalkBotMessage
to remove reaction from.reaction – A single emoji.
token – Token of the conversation. Can be empty if
message
isTalkBotMessage
.
- Raises:
ValueError – in case of an invalid usage.
RuntimeError – in case of a broken installation.
- class nc_py_api.talk_bot.ObjectContent[source]
Object content of
TalkBotMessage
.