diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2015-08-06 21:58:34 +0200 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2015-08-06 21:58:34 +0200 |
commit | 955b3728a3d3d06449cfcebe6cee3470295d4fd0 (patch) | |
tree | 7bc5f91dd8fdf72bcc026bce9258ee53ab8cf538 | |
parent | aa77bc41d08aba90dd468e96f1cc662583d673ba (diff) | |
download | xK-955b3728a3d3d06449cfcebe6cee3470295d4fd0.tar.gz xK-955b3728a3d3d06449cfcebe6cee3470295d4fd0.tar.xz xK-955b3728a3d3d06449cfcebe6cee3470295d4fd0.zip |
degesch: don't send PART on /close when not joined
-rw-r--r-- | degesch.c | 19 |
1 files changed, 12 insertions, 7 deletions
@@ -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 |