summaryrefslogtreecommitdiff
path: root/degesch.c
diff options
context:
space:
mode:
Diffstat (limited to 'degesch.c')
-rw-r--r--degesch.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/degesch.c b/degesch.c
index ac14042..2146005 100644
--- a/degesch.c
+++ b/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