mirror of
https://github.com/weechat/weechat.git
synced 2026-06-12 14:14:48 +02:00
irc: fix groups in channel nicklist when reconnecting to a server that supports more nick prefixes than the previously connected server
This commit is contained in:
@@ -22,6 +22,8 @@ http://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes]
|
||||
* core: add options to customize default text search in buffers:
|
||||
weechat.look.buffer_search_{case_sensitive|force_default|regex|where}
|
||||
* api: fix read of arrays in hdata functions hdata_<type> (bug #40354)
|
||||
* irc: fix groups in channel nicklist when reconnecting to a server that
|
||||
supports more nick prefixes than the previously connected server
|
||||
* irc: fix auto-switch to channel buffer when doing /join channel (without "#")
|
||||
* irc: add option irc.look.notice_welcome_tags
|
||||
* irc: add server option "default_msg_kick" to customize default kick/kickban
|
||||
|
||||
@@ -152,10 +152,9 @@ irc_channel_new (struct t_irc_server *server, int channel_type,
|
||||
{
|
||||
struct t_irc_channel *new_channel;
|
||||
struct t_gui_buffer *new_buffer, *ptr_buffer_for_merge;
|
||||
int i, buffer_created, current_buffer_number, buffer_position, manual_join;
|
||||
int buffer_created, current_buffer_number, buffer_position, manual_join;
|
||||
int noswitch;
|
||||
char *buffer_name, str_number[32], str_group[32], *channel_name_lower;
|
||||
const char *prefix_modes;
|
||||
char *buffer_name, str_number[32], *channel_name_lower;
|
||||
|
||||
/* alloc memory for new channel */
|
||||
if ((new_channel = malloc (sizeof (*new_channel))) == NULL)
|
||||
@@ -262,22 +261,6 @@ irc_channel_new (struct t_irc_server *server, int channel_type,
|
||||
}
|
||||
}
|
||||
|
||||
if (channel_type == IRC_CHANNEL_TYPE_CHANNEL)
|
||||
{
|
||||
prefix_modes = irc_server_get_prefix_modes (server);
|
||||
for (i = 0; prefix_modes[i]; i++)
|
||||
{
|
||||
snprintf (str_group, sizeof (str_group), "%03d|%c",
|
||||
i, prefix_modes[i]);
|
||||
weechat_nicklist_add_group (new_buffer, NULL, str_group,
|
||||
"weechat.color.nicklist_group", 1);
|
||||
}
|
||||
snprintf (str_group, sizeof (str_group), "%03d|%s",
|
||||
IRC_NICK_GROUP_OTHER_NUMBER, IRC_NICK_GROUP_OTHER_NAME);
|
||||
weechat_nicklist_add_group (new_buffer, NULL, str_group,
|
||||
"weechat.color.nicklist_group", 1);
|
||||
}
|
||||
|
||||
/* initialize new channel */
|
||||
new_channel->type = channel_type;
|
||||
new_channel->name = strdup (channel_name);
|
||||
@@ -375,6 +358,35 @@ irc_channel_new (struct t_irc_server *server, int channel_type,
|
||||
return new_channel;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add groups in nicklist for a channel.
|
||||
*/
|
||||
|
||||
void
|
||||
irc_channel_add_nicklist_groups (struct t_irc_server *server,
|
||||
struct t_irc_channel *channel)
|
||||
{
|
||||
const char *prefix_modes;
|
||||
char str_group[32];
|
||||
int i;
|
||||
|
||||
if (channel->type != IRC_CHANNEL_TYPE_CHANNEL)
|
||||
return;
|
||||
|
||||
prefix_modes = irc_server_get_prefix_modes (server);
|
||||
for (i = 0; prefix_modes[i]; i++)
|
||||
{
|
||||
snprintf (str_group, sizeof (str_group), "%03d|%c",
|
||||
i, prefix_modes[i]);
|
||||
weechat_nicklist_add_group (channel->buffer, NULL, str_group,
|
||||
"weechat.color.nicklist_group", 1);
|
||||
}
|
||||
snprintf (str_group, sizeof (str_group), "%03d|%s",
|
||||
IRC_NICK_GROUP_OTHER_NUMBER, IRC_NICK_GROUP_OTHER_NAME);
|
||||
weechat_nicklist_add_group (channel->buffer, NULL, str_group,
|
||||
"weechat.color.nicklist_group", 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets topic for a channel.
|
||||
*/
|
||||
|
||||
@@ -83,6 +83,8 @@ extern struct t_irc_channel *irc_channel_new (struct t_irc_server *server,
|
||||
const char *channel_name,
|
||||
int switch_to_channel,
|
||||
int auto_switch);
|
||||
extern void irc_channel_add_nicklist_groups (struct t_irc_server *server,
|
||||
struct t_irc_channel *channel);
|
||||
extern void irc_channel_set_topic (struct t_irc_channel *channel,
|
||||
const char *topic);
|
||||
extern void irc_channel_set_modes (struct t_irc_channel *channel,
|
||||
|
||||
@@ -632,6 +632,9 @@ irc_nick_new (struct t_irc_server *server, struct t_irc_channel *channel,
|
||||
if (!nickname || !nickname[0])
|
||||
return NULL;
|
||||
|
||||
if (!channel->nicks)
|
||||
irc_channel_add_nicklist_groups (server, channel);
|
||||
|
||||
/* nick already exists on this channel? */
|
||||
ptr_nick = irc_nick_search (server, channel, nickname);
|
||||
if (ptr_nick)
|
||||
@@ -821,6 +824,9 @@ irc_nick_free_all (struct t_irc_server *server, struct t_irc_channel *channel)
|
||||
irc_nick_free (server, channel, channel->nicks);
|
||||
}
|
||||
|
||||
/* remove all groups in nicklist */
|
||||
weechat_nicklist_remove_all (channel->buffer);
|
||||
|
||||
/* should be zero, but prevent any bug :D */
|
||||
channel->nicks_count = 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user