From 9f5ca3b1a9fbf891d7450d6191c6f16818ea9ebe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Tue, 31 Jan 2023 18:37:27 +0100 Subject: irc: add command `/knock` (closes #7) --- src/plugins/irc/irc-command.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'src/plugins/irc/irc-command.c') 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 @@ -3257,6 +3257,36 @@ IRC_COMMAND_CALLBACK(kill) return WEECHAT_RC_OK; } +/* + * 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. @@ -7147,6 +7177,14 @@ irc_command_init () N_(" nick: nick\n" "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_(" []"), + 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 " -- cgit v1.2.3