diff --git a/src/repl.jl b/src/repl.jl index 742c06b..d5db453 100644 --- a/src/repl.jl +++ b/src/repl.jl @@ -498,7 +498,7 @@ function do_cmd!(command::MatrixCommand, repl) elseif length(command.arguments) == 1 history_size = 10 else - history_size = command.arguments + history_size = Base.parse(Int,command.arguments[2]) end history(user, command.arguments[1], limit = history_size) elseif command.spec.kind in [ CMD_DIALOG_LIST ] @@ -869,3 +869,8 @@ Multiple commands can be given on the same line by interleaving a `;` between th **Commands** """ + +#= +Get alias in the event list +curl 'https://chat.nixo.xyz/_matrix/client/r0/rooms/!maXyvEjllUwxzXPTua:nixo.xyz/state?access_token=' +=# diff --git a/src/rooms.jl b/src/rooms.jl index 70f7e73..62a6d66 100644 --- a/src/rooms.jl +++ b/src/rooms.jl @@ -29,10 +29,10 @@ getroomname(u::MatrixUser, room_id::String) = getroomevent(u, room_id, "m.room.n function roomhistory(u::MatrixUser, room_id::String; from::Union{Nothing,String} = nothing, - direction::String = "f", limit = 15) + direction::String = "f", limit::Int = 15) global rooms_last_batch query = Dict("dir" => direction, - "limit" => string(limit), + "limit" => limit, "from" => from === nothing ? rooms_last_batch[room_id] : from) res = get(u, join(["rooms", room_id, "messages",], "/"), extraquery = query) @@ -85,7 +85,9 @@ end function sendtyping(u::MatrixUser, room_id::String; typing = true, timeout = 30000) path = join([u.server.instance, API_PATH, - string("rooms/", escapeuri(room_id), "/typing/", u.userid)], "/") + string("rooms/", HTTP.escapeuri(room_id), "/typing/", u.userid)], "/") data = Dict{String,Any}("typing" => typing, "timeout" => timeout) + @show data + @show path put(u, path, data) end diff --git a/src/types.jl b/src/types.jl index 00cd6f8..8bfa0bd 100644 --- a/src/types.jl +++ b/src/types.jl @@ -13,8 +13,7 @@ struct MatrixUser end import Base.== -==(u::MatrixUser, s::String) = - string("@", u.userid, ":", join(split(URI(u.server.instance).host, ".")[end-1:end], ".")) == s +==(u::MatrixUser, s::String) = string(u) == s ==(s::String, u::MatrixUser) = u == s import Base.show @@ -75,3 +74,8 @@ function Base.show(io::IO, m::MatrixMsg; muser::Union{Nothing,MatrixUser} = noth print(io, string("[", dtfmt, "] ", m.sender, direction, m.body)) nothing end + +import Base.string +function string(u::MatrixUser) + string("@", u.userid, ":", join(split(URI(u.server.instance).host, ".")[end-1:end], ".")) +end diff --git a/src/utils.jl b/src/utils.jl index ab2d18a..7ea3b8c 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -10,7 +10,7 @@ Authenticated get request """ function get(u::MatrixUser, path::String; extraquery = Dict()) - query = Dict( + query = Dict{String,Any}( "access_token" => u.token ) merge!(query, extraquery)