Various fixes related to channel modes

Bugs unnoticed for so long.
This commit is contained in:
Přemysl Eric Janouch 2016-12-30 07:49:10 +01:00
parent eb70bf3fbc
commit 8e668ff31a
Signed by: p
GPG Key ID: B715679E3A361BE6
3 changed files with 39 additions and 13 deletions

10
NEWS
View File

@ -1,4 +1,4 @@
0.9.5 (2016-??-??) 0.9.5 (2016-12-30)
* Better support for the KILL command * Better support for the KILL command
@ -8,12 +8,20 @@
* degesch: allow hiding join/part messages and other noise (Meta-Shift-H) * degesch: allow hiding join/part messages and other noise (Meta-Shift-H)
* degesch: allow autojoining channels with keys
* degesch: rejoin channels with keys on reconnect
* degesch: make /query without arguments just open the buffer * degesch: make /query without arguments just open the buffer
* degesch: add a censor plugin * degesch: add a censor plugin
* degesch: die on configuration parse errors * degesch: die on configuration parse errors
* degesch: request channel modes also on rejoin
* degesch: don't show remembered channel modes on parted channels
* degesch: fix highlight detection in colored text * degesch: fix highlight detection in colored text
* degesch: fix CTCP handling for the real world and don't decode X-QUOTEs * degesch: fix CTCP handling for the real world and don't decode X-QUOTEs

View File

@ -2360,7 +2360,7 @@ static struct config_schema g_config_server[] =
.type = CONFIG_ITEM_BOOLEAN, .type = CONFIG_ITEM_BOOLEAN,
.default_ = "on" }, .default_ = "on" },
{ .name = "autojoin", { .name = "autojoin",
.comment = "Channels to join on start", .comment = "Channels to join on start (e.g. \"#abc,#def key,#ghi\")",
.type = CONFIG_ITEM_STRING_ARRAY, .type = CONFIG_ITEM_STRING_ARRAY,
.validate = config_validate_nonjunk_string }, .validate = config_validate_nonjunk_string },
{ .name = "command", { .name = "command",
@ -4996,7 +4996,7 @@ on_irc_autojoin_timeout (void *user_data)
cstr_split (autojoin, ",", true, &v); cstr_split (autojoin, ",", true, &v);
for (size_t i = 0; i < v.len; i++) for (size_t i = 0; i < v.len; i++)
{ {
irc_send (s, "JOIN :%s", v.vector[i]); irc_send (s, "JOIN %s", v.vector[i]);
str_map_set (&joins_sent, v.vector[i], (void *) 1); str_map_set (&joins_sent, v.vector[i], (void *) 1);
} }
str_vector_free (&v); str_vector_free (&v);
@ -5007,9 +5007,21 @@ on_irc_autojoin_timeout (void *user_data)
str_map_iter_init (&iter, &s->irc_channels); str_map_iter_init (&iter, &s->irc_channels);
struct channel *channel; struct channel *channel;
while ((channel = str_map_iter_next (&iter))) while ((channel = str_map_iter_next (&iter)))
{
struct str target;
str_init (&target);
str_append (&target, channel->name);
const char *key;
if ((key = str_map_find (&channel->param_modes, "k")))
str_append_printf (&target, " %s", key);
// When a channel is both autojoined and rejoined, both keys are tried
if (!channel->left_manually if (!channel->left_manually
&& !str_map_find (&joins_sent, channel->name)) && !str_map_find (&joins_sent, target.str))
irc_send (s, "JOIN :%s", channel->name); irc_send (s, "JOIN %s", target.str);
str_free (&target);
}
str_map_free (&joins_sent); str_map_free (&joins_sent);
} }
@ -5912,7 +5924,9 @@ make_prompt (struct app_context *ctx, struct str *output)
str_append_printf (output, "%d:%s", str_append_printf (output, "%d:%s",
buffer_get_index (ctx, buffer), buffer->name); buffer_get_index (ctx, buffer), buffer->name);
if (buffer->type == BUFFER_CHANNEL) // We remember old modes, don't show them while we're not on the channel
if (buffer->type == BUFFER_CHANNEL
&& buffer->channel->users_len)
{ {
struct str modes; struct str modes;
str_init (&modes); str_init (&modes);
@ -5921,8 +5935,7 @@ make_prompt (struct app_context *ctx, struct str *output)
str_append_printf (output, "(+%s)", modes.str); str_append_printf (output, "(+%s)", modes.str);
str_free (&modes); str_free (&modes);
if (buffer->channel->users_len) str_append_printf (output, "{%zu}", buffer->channel->users_len);
str_append_printf (output, "{%zu}", buffer->channel->users_len);
} }
if (buffer->hide_unimportant) if (buffer->hide_unimportant)
str_append (output, "<H>"); str_append (output, "<H>");
@ -6522,8 +6535,16 @@ irc_handle_join (struct server *s, const struct irc_message *msg)
buffer_add (s->ctx, buffer); buffer_add (s->ctx, buffer);
buffer_activate (s->ctx, buffer); buffer_activate (s->ctx, buffer);
}
if (irc_is_this_us (s, msg->prefix))
{
// Reset the field so that we rejoin the channel after reconnecting
channel->left_manually = false;
// Request the channel mode as we don't get it automatically // Request the channel mode as we don't get it automatically
str_reset (&channel->no_param_modes);
str_map_clear (&channel->param_modes);
irc_send (s, "MODE %s", channel_name); irc_send (s, "MODE %s", channel_name);
} }
@ -6531,9 +6552,6 @@ irc_handle_join (struct server *s, const struct irc_message *msg)
if (!channel) if (!channel)
return; return;
// Reset the field so that we rejoin the channel after reconnecting
channel->left_manually = false;
// Add the user to the channel // Add the user to the channel
char *nickname = irc_cut_nickname (msg->prefix); char *nickname = irc_cut_nickname (msg->prefix);
irc_channel_link_user (channel, irc_get_or_make_user (s, nickname), ""); irc_channel_link_user (channel, irc_get_or_make_user (s, nickname), "");

View File

@ -51,14 +51,14 @@ local prompt = degesch.hook_prompt (function (hook)
end end
if active ~= "" then active = "(" .. active .. ")" end if active ~= "" then active = "(" .. active .. ")" end
local x = current_n .. ":" .. current.name local x = current_n .. ":" .. current.name
if chan then if chan and chan.users_len ~= 0 then
local params = "" local params = ""
for mode, param in pairs (chan.param_modes) do for mode, param in pairs (chan.param_modes) do
params = params .. " +" .. mode .. " " .. param params = params .. " +" .. mode .. " " .. param
end end
local modes = chan.no_param_modes .. params:sub (3) local modes = chan.no_param_modes .. params:sub (3)
if modes ~= "" then x = x .. "(+" .. modes .. ")" end if modes ~= "" then x = x .. "(+" .. modes .. ")" end
if chan.users_len ~= 0 then x = x .. "{" .. chan.users_len .. "}" end x = x .. "{" .. chan.users_len .. "}"
end end
if current.hide_unimportant then x = x .. "<H>" end if current.hide_unimportant then x = x .. "<H>" end