summaryrefslogtreecommitdiff
path: root/src/plugins/irc/irc-command.c
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2023-01-31 18:37:27 +0100
committerSébastien Helleu <flashcode@flashtux.org>2023-01-31 18:37:27 +0100
commit9f5ca3b1a9fbf891d7450d6191c6f16818ea9ebe (patch)
treec2475f87357351e1856ec78d8cd20a59cdbb11b4 /src/plugins/irc/irc-command.c
parent4c0d2ab3b16c3ffa99b063671fa3fb0f4ef78d68 (diff)
downloadweechat-9f5ca3b1a9fbf891d7450d6191c6f16818ea9ebe.zip
irc: add command `/knock` (closes #7)
Diffstat (limited to 'src/plugins/irc/irc-command.c')
-rw-r--r--src/plugins/irc/irc-command.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/plugins/irc/irc-command.c b/src/plugins/irc/irc-command.c
index 1620953ac..c48a2fbc5 100644
--- a/src/plugins/irc/irc-command.c
+++ b/src/plugins/irc/irc-command.c
@@ -3258,6 +3258,36 @@ IRC_COMMAND_CALLBACK(kill)
}
/*
+ * Callback for command "/knock": sends a notice to an invitation-only channel,
+ * requesting an invite.
+ */
+
+IRC_COMMAND_CALLBACK(knock)
+{
+ IRC_BUFFER_GET_SERVER(buffer);
+ IRC_COMMAND_CHECK_SERVER("knock", 1, 1);
+
+ /* make C compiler happy */
+ (void) pointer;
+ (void) data;
+
+ WEECHAT_COMMAND_MIN_ARGS(2, "");
+
+ if (argc < 3)
+ {
+ irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
+ "KNOCK %s", argv[1]);
+ }
+ else
+ {
+ irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
+ "KNOCK %s :%s", argv[1], argv_eol[2]);
+ }
+
+ return WEECHAT_RC_OK;
+}
+
+/*
* Callback for command "/links": lists all server names which are known by the
* server answering the query.
*/
@@ -7148,6 +7178,14 @@ irc_command_init ()
"reason: reason"),
"%(nicks) %-", &irc_command_kill, NULL, NULL);
weechat_hook_command (
+ "knock",
+ N_("send a notice to an invitation-only channel, requesting an invite"),
+ N_("<channel> [<message>]"),
+ N_("channel: channel name\n"
+ "message: message to send"),
+ "%(irc_channels)",
+ &irc_command_knock, NULL, NULL);
+ weechat_hook_command (
"links",
N_("list all server names which are known by the server answering the "
"query"),