Content
The content module provides typed message payload builders. Each class serialises its data into the dict format expected by the Matrix client-server API. You rarely need to instantiate these directly — Room methods create them for you — but they are useful when constructing custom message types.
from matrix.content import MarkdownMessage, TextContent
plain = TextContent(body="Hello, world!")
rich = MarkdownMessage(body="**Hello**, world!")
matrix.content.BaseMessageContent
Bases: ABC
Base class for outgoing message payloads.
msgtype
instance-attribute
msgtype
build
abstractmethod
build()
Source code in matrix/content.py
12 13 14 | |
matrix.content.TextContent
dataclass
TextContent(body)
Bases: BaseMessageContent
msgtype
class-attribute
instance-attribute
msgtype = 'm.text'
body
instance-attribute
body
build
build()
Source code in matrix/content.py
22 23 | |
matrix.content.MarkdownMessage
dataclass
MarkdownMessage(body)
Bases: TextContent
build
build()
Source code in matrix/content.py
28 29 30 31 32 33 34 | |
matrix.content.NoticeContent
dataclass
NoticeContent(body)
Bases: TextContent
msgtype
class-attribute
instance-attribute
msgtype = 'm.notice'
matrix.content.ReplyContent
dataclass
ReplyContent(body, reply_to_event_id)
Bases: TextContent
reply_to_event_id
instance-attribute
reply_to_event_id
build
build()
Source code in matrix/content.py
46 47 48 49 50 51 | |
matrix.content.EditContent
dataclass
EditContent(body, original_event_id)
Bases: TextContent
original_event_id
instance-attribute
original_event_id
build
build()
Source code in matrix/content.py
58 59 60 61 62 63 64 65 66 67 68 69 70 | |
matrix.content.FileContent
dataclass
FileContent(filename, url, mimetype)
Bases: BaseMessageContent
msgtype
class-attribute
instance-attribute
msgtype = 'm.file'
filename
instance-attribute
filename
url
instance-attribute
url
mimetype
instance-attribute
mimetype
build
build()
Source code in matrix/content.py
80 81 82 83 84 85 86 | |
matrix.content.ImageContent
dataclass
ImageContent(filename, url, mimetype, height=0, width=0)
Bases: FileContent
msgtype
class-attribute
instance-attribute
msgtype = 'm.image'
height
class-attribute
instance-attribute
height = 0
width
class-attribute
instance-attribute
width = 0
build
build()
Source code in matrix/content.py
95 96 97 98 99 100 101 102 103 104 105 | |
matrix.content.AudioContent
dataclass
AudioContent(filename, url, mimetype, duration=0)
Bases: FileContent
msgtype
class-attribute
instance-attribute
msgtype = 'm.audio'
duration
class-attribute
instance-attribute
duration = 0
build
build()
Source code in matrix/content.py
113 114 115 116 117 118 119 120 121 122 | |
matrix.content.VideoContent
dataclass
VideoContent(
filename, url, mimetype, height=0, width=0, duration=0
)
Bases: FileContent
msgtype
class-attribute
instance-attribute
msgtype = 'm.video'
height
class-attribute
instance-attribute
height = 0
width
class-attribute
instance-attribute
width = 0
duration
class-attribute
instance-attribute
duration = 0
build
build()
Source code in matrix/content.py
132 133 134 135 136 137 138 139 140 141 142 143 | |
matrix.content.LocationContent
dataclass
LocationContent(geo_uri, description='')
Bases: BaseMessageContent
msgtype
class-attribute
instance-attribute
msgtype = 'm.location'
geo_uri
instance-attribute
geo_uri
description
class-attribute
instance-attribute
description = ''
build
build()
Source code in matrix/content.py
152 153 154 155 156 157 | |
matrix.content.ReactionContent
dataclass
ReactionContent(event_id, emoji)
Bases: BaseMessageContent
For sending reactions to an event.
event_id
instance-attribute
event_id
emoji
instance-attribute
emoji
build
build()
Source code in matrix/content.py
167 168 169 170 171 172 173 174 | |