rooms: send: allow html formatted messages
send: new keyword argument html (html String or nothing)master
parent
4adcee3eea
commit
48493a7f51
14
src/rooms.jl
14
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)))
|
||||
|
|
Loading…
Reference in New Issue