diff options
author | Jonas Smedegaard <dr@jones.dk> | 2016-12-21 21:25:09 +0100 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2016-12-21 21:25:09 +0100 |
commit | f820d86aadb7a5473bcc0a0a3669732ab0182555 (patch) | |
tree | a6a673c444ea3df75fe0a5d53e905030c2f617ce /louloulibs/xmpp/adhoc_commands_handler.cpp | |
parent | eda4b75b1cff83336e87da90efca9fd6b4ced2c7 (diff) | |
parent | 9634cdaba2e5d2343fcbc1f07264d55609640273 (diff) | |
download | biboumi-upstream/4.0.tar.gz biboumi-upstream/4.0.tar.bz2 biboumi-upstream/4.0.tar.xz biboumi-upstream/4.0.zip |
New upstream version 4.0upstream/4.0
Diffstat (limited to 'louloulibs/xmpp/adhoc_commands_handler.cpp')
-rw-r--r-- | louloulibs/xmpp/adhoc_commands_handler.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/louloulibs/xmpp/adhoc_commands_handler.cpp b/louloulibs/xmpp/adhoc_commands_handler.cpp index 17c4e67..540cac0 100644 --- a/louloulibs/xmpp/adhoc_commands_handler.cpp +++ b/louloulibs/xmpp/adhoc_commands_handler.cpp @@ -15,9 +15,12 @@ const std::map<const std::string, const AdhocCommand>& AdhocCommandsHandler::get return this->commands; } -std::map<const std::string, const AdhocCommand>& AdhocCommandsHandler::get_commands() +void AdhocCommandsHandler::add_command(std::string name, AdhocCommand command) { - return this->commands; + const auto found = this->commands.find(name); + if (found != this->commands.end()) + throw std::runtime_error("Trying to add an ad-hoc command that already exist: "s + name); + this->commands.emplace(std::make_pair(std::move(name), std::move(command))); } XmlNode AdhocCommandsHandler::handle_request(const std::string& executor_jid, const std::string& to, XmlNode command_node) |