changeset 355:ace71e2b8e2a

Irccd: add server-topic support again
author David Demelier <markand@malikania.fr>
date Mon, 14 Nov 2016 21:40:10 +0100
parents 6b0e202ed9a0
children 6fa04fe563c6
files irccd/main.cpp irccdctl/cli.cpp irccdctl/cli.hpp irccdctl/main.cpp
diffstat 4 files changed, 50 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/irccd/main.cpp	Mon Nov 14 21:02:44 2016 +0100
+++ b/irccd/main.cpp	Mon Nov 14 21:40:10 2016 +0100
@@ -295,6 +295,7 @@
     instance->commands().add(std::make_unique<command::ServerNoticeCommand>());
     instance->commands().add(std::make_unique<command::ServerPartCommand>());
     instance->commands().add(std::make_unique<command::ServerReconnectCommand>());
+    instance->commands().add(std::make_unique<command::ServerTopicCommand>());
 
     // Load Javascript API and plugin loader.
 #if defined(WITH_JS)
--- a/irccdctl/cli.cpp	Mon Nov 14 21:02:44 2016 +0100
+++ b/irccdctl/cli.cpp	Mon Nov 14 21:40:10 2016 +0100
@@ -803,6 +803,33 @@
     check(request(irccdctl, object));
 }
 
+/*
+ * ServerTopicCli.
+ * ------------------------------------------------------------------
+ */
+
+ServerTopicCli::ServerTopicCli()
+    : Cli("server-topic",
+          "change channel topic",
+          "server-topic server channel topic",
+          "Change the topic of the specified channel.\n\n"
+          "Example:\n"
+          "\tirccdctl server-topic freenode #wmfs \"This is the best channel\"")
+{
+}
+
+void ServerTopicCli::exec(Irccdctl &irccdctl, const std::vector<std::string> &args)
+{
+    if (args.size() < 3)
+        throw std::invalid_argument("server-topic requires 3 arguments");
+
+    check(request(irccdctl, {
+        { "server",     args[0] },
+        { "channel",    args[1] },
+        { "topic",      args[2] }
+    }));
+}
+
 } // !cli
 
 } // !irccd
--- a/irccdctl/cli.hpp	Mon Nov 14 21:02:44 2016 +0100
+++ b/irccdctl/cli.hpp	Mon Nov 14 21:40:10 2016 +0100
@@ -564,6 +564,27 @@
     void exec(Irccdctl &irccdctl, const std::vector<std::string> &args) override;
 };
 
+/*
+ * ServerTopicCli.
+ * ------------------------------------------------------------------
+ */
+
+/**
+ * \brief Implementation of irccdctl server-topic.
+ */
+class ServerTopicCli : public Cli {
+public:
+    /**
+     * Default constructor.
+     */
+    ServerTopicCli();
+
+    /**
+     * \copydoc Cli::exec
+     */
+    void exec(Irccdctl &client, const std::vector<std::string> &args) override;
+};
+
 } // !cli
 
 } // !irccd
--- a/irccdctl/main.cpp	Mon Nov 14 21:02:44 2016 +0100
+++ b/irccdctl/main.cpp	Mon Nov 14 21:40:10 2016 +0100
@@ -507,6 +507,7 @@
     commands.push_back(std::make_unique<cli::ServerNoticeCli>());
     commands.push_back(std::make_unique<cli::ServerPartCli>());
     commands.push_back(std::make_unique<cli::ServerReconnectCli>());
+    commands.push_back(std::make_unique<cli::ServerTopicCli>());
 }
 
 } // !namespace