From 9830a4347ba659b690ab1638be951dae89cbf4f5 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Sun, 25 Mar 2018 18:12:17 -0700 Subject: [PATCH] modules/s_control: Plug the console into the control room. --- modules/s_control.cc | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/modules/s_control.cc b/modules/s_control.cc index ef41fd765..d15985fde 100644 --- a/modules/s_control.cc +++ b/modules/s_control.cc @@ -38,7 +38,6 @@ static void _conf_set(const m::event &event, const string_view &key, const string_view &val) -try { const auto &sender { @@ -65,15 +64,10 @@ try kvbuf, "[%s] %s = %s", string_view{event_id}, key, val }); } -catch(const std::exception &e) -{ - notice(control_room, e.what()); -} static void _conf_get(const m::event &event, const string_view &key) -try { using closure = std::function; using prototype = void (const string_view &key, @@ -94,14 +88,9 @@ try }); }); } -catch(const std::exception &e) -{ - notice(control_room, e.what()); -} static void _conf_list(const m::event &event) -try { char val[512]; std::stringstream ss; @@ -114,10 +103,6 @@ try msghtml(control_room, m::me.user_id, ss.str()); } -catch(const std::exception &e) -{ - notice(control_room, e.what()); -} static void _cmd__conf(const m::event &event, @@ -157,7 +142,7 @@ _cmd__die(const m::event &event, static void command_control(const m::event &event) -noexcept +noexcept try { const auto &content { @@ -182,6 +167,30 @@ noexcept case hash("die"): return _cmd__die(event, tokens_after(body, ' ', 0)); } + + const ircd::module console_module + { + "console" + }; + + const mods::import command + { + *console_module, "console_command" + }; + + std::string out; + command(body, out); + out = replace(std::move(out), '\n', "
"); //TODO: X + std::stringstream ss; + ss << "
"
+	   << out
+	   << "
"; + + msghtml(control_room, m::me.user_id, ss.str()); +} +catch(const std::exception &e) +{ + notice(control_room, e.what()); } const m::hook