mirror of
https://github.com/matrix-construct/construct
synced 2024-09-28 11:48:54 +02:00
modules/console: Add room type count cmd.
This commit is contained in:
parent
8e79fda31b
commit
c97cc4ecb7
1 changed files with 55 additions and 0 deletions
|
@ -11280,6 +11280,61 @@ console_cmd__room__type(opt &out, const string_view &line)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
console_cmd__room__type__count(opt &out, const string_view &line)
|
||||
{
|
||||
const params param{line, " ",
|
||||
{
|
||||
"room_id", "type", "start_depth", "end_depth"
|
||||
}};
|
||||
|
||||
const auto &room_id
|
||||
{
|
||||
m::room_id(param.at("room_id"))
|
||||
};
|
||||
|
||||
const auto &type
|
||||
{
|
||||
param["type"]
|
||||
};
|
||||
|
||||
const uint64_t start_depth
|
||||
{
|
||||
param.at<uint64_t>(2, -1UL)
|
||||
};
|
||||
|
||||
const int64_t end_depth
|
||||
{
|
||||
param.at<int64_t>(3, -1L)
|
||||
};
|
||||
|
||||
const bool prefix_match
|
||||
{
|
||||
endswith(type, "...")
|
||||
};
|
||||
|
||||
const m::room::type events
|
||||
{
|
||||
room_id,
|
||||
rstrip(type, "..."),
|
||||
{ start_depth, end_depth },
|
||||
prefix_match
|
||||
};
|
||||
|
||||
size_t ret(0);
|
||||
events.for_each([&ret]
|
||||
(const string_view &type, const uint64_t &depth, const m::event::idx &event_idx)
|
||||
{
|
||||
++ret;
|
||||
return true;
|
||||
});
|
||||
|
||||
out
|
||||
<< ret
|
||||
<< std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
console_cmd__room__get(opt &out, const string_view &line)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue