mirror of
https://github.com/matrix-construct/construct
synced 2024-11-26 00:32:35 +01:00
modules/console: Add room messages cmd.
This commit is contained in:
parent
e48750e6aa
commit
893b633578
1 changed files with 46 additions and 0 deletions
|
@ -5241,6 +5241,52 @@ console_cmd__room__events(opt &out, const string_view &line)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
console_cmd__room__messages(opt &out, const string_view &line)
|
||||
{
|
||||
const params param{line, " ",
|
||||
{
|
||||
"room_id", "depth|-limit", "order", "limit"
|
||||
}};
|
||||
|
||||
const auto &room_id
|
||||
{
|
||||
m::room_id(param.at(0))
|
||||
};
|
||||
|
||||
const int64_t depth
|
||||
{
|
||||
param.at<int64_t>(1, std::numeric_limits<int64_t>::max())
|
||||
};
|
||||
|
||||
const char order
|
||||
{
|
||||
param.at(2, "b"_sv).at(0)
|
||||
};
|
||||
|
||||
ssize_t limit
|
||||
{
|
||||
depth < 0?
|
||||
std::abs(depth):
|
||||
param.at(3, ssize_t(32))
|
||||
};
|
||||
|
||||
const m::room room
|
||||
{
|
||||
room_id
|
||||
};
|
||||
|
||||
m::room::messages it{room};
|
||||
if(depth >= 0 && depth < std::numeric_limits<int64_t>::max())
|
||||
it.seek(depth);
|
||||
|
||||
for(; it && limit >= 0; order == 'b'? --it : ++it, --limit)
|
||||
out << pretty_msgline(*it)
|
||||
<< std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
console_cmd__room__roots(opt &out, const string_view &line)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue