0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-15 22:41:12 +01:00

modules/console: Add console cmd to get random origin.

This commit is contained in:
Jason Volk 2018-08-22 17:44:24 -07:00
parent 8f21451d68
commit 18b591c298

View file

@ -4671,6 +4671,49 @@ console_cmd__room__origins(opt &out, const string_view &line)
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
console_cmd__room__state(opt &out, const string_view &line)
{