mirror of
https://github.com/matrix-construct/construct
synced 2024-09-27 19:28:52 +02:00
modules/console: Add console cmd to get random origin.
This commit is contained in:
parent
8f21451d68
commit
18b591c298
1 changed files with 43 additions and 0 deletions
|
@ -4671,6 +4671,49 @@ console_cmd__room__origins(opt &out, const string_view &line)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
console_cmd__room__origins__random(opt &out, const string_view &line)
|
||||||
|
{
|
||||||
|
using prototype = string_view (const m::room &,
|
||||||
|
const mutable_buffer &,
|
||||||
|
const std::function<bool (const string_view &)> &);
|
||||||
|
|
||||||
|
static m::import<prototype> random_origin
|
||||||
|
{
|
||||||
|
"m_room", "random_origin"
|
||||||
|
};
|
||||||
|
|
||||||
|
const params param{line, " ",
|
||||||
|
{
|
||||||
|
"room_id"
|
||||||
|
}};
|
||||||
|
|
||||||
|
const auto &room_id
|
||||||
|
{
|
||||||
|
m::room_id(param.at("room_id"))
|
||||||
|
};
|
||||||
|
|
||||||
|
const m::room room
|
||||||
|
{
|
||||||
|
room_id
|
||||||
|
};
|
||||||
|
|
||||||
|
char buf[256];
|
||||||
|
const string_view origin
|
||||||
|
{
|
||||||
|
random_origin(room, buf, nullptr)
|
||||||
|
};
|
||||||
|
|
||||||
|
if(!origin)
|
||||||
|
throw m::NOT_FOUND
|
||||||
|
{
|
||||||
|
"No origins for this room."
|
||||||
|
};
|
||||||
|
|
||||||
|
out << origin << std::endl;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
console_cmd__room__state(opt &out, const string_view &line)
|
console_cmd__room__state(opt &out, const string_view &line)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue