| matrix_message_send |
function |
go |
infra |
0.1.0 |
impure |
func MatrixSendText(ctx context.Context, client *mautrix.Client, roomID id.RoomID, body string) (id.EventID, error)
func MatrixSendMarkdown(ctx context.Context, client *mautrix.Client, roomID id.RoomID, markdown string) (id.EventID, error)
func MatrixSendReply(ctx context.Context, client *mautrix.Client, roomID id.RoomID, replyTo id.EventID, body string) (id.EventID, error)
func MatrixEditMessage(ctx context.Context, client *mautrix.Client, roomID id.RoomID, eventID id.EventID, newBody string) (id.EventID, error)
func MatrixSendReaction(ctx context.Context, client *mautrix.Client, roomID id.RoomID, targetEventID id.EventID, key string) (id.EventID, error)
|
Envía mensajes Matrix con todas las variantes del compositor: texto plain, markdown con HTML sanitizado, reply con m.in_reply_to, edit (m.replace) y reaction (m.annotation). Si el room es E2EE y client.Crypto está configurado via matrix_crypto_init, mautrix cifra automáticamente. |
| matrix |
| mautrix |
| send |
| message |
| markdown |
| reply |
| edit |
| reaction |
| infra |
| matrix-mas |
|
| name |
desc |
| ctx |
Context para cancelación y timeout de la petición HTTP a Synapse. |
|
| name |
desc |
| client |
*mautrix.Client autenticado. Debe tener AccessToken, UserID y DeviceID. Si es nil, error inmediato. |
|
| name |
desc |
| roomID |
ID del room Matrix destino. Formato: !xxx:server. |
|
| name |
desc |
| body / markdown / newBody |
Contenido del mensaje. Para MatrixSendMarkdown se parsea con goldmark y se sanitiza con bluemonday UGCPolicy. |
|
| name |
desc |
| replyTo / eventID / targetEventID |
ID del evento referenciado (para reply, edit y reaction). |
|
| name |
desc |
| key |
Emoji unicode raw para reaction (ej. '👍'). No shortcodes (👍). |
|
|
id.EventID del evento enviado por Synapse + error. El EventID permite referenciar el mensaje para edits, replies o reactions posteriores. |
|
|
|
false |
error_go_core |
| context |
| bytes |
| fmt |
| github.com/microcosm-cc/bluemonday |
| github.com/yuin/goldmark |
| maunium.net/go/mautrix |
| maunium.net/go/mautrix/event |
| maunium.net/go/mautrix/id |
|
true |
| SendText body correcto y EventID parseado |
| SendMarkdown bold convierte a HTML strong y sanitiza script |
| SendReply m.relates_to m.in_reply_to presente |
| EditMessage rel_type m.replace y m.new_content |
| SendReaction tipo m.reaction con m.annotation y key |
| SendText client nil devuelve error |
| SendMarkdown client nil devuelve error |
| SendReply client nil devuelve error |
| EditMessage client nil devuelve error |
| SendReaction client nil devuelve error |
|
functions/infra/matrix_message_send_test.go |
functions/infra/matrix_message_send.go |