1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-09 11:13:12 +02:00

Fix irc excess flood caused by mode command sent when a mode is received: send mode only when channel modes are updated (bug #25651)

This commit is contained in:
Sebastien Helleu
2009-02-23 11:01:11 +01:00
parent 351a27c8be
commit 70cfce2d2c
3 changed files with 23 additions and 11 deletions
+18 -6
View File
@@ -72,17 +72,22 @@ irc_mode_channel_get_flag (const char *string, const char *pos)
/*
* irc_mode_channel_set: set channel modes
* return: 1 if channel modes are updated
* 0 if channel modes are NOT updated
* (no update or on nicks only)
*/
void
int
irc_mode_channel_set (struct t_irc_server *server,
struct t_irc_channel *channel, const char *modes)
{
char *pos_args, *str_modes, set_flag, **argv, *pos, *ptr_arg;
int argc, current_arg;
int channel_modes_updated, argc, current_arg;
if (!server || !channel || !modes)
return;
return 0;
channel_modes_updated = 0;
argc = 0;
argv = NULL;
@@ -92,7 +97,7 @@ irc_mode_channel_set (struct t_irc_server *server,
{
str_modes = weechat_strndup (modes, pos_args - modes);
if (!str_modes)
return;
return 0;
pos_args++;
while (pos_args[0] == ' ')
pos_args++;
@@ -104,7 +109,7 @@ irc_mode_channel_set (struct t_irc_server *server,
{
str_modes = strdup (modes);
if (!str_modes)
return;
return 0;
}
if (str_modes && str_modes[0])
@@ -155,6 +160,7 @@ irc_mode_channel_set (struct t_irc_server *server,
if (ptr_arg)
channel->key = strdup (ptr_arg);
}
channel_modes_updated = 1;
break;
case 'l': /* channel limit */
if (set_flag == '-')
@@ -166,6 +172,7 @@ irc_mode_channel_set (struct t_irc_server *server,
if (ptr_arg)
channel->limit = atoi (ptr_arg);
}
channel_modes_updated = 1;
break;
case 'o': /* op */
ptr_arg = ((argc > 0) && (current_arg >= 0)) ?
@@ -195,19 +202,24 @@ irc_mode_channel_set (struct t_irc_server *server,
irc_mode_channel_set_nick (channel, ptr_arg,
set_flag, IRC_NICK_VOICE);
break;
default:
channel_modes_updated = 1;
break;
}
break;
}
pos--;
}
}
if (str_modes)
free (str_modes);
if (argv)
weechat_string_free_exploded (argv);
weechat_bar_item_update ("buffer_name");
return channel_modes_updated;
}
/*
+3 -3
View File
@@ -23,9 +23,9 @@
struct t_irc_server;
struct t_irc_channel;
extern void irc_mode_channel_set (struct t_irc_server *server,
struct t_irc_channel *channel,
const char *modes);
extern int irc_mode_channel_set (struct t_irc_server *server,
struct t_irc_channel *channel,
const char *modes);
extern void irc_mode_user_set (struct t_irc_server *server, const char *modes);
extern int irc_mode_nick_prefix_allowed (struct t_irc_server *server,
char prefix);
+2 -2
View File
@@ -576,8 +576,8 @@ irc_protocol_cmd_mode (struct t_irc_server *server, const char *command,
ptr_channel = irc_channel_search (server, argv[2]);
if (ptr_channel)
{
irc_mode_channel_set (server, ptr_channel, pos_modes);
irc_server_sendf (server, "MODE %s", ptr_channel->name);
if (irc_mode_channel_set (server, ptr_channel, pos_modes))
irc_server_sendf (server, "MODE %s", ptr_channel->name);
}
ptr_nick = irc_nick_search (ptr_channel, nick);
if (!irc_ignore_check (server, ptr_channel, nick, host))