diff --git a/src/rooms.jl b/src/rooms.jl index 1c0f14a..4d1b129 100644 --- a/src/rooms.jl +++ b/src/rooms.jl @@ -11,13 +11,19 @@ function invite(u::MatrixUser, room::String, user::String) post(u, string("rooms/",room,"/invite"), Dict("user_id" => user)) end -function send(u::MatrixUser, room_id::String, text::String) - res = post(u, string("rooms/", room_id, "/send/m.room.message"), - Dict("msgtype" => "m.text", "body" => text)) +"""Send message TEXT from user U to room ROOM_ID. +If HTML is not nothing, send also an html formatted text.""" +function send(u::MatrixUser, room_id::String, text::String; + html::Union{Nothing,String} = nothing) + msg = Dict("msgtype" => "m.text", "body" => text) + if !isnothing(html) + msg["format"] = "org.matrix.custom.html" + msg["formatted_body"] = html + end + res = post(u, string("rooms/", room_id, "/send/m.room.message"), msg) JSON.parse(String(res.body)) end - function getroomevent(u::MatrixUser, room_id::String, event::String) get(u, string("rooms/", HTTP.escapeuri(room_id), "/state", event == "" ? "" : string("/", event)))