some repl fixes

master
Nicolò Balzarotti 2018-09-19 07:26:41 +02:00
parent d11bd8ac31
commit 98ce81a32d
4 changed files with 18 additions and 7 deletions

View File

@ -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='
=#

View File

@ -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

View File

@ -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

View File

@ -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)