Mercurial > irccd
changeset 330:a167353ab89e
Irccdctl: bring back server-kick
author | David Demelier <markand@malikania.fr> |
---|---|
date | Tue, 08 Nov 2016 22:31:08 +0100 |
parents | bc7f65897762 |
children | 4f1fb35ef30e |
files | irccdctl/cli-server-kick.cpp irccdctl/cli-server-kick.hpp |
diffstat | 2 files changed, 107 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/irccdctl/cli-server-kick.cpp Tue Nov 08 22:31:08 2016 +0100 @@ -0,0 +1,54 @@ +/* + * cli-server-kick.cpp -- implementation of irccdctl server-kick + * + * Copyright (c) 2013-2016 David Demelier <markand@malikania.fr> + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include "cli-server-kick.hpp" + +namespace irccd { + +namespace cli { + +ServerKickCli::ServerKickCli() + : Cli("server-kick", + "kick someone from a channel", + "server-kick server target channel [reason]", + "Kick the specified target from the channel, the reason is optional.\n\n" + "Example:\n" + "\tirccdctl server-kick freenode jean #staff \"Stop flooding\"") +{ +} + +void ServerKickCli::exec(Irccdctl &irccdctl, const std::vector<std::string> &args) +{ + if (args.size() < 3) + throw std::invalid_argument("server-kick requires at least 3 arguments "); + + auto object = nlohmann::json::object({ + { "server", args[0] }, + { "target", args[1] }, + { "channel", args[2] } + }); + + if (args.size() == 4) + object["reason"] = args[3]; + + check(request(irccdctl, object)); +} + +} // !cli + +} // !irccd
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/irccdctl/cli-server-kick.hpp Tue Nov 08 22:31:08 2016 +0100 @@ -0,0 +1,53 @@ +/* + * cli-server-kick.hpp -- implementation of irccdctl server-kick + * + * Copyright (c) 2013-2016 David Demelier <markand@malikania.fr> + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef IRCCDCTL_SERVER_KICK_HPP +#define IRCCDCTL_SERVER_KICK_HPP + +/** + * \file cli-server-kick.hpp + * \brief Implementation of irccdctl server-kick. + */ + +#include "cli.hpp" + +namespace irccd { + +namespace cli { + +/** + * \brief Implementation of irccdctl server-kick. + */ +class ServerKickCli : public Cli { +public: + /** + * Default constructor. + */ + ServerKickCli(); + + /** + * \copydoc Cli::exec + */ + void exec(Irccdctl &irccdctl, const std::vector<std::string> &args) override; +}; + +} // !cli + +} // !irccd + +#endif // !IRCCDCTL_SERVER_KICK_HPP