degesch: cleanup
This commit is contained in:
parent
f09313f08b
commit
87a44fb807
46
degesch.c
46
degesch.c
@ -6320,48 +6320,28 @@ handle_command_mode (struct app_context *ctx, char *arguments)
|
|||||||
|
|
||||||
// Channel names prefixed by "+" collide with mode strings,
|
// Channel names prefixed by "+" collide with mode strings,
|
||||||
// so we just disallow specifying these channels
|
// so we just disallow specifying these channels
|
||||||
char *channel_name = NULL;
|
char *target = NULL;
|
||||||
char *nickname = NULL;
|
if (strchr ("+-\0", *arguments)
|
||||||
|
|| !(target = maybe_cut_word (&arguments, validate_channel_name, s))
|
||||||
if (*arguments != '+')
|
|| !(target = cut_word (&arguments)))
|
||||||
channel_name = maybe_cut_word (&arguments, validate_channel_name, s);
|
|
||||||
if (!channel_name
|
|
||||||
&& !strchr ("+-\0", *arguments))
|
|
||||||
nickname = cut_word (&arguments);
|
|
||||||
|
|
||||||
if (!channel_name
|
|
||||||
&& !nickname)
|
|
||||||
{
|
{
|
||||||
if (ctx->current_buffer->type == BUFFER_CHANNEL)
|
if (ctx->current_buffer->type == BUFFER_CHANNEL)
|
||||||
channel_name = ctx->current_buffer->channel->name;
|
target = ctx->current_buffer->channel->name;
|
||||||
if (ctx->current_buffer->type == BUFFER_PM)
|
if (ctx->current_buffer->type == BUFFER_PM)
|
||||||
nickname = ctx->current_buffer->user->nickname;
|
target = ctx->current_buffer->user->nickname;
|
||||||
if (ctx->current_buffer->type == BUFFER_SERVER)
|
if (ctx->current_buffer->type == BUFFER_SERVER)
|
||||||
nickname = ctx->current_buffer->server->irc_user->nickname;
|
target = ctx->current_buffer->server->irc_user->nickname;
|
||||||
}
|
|
||||||
|
|
||||||
if (channel_name)
|
|
||||||
{
|
|
||||||
if (*arguments)
|
|
||||||
// XXX: split as necessary using irc_max_modes?
|
|
||||||
irc_send (s, "MODE %s %s", channel_name, arguments);
|
|
||||||
else
|
|
||||||
irc_send (s, "MODE %s", channel_name);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nickname)
|
|
||||||
{
|
|
||||||
if (*arguments)
|
|
||||||
irc_send (s, "MODE %s %s", nickname, arguments);
|
|
||||||
else
|
|
||||||
irc_send (s, "MODE %s", nickname);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!target)
|
||||||
buffer_send_error (ctx, ctx->current_buffer,
|
buffer_send_error (ctx, ctx->current_buffer,
|
||||||
"%s: %s", "Can't change mode",
|
"%s: %s", "Can't change mode",
|
||||||
"no target given and this buffer is neither a PM nor a channel");
|
"no target given and this buffer is neither a PM nor a channel");
|
||||||
|
else if (*arguments)
|
||||||
|
// XXX: split channel mode params as necessary using irc_max_modes?
|
||||||
|
irc_send (s, "MODE %s %s", target, arguments);
|
||||||
|
else
|
||||||
|
irc_send (s, "MODE %s", target);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user