0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-28 16:34:13 +01:00

modules/console: Add room messages cmd.

This commit is contained in:
Jason Volk 2018-09-04 23:24:56 -07:00
parent e48750e6aa
commit 893b633578

View file

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