From 18b591c298bce1ef70b76548e894ab300a5c7e30 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Wed, 22 Aug 2018 17:44:24 -0700 Subject: [PATCH] modules/console: Add console cmd to get random origin. --- modules/console.cc | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/modules/console.cc b/modules/console.cc index 5849a2843..520f6b7ec 100644 --- a/modules/console.cc +++ b/modules/console.cc @@ -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 &); + + static m::import 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) {