degesch: don't send PART on /close when not joined
This commit is contained in:
parent
aa77bc41d0
commit
955b3728a3
19
degesch.c
19
degesch.c
|
@ -3308,6 +3308,13 @@ irc_get_channel_user_prefix (struct server *s,
|
|||
str_append_c (output, channel_user->prefixes.str[0]);
|
||||
}
|
||||
|
||||
static bool
|
||||
irc_channel_is_joined (struct channel *channel)
|
||||
{
|
||||
// TODO: find a better way of checking if we're on a channel
|
||||
return !!channel->users;
|
||||
}
|
||||
|
||||
// Note that this eats the user reference
|
||||
static void
|
||||
irc_channel_link_user (struct channel *channel, struct user *user,
|
||||
|
@ -7043,7 +7050,8 @@ handle_buffer_close (struct app_context *ctx, struct handler_args *a)
|
|||
else
|
||||
{
|
||||
// The user would be unable to recreate the buffer otherwise
|
||||
if (buffer->type == BUFFER_CHANNEL)
|
||||
if (buffer->type == BUFFER_CHANNEL
|
||||
&& irc_channel_is_joined (buffer->channel))
|
||||
part_channel (buffer->server, buffer->channel->name, "");
|
||||
buffer_remove_safe (ctx, buffer);
|
||||
}
|
||||
|
@ -7468,8 +7476,7 @@ handle_command_join (struct handler_args *a)
|
|||
else if (a->buffer->type != BUFFER_CHANNEL)
|
||||
log_server_error (a->s, a->buffer, "#s: #s", "Can't join",
|
||||
"no channel name given and this buffer is not a channel");
|
||||
// TODO: have a better way of checking if we're on the channel
|
||||
else if (a->buffer->channel->users)
|
||||
else if (irc_channel_is_joined (a->buffer->channel))
|
||||
log_server_error (a->s, a->buffer, "#s: #s", "Can't join",
|
||||
"you already are on the channel");
|
||||
else if (*a->arguments)
|
||||
|
@ -7494,8 +7501,7 @@ handle_command_part (struct handler_args *a)
|
|||
else if (a->buffer->type != BUFFER_CHANNEL)
|
||||
log_server_error (a->s, a->buffer, "#s: #s", "Can't part",
|
||||
"no channel name given and this buffer is not a channel");
|
||||
// TODO: have a better way of checking if we're on the channel
|
||||
else if (!a->buffer->channel->users)
|
||||
else if (!irc_channel_is_joined (a->buffer->channel))
|
||||
log_server_error (a->s, a->buffer, "#s: #s", "Can't part",
|
||||
"you're not on the channel");
|
||||
else
|
||||
|
@ -7538,8 +7544,7 @@ handle_command_cycle (struct handler_args *a)
|
|||
else if (a->buffer->type != BUFFER_CHANNEL)
|
||||
log_server_error (a->s, a->buffer, "#s: #s", "Can't cycle",
|
||||
"no channel name given and this buffer is not a channel");
|
||||
// TODO: have a better way of checking if we're on the channel
|
||||
else if (!a->buffer->channel->users)
|
||||
else if (!irc_channel_is_joined (a->buffer->channel))
|
||||
log_server_error (a->s, a->buffer, "#s: #s", "Can't cycle",
|
||||
"you're not on the channel");
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue