diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2015-06-18 22:30:18 +0200 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2015-06-18 22:35:14 +0200 |
commit | 8eb31ad2e11038a17f66c84f48befda6b3b807d2 (patch) | |
tree | 45b4722a0a4f8d669a5e9d8d31631335dd4d7203 /degesch.c | |
parent | bdad7bd7c205bd8d2e1b067d89be88b68b9da34f (diff) | |
download | xK-8eb31ad2e11038a17f66c84f48befda6b3b807d2.tar.gz xK-8eb31ad2e11038a17f66c84f48befda6b3b807d2.tar.xz xK-8eb31ad2e11038a17f66c84f48befda6b3b807d2.zip |
degesch: fix /invite
Diffstat (limited to 'degesch.c')
-rw-r--r-- | degesch.c | 29 |
1 files changed, 22 insertions, 7 deletions
@@ -6502,18 +6502,33 @@ handle_command_invite (struct app_context *ctx, char *arguments) if (!server_command_check (ctx, "invite", true)) return true; - // XXX: the order of arguments should probably be reverse struct server *s = ctx->current_buffer->server; - char *channel_name = try_get_channel (ctx, &arguments); + + struct str_vector v; + str_vector_init (&v); + split_str_ignore_empty (arguments, ' ', &v); + + char *channel_name = NULL; + size_t last = v.len - 1; + if (v.len && irc_is_channel (s, v.vector[last])) + channel_name = str_vector_steal (&v, last); + else if (ctx->current_buffer->type == BUFFER_CHANNEL) + channel_name = xstrdup (ctx->current_buffer->channel->name); + + bool result = true; if (!channel_name) buffer_send_error (ctx, ctx->current_buffer, "%s: %s", "Can't invite", "no channel name given and this buffer is not a channel"); - else if (*arguments) - irc_send (s, "INVITE %s %s", arguments, channel_name); + else if (v.len) + for (size_t i = 0; i < v.len; i++) + irc_send (s, "INVITE %s %s", v.vector[i], channel_name); else - return false; - return true; + result = false; + + str_vector_free (&v); + free (channel_name); + return result; } static bool @@ -6807,7 +6822,7 @@ g_command_handlers[] = "[<channel>] <mask>...", handle_command_unban }, { "invite", "Invite user to channel", - "[<channel>] <user>", + "<user>... [<channel>]", handle_command_invite }, { "connect", "Connect to the server", |