view irccdctl/command-server-notice.cpp @ 12:960e03040ddf

Docs: add missing highlight.js and make pre in white
author David Demelier <markand@malikania.fr>
date Wed, 10 Feb 2016 14:18:15 +0100
parents 1158cffe5a5e
children
line wrap: on
line source

/*
 * command-server-notice.cpp -- implementation of irccdctl server-notice
 *
 * 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 "command-server-notice.h"

namespace irccd {

namespace command {

void ServerNotice::usage(Irccdctl &) const
{
	log::warning() << "usage: " << sys::programName() << " server-notice server target message\n\n";
	log::warning() << "Send a private notice to the specified target.\n\n";
	log::warning() << "Example:\n";
	log::warning() << "\t" << sys::programName() << " server-notice freenode jean \"I know you are here.\"" << std::endl;
}

void ServerNotice::exec(Irccdctl &ctl, const std::vector<std::string> &args) const
{
	if (args.size() < 3)
		throw std::invalid_argument("server-notice requires 3 arguments");

	ctl.connection().send(json::object({
		{ "command",	"server-notice"	},
		{ "server",	args[0]		},
		{ "target",	args[1]		},
		{ "message",	args[2]		}
	}).toJson(0));

	ctl.connection().verify("server-notice");
}

} // !command

} // !irccd