From 2dc5c852cf233fbcf1634ccce767c4e97b425705 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Fri, 13 Nov 2020 22:48:11 -0800 Subject: [PATCH] modules/m_command: Simplify command string preserved in input property. --- modules/m_command.cc | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/modules/m_command.cc b/modules/m_command.cc index d8f0fec44..ae414b506 100644 --- a/modules/m_command.cc +++ b/modules/m_command.cc @@ -77,23 +77,28 @@ try unquote(content.at("room_id")) }; - const json::string &input + const json::string &input_ { content.at("body") }; - if(!startswith(input, "\\\\")) + if(!startswith(input_, "\\\\")) return; // View of the command string without prefix - string_view cmd{input}; - cmd = lstrip(cmd, "\\\\"); + string_view input{input_}; + input = lstrip(input, "\\\\"); // Determine if there's a bang after the prefix; if so the response's // sender will be the user, and will be broadcast publicly to the room. // Otherwise the response comes from the server and is only visible in // the user's timeline. - const bool public_response(startswith(cmd, '!')); + const bool public_response + { + startswith(input, '!') + }; + + string_view cmd{input}; cmd = lstrip(cmd, '!'); log::debug