Files
lua-matrix/examples/get-user-info.lua
Adrian Perez de Castro e128366f7f Use eventables in matrix.client, implement a chunk of functionality
Yeah, I know: commits should have been smaller and all that. Yadda-yadda.
2016-07-01 05:05:50 +03:00

27 lines
640 B
Lua

#! /usr/bin/env lua
--
-- get-user-info.lua
-- Copyright (C) 2016 Adrian Perez <aperez@igalia.com>
--
-- Distributed under terms of the MIT license.
--
if #arg ~= 3 then
io.stderr:write(string.format("Usage: %s <homeserver-URL> <username> <password>\n", arg[0]))
os.exit(1)
end
local client = require "matrix" .client(arg[1])
client:login_with_password(arg[2], arg[3])
local user = client:get_user()
print("User ID: " .. user.user_id)
user:hook("property-changed", function (user, property)
print(" - " .. property .. ": " .. tostring(user[property]))
end)
user:update_display_name()
user:update_avatar_url()
client:logout()