summaryrefslogtreecommitdiff
path: root/degesch.c
diff options
context:
space:
mode:
Diffstat (limited to 'degesch.c')
-rw-r--r--degesch.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/degesch.c b/degesch.c
index 4bdaaba..e525e3d 100644
--- a/degesch.c
+++ b/degesch.c
@@ -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",