view irccdctl/cli-server-message.cpp @ 337:492bd7c9ecc4

Irccdctl: bring back server-part
author David Demelier <markand@malikania.fr>
date Thu, 10 Nov 2016 13:10:27 +0100
parents c99877913565
children
line wrap: on
line source

/*
 * cli-server-message.cpp -- implementation of irccdctl server-message
 *
 * 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-message.hpp"

namespace irccd {

namespace cli {

ServerMessageCli::ServerMessageCli()
    : Cli("server-message",
          "send a message",
          "server-message server target message",
          "Send a message to the specified target or channel.\n\n"
          "Example:\n"
          "\tirccdctl server-message freenode #staff \"Hello from irccd\"")
{
}

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

    check(request(irccdctl, {
        { "server",     args[0] },
        { "target",     args[1] },
        { "message",    args[2] }
    }));
}

} // !cli

} // !irccd