mirror of
https://github.com/matrix-construct/construct
synced 2024-11-19 08:21:09 +01:00
modules/console: Improve room get (event) cmd; use params; add output opts.
This commit is contained in:
parent
b497ce35da
commit
d7b3a56882
1 changed files with 22 additions and 6 deletions
|
@ -1642,28 +1642,44 @@ console_cmd__room__messages(opt &out, const string_view &line)
|
||||||
bool
|
bool
|
||||||
console_cmd__room__get(opt &out, const string_view &line)
|
console_cmd__room__get(opt &out, const string_view &line)
|
||||||
{
|
{
|
||||||
|
const params param{line, " ",
|
||||||
|
{
|
||||||
|
"room_id", "type", "state_key", "args"
|
||||||
|
}};
|
||||||
|
|
||||||
const auto &room_id
|
const auto &room_id
|
||||||
{
|
{
|
||||||
m::room_id(token(line, ' ', 0))
|
m::room_id(param.at(0))
|
||||||
};
|
};
|
||||||
|
|
||||||
const string_view type
|
const string_view type
|
||||||
{
|
{
|
||||||
token(line, ' ', 1)
|
param.at(1)
|
||||||
};
|
};
|
||||||
|
|
||||||
const string_view state_key
|
const string_view state_key
|
||||||
{
|
{
|
||||||
token(line, ' ', 2)
|
param.at(2)
|
||||||
};
|
};
|
||||||
|
|
||||||
const m::room room
|
const string_view arg
|
||||||
|
{
|
||||||
|
param[3]
|
||||||
|
};
|
||||||
|
|
||||||
|
const m::room::state room
|
||||||
{
|
{
|
||||||
room_id
|
room_id
|
||||||
};
|
};
|
||||||
|
|
||||||
room.get(type, state_key, [&out](const m::event &event)
|
room.get(type, state_key, [&out, &arg]
|
||||||
|
(const m::event &event)
|
||||||
{
|
{
|
||||||
|
if(has(arg, "raw"))
|
||||||
|
out << event << std::endl;
|
||||||
|
else if(has(arg, "content"))
|
||||||
|
out << json::get<"content"_>(event) << std::endl;
|
||||||
|
else
|
||||||
out << pretty(event) << std::endl;
|
out << pretty(event) << std::endl;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue