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))
|
post(u, string("rooms/",room,"/invite"), Dict("user_id" => user))
|
||||||
end
|
end
|
||||||
|
|
||||||
function send(u::MatrixUser, room_id::String, text::String)
|
"""Send message TEXT from user U to room ROOM_ID.
|
||||||
res = post(u, string("rooms/", room_id, "/send/m.room.message"),
|
If HTML is not nothing, send also an html formatted text."""
|
||||||
Dict("msgtype" => "m.text", "body" => 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))
|
JSON.parse(String(res.body))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function getroomevent(u::MatrixUser, room_id::String, event::String)
|
function getroomevent(u::MatrixUser, room_id::String, event::String)
|
||||||
get(u, string("rooms/", HTTP.escapeuri(room_id), "/state",
|
get(u, string("rooms/", HTTP.escapeuri(room_id), "/state",
|
||||||
event == "" ? "" : string("/", event)))
|
event == "" ? "" : string("/", event)))
|
||||||
|
|
Loading…
Reference in New Issue