mirror of
https://github.com/matrix-construct/construct
synced 2024-10-04 14:48:56 +02:00
modules/console: Add command to iterate messages forward and backward with seek to depth.
This commit is contained in:
parent
26d25c0db0
commit
5a73e631a6
1 changed files with 37 additions and 0 deletions
|
@ -774,6 +774,7 @@ console_cmd__exec_file(const string_view &line)
|
||||||
// room
|
// room
|
||||||
//
|
//
|
||||||
|
|
||||||
|
static bool console_cmd__room__messages(const string_view &line);
|
||||||
static bool console_cmd__room__members(const string_view &line);
|
static bool console_cmd__room__members(const string_view &line);
|
||||||
static bool console_cmd__room__state(const string_view &line);
|
static bool console_cmd__room__state(const string_view &line);
|
||||||
static bool console_cmd__room__depth(const string_view &line);
|
static bool console_cmd__room__depth(const string_view &line);
|
||||||
|
@ -800,6 +801,9 @@ console_cmd__room(const string_view &line)
|
||||||
|
|
||||||
case hash("members"):
|
case hash("members"):
|
||||||
return console_cmd__room__members(args);
|
return console_cmd__room__members(args);
|
||||||
|
|
||||||
|
case hash("messages"):
|
||||||
|
return console_cmd__room__messages(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -890,3 +894,36 @@ console_cmd__room__state(const string_view &line)
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
console_cmd__room__messages(const string_view &line)
|
||||||
|
{
|
||||||
|
const m::room::id room_id
|
||||||
|
{
|
||||||
|
token(line, ' ', 0)
|
||||||
|
};
|
||||||
|
|
||||||
|
const int64_t depth
|
||||||
|
{
|
||||||
|
token_count(line, ' ') > 1? lex_cast<int64_t>(token(line, ' ', 1)) : -1
|
||||||
|
};
|
||||||
|
|
||||||
|
const char order
|
||||||
|
{
|
||||||
|
token_count(line, ' ') > 2? token(line, ' ', 2).at(0) : 'b'
|
||||||
|
};
|
||||||
|
|
||||||
|
const m::room room
|
||||||
|
{
|
||||||
|
room_id
|
||||||
|
};
|
||||||
|
|
||||||
|
m::room::messages it{room};
|
||||||
|
if(depth >= 0)
|
||||||
|
it.seek(depth);
|
||||||
|
|
||||||
|
for(; it; order == 'b'? --it : ++it)
|
||||||
|
out << pretty_oneline(*it) << std::endl;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue