changeset 332:9d09b8d882f3

Irccdctl: bring back server-me (and fix server side)
author David Demelier <markand@malikania.fr>
date Wed, 09 Nov 2016 13:03:29 +0100
parents 4f1fb35ef30e
children c99877913565
files irccdctl/cli-server-me.cpp irccdctl/cli-server-me.hpp libirccd/irccd/cmd-server-me.cpp
diffstat 3 files changed, 103 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/irccdctl/cli-server-me.cpp	Wed Nov 09 13:03:29 2016 +0100
@@ -0,0 +1,49 @@
+/*
+ * cli-server-me.cpp -- implementation of irccdctl server-me
+ *
+ * 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-me.hpp"
+
+namespace irccd {
+
+namespace cli {
+
+ServerMeCli::ServerMeCli()
+    : Cli("server-me",
+          "send an action emote",
+          "server-me server target message",
+          "Send an action emote.\n\n"
+          "Example:\n"
+          "\tirccdctl server-me freenode #staff \"going back soon\"")
+{
+}
+
+void ServerMeCli::exec(Irccdctl &irccdctl, const std::vector<std::string> &args)
+{
+    if (args.size() < 3)
+        throw std::runtime_error("server-me requires 3 arguments");
+
+    check(request(irccdctl, {
+        { "server",     args[0]     },
+        { "target",     args[1]     },
+        { "message",    args[2]     }
+    }));
+}
+
+} // !cli
+
+} // !irccd
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/irccdctl/cli-server-me.hpp	Wed Nov 09 13:03:29 2016 +0100
@@ -0,0 +1,53 @@
+/*
+ * cli-server-me.hpp -- implementation of irccdctl server-me
+ *
+ * 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_CLI_SERVER_ME_HPP
+#define IRCCDCTL_CLI_SERVER_ME_HPP
+
+/**
+ * \file cli-server-me.hpp
+ * \brief Implementation of irccdctl server-me.
+ */
+
+#include "cli.hpp"
+
+namespace irccd {
+
+namespace cli {
+
+/**
+ * \brief Implementation of irccdctl server-me.
+ */
+class ServerMeCli : public Cli {
+public:
+    /**
+     * Default constructor.
+     */
+    ServerMeCli();
+
+    /**
+     * \copydoc Command::exec
+     */
+    void exec(Irccdctl &irccdctl, const std::vector<std::string> &args) override;
+};
+
+} // !cli
+
+} // !irccd
+
+#endif // !_IRCCDCTL_COMMAND_SERVER_ME_H_
--- a/libirccd/irccd/cmd-server-me.cpp	Tue Nov 08 22:39:55 2016 +0100
+++ b/libirccd/irccd/cmd-server-me.cpp	Wed Nov 09 13:03:29 2016 +0100
@@ -38,7 +38,7 @@
         util::json::requireString(args, "target"),
         util::json::requireString(args, "message")
     );
-    client.success("server-message");
+    client.success("server-me");
 }
 
 } // !command