Mercurial > irccd
comparison irccdctl/command-server-kick.cpp @ 0:1158cffe5a5e
Initial import
author | David Demelier <markand@malikania.fr> |
---|---|
date | Mon, 08 Feb 2016 16:43:14 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:1158cffe5a5e |
---|---|
1 /* | |
2 * command-server-kick.cpp -- implementation of irccdctl server-kick | |
3 * | |
4 * Copyright (c) 2013-2016 David Demelier <markand@malikania.fr> | |
5 * | |
6 * Permission to use, copy, modify, and/or distribute this software for any | |
7 * purpose with or without fee is hereby granted, provided that the above | |
8 * copyright notice and this permission notice appear in all copies. | |
9 * | |
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
17 */ | |
18 | |
19 #include "command-server-kick.h" | |
20 | |
21 namespace irccd { | |
22 | |
23 namespace command { | |
24 | |
25 void ServerKick::usage(Irccdctl &) const | |
26 { | |
27 log::warning() << "usage: " << sys::programName() << " server-kick server target channel [reason]\n\n"; | |
28 log::warning() << "Kick the specified target from the channel, the reason is optional.\n\n"; | |
29 log::warning() << "Example:\n"; | |
30 log::warning() << "\t" << sys::programName() << " server-kick freenode jean #staff \"Stop flooding\"" << std::endl; | |
31 } | |
32 | |
33 void ServerKick::exec(Irccdctl &ctl, const std::vector<std::string> &args) const | |
34 { | |
35 if (args.size() < 3) | |
36 throw std::invalid_argument("server-kick requires at least 3 arguments "); | |
37 | |
38 json::Value object = json::object({ | |
39 { "command", "server-kick" }, | |
40 { "server", args[0] }, | |
41 { "target", args[1] }, | |
42 { "channel", args[2] } | |
43 }); | |
44 | |
45 if (args.size() == 4) | |
46 object.insert("reason", args[3]); | |
47 | |
48 ctl.connection().send(object.toJson(0)); | |
49 ctl.connection().verify("server-kick"); | |
50 } | |
51 | |
52 } // !command | |
53 | |
54 } // !irccd |