summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2009-04-24 11:45:31 +0200
committerSebastien Helleu <flashcode@flashtux.org>2009-04-24 11:45:31 +0200
commit671087e26a2f4c48189c25b73b8fab96a9bd15e8 (patch)
treea16601bc9a7c5838e299035e7817c44cafb00035 /src
parentc5968389a61a0c12ff569dfa902584117527dd8f (diff)
downloadweechat-671087e26a2f4c48189c25b73b8fab96a9bd15e8.zip
Add anti-flood for extra IRC commands like msg/notice/query/quote and some other
Diffstat (limited to 'src')
-rw-r--r--src/plugins/irc/irc-channel.c2
-rw-r--r--src/plugins/irc/irc-command.c183
-rw-r--r--src/plugins/irc/irc-input.c6
-rw-r--r--src/plugins/irc/irc-protocol.c20
-rw-r--r--src/plugins/irc/irc-server.c51
-rw-r--r--src/plugins/irc/irc-server.h12
-rw-r--r--src/plugins/irc/irc-upgrade.c1
7 files changed, 135 insertions, 140 deletions
diff --git a/src/plugins/irc/irc-channel.c b/src/plugins/irc/irc-channel.c
index b5c2d8af6..a2eb29ca5 100644
--- a/src/plugins/irc/irc-channel.c
+++ b/src/plugins/irc/irc-channel.c
@@ -281,7 +281,7 @@ irc_channel_check_away (struct t_irc_server *server,
|| (channel->nicks_count <= weechat_config_integer (irc_config_network_away_check_max_nicks)))
{
channel->checking_away++;
- irc_server_sendf (server, "WHO %s", channel->name);
+ irc_server_sendf (server, 1, "WHO %s", channel->name);
}
else
irc_channel_remove_away (channel);
diff --git a/src/plugins/irc/irc-command.c b/src/plugins/irc/irc-command.c
index aec937665..a6453c8eb 100644
--- a/src/plugins/irc/irc-command.c
+++ b/src/plugins/irc/irc-command.c
@@ -60,9 +60,9 @@ irc_command_admin (void *data, struct t_gui_buffer *buffer, int argc,
(void) argv;
if (argc > 1)
- irc_server_sendf (ptr_server, "ADMIN %s", argv_eol[1]);
+ irc_server_sendf (ptr_server, 0, "ADMIN %s", argv_eol[1]);
else
- irc_server_sendf (ptr_server, "ADMIN");
+ irc_server_sendf (ptr_server, 0, "ADMIN");
return WEECHAT_RC_OK;
}
@@ -78,7 +78,7 @@ irc_command_me_channel (struct t_irc_server *server,
{
char *string;
- irc_server_sendf (server, "PRIVMSG %s :\01ACTION %s\01",
+ irc_server_sendf (server, 1, "PRIVMSG %s :\01ACTION %s\01",
channel->name,
(arguments && arguments[0]) ? arguments : "");
string = (arguments && arguments[0]) ?
@@ -138,7 +138,7 @@ irc_command_mode_nicks (struct t_irc_server *server, const char *channel,
strcat (command, " ");
strcat (command, argv[i]);
}
- irc_server_sendf (server, "%s", command);
+ irc_server_sendf (server, 0, "%s", command);
free (command);
}
}
@@ -212,7 +212,7 @@ irc_command_amsg (void *data, struct t_gui_buffer *buffer, int argc,
{
if (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL)
{
- irc_server_sendf (ptr_server, "PRIVMSG %s :%s",
+ irc_server_sendf (ptr_server, 1, "PRIVMSG %s :%s",
ptr_channel->name, argv_eol[1]);
ptr_nick = irc_nick_search (ptr_channel,
ptr_server->nick);
@@ -274,7 +274,7 @@ irc_command_away_server (struct t_irc_server *server, const char *arguments,
{
server->is_away = 1;
server->away_time = time (NULL);
- irc_server_sendf (server, "AWAY :%s", arguments);
+ irc_server_sendf (server, 1, "AWAY :%s", arguments);
if (weechat_config_integer (irc_config_look_display_away) != IRC_CONFIG_DISPLAY_AWAY_OFF)
{
string = irc_color_decode (arguments,
@@ -335,7 +335,7 @@ irc_command_away_server (struct t_irc_server *server, const char *arguments,
/* if server is connected, send away command now */
if (server->is_connected)
{
- irc_server_sendf (server, "AWAY");
+ irc_server_sendf (server, 1, "AWAY");
server->is_away = 0;
if (server->away_time != 0)
{
@@ -467,7 +467,7 @@ irc_command_ban (void *data, struct t_gui_buffer *buffer, int argc,
/* loop on users */
while (argv[pos_args])
{
- irc_server_sendf (ptr_server, "MODE %s +b %s",
+ irc_server_sendf (ptr_server, 0, "MODE %s +b %s",
pos_channel, argv[pos_args]);
pos_args++;
}
@@ -483,7 +483,7 @@ irc_command_ban (void *data, struct t_gui_buffer *buffer, int argc,
IRC_PLUGIN_NAME, "ban");
return WEECHAT_RC_OK;
}
- irc_server_sendf (ptr_server, "MODE %s +b", ptr_channel->name);
+ irc_server_sendf (ptr_server, 0, "MODE %s +b", ptr_channel->name);
}
return WEECHAT_RC_OK;
@@ -689,7 +689,7 @@ irc_command_ctcp (void *data, struct t_gui_buffer *buffer, int argc,
if ((weechat_strcasecmp (argv[2], "ping") == 0) && !argv_eol[3])
{
gettimeofday (&tv, NULL);
- irc_server_sendf (ptr_server, "PRIVMSG %s :\01PING %d %d\01",
+ irc_server_sendf (ptr_server, 1, "PRIVMSG %s :\01PING %d %d\01",
argv[1], tv.tv_sec, tv.tv_usec);
weechat_printf (ptr_server->buffer,
"%sCTCP%s(%s%s%s)%s: %s%s %s%d %d",
@@ -708,7 +708,7 @@ irc_command_ctcp (void *data, struct t_gui_buffer *buffer, int argc,
{
if (argv_eol[3])
{
- irc_server_sendf (ptr_server, "PRIVMSG %s :\01%s %s\01",
+ irc_server_sendf (ptr_server, 1, "PRIVMSG %s :\01%s %s\01",
argv[1], irc_cmd, argv_eol[3]);
weechat_printf (ptr_server->buffer,
"%sCTCP%s(%s%s%s)%s: %s%s %s%s",
@@ -725,7 +725,7 @@ irc_command_ctcp (void *data, struct t_gui_buffer *buffer, int argc,
}
else
{
- irc_server_sendf (ptr_server, "PRIVMSG %s :\01%s\01",
+ irc_server_sendf (ptr_server, 1, "PRIVMSG %s :\01%s\01",
argv[1], irc_cmd);
weechat_printf (ptr_server->buffer,
"%sCTCP%s(%s%s%s)%s: %s%s",
@@ -838,13 +838,13 @@ irc_command_cycle (void *data, struct t_gui_buffer *buffer, int argc,
{
version = weechat_info_get ("version", "");
buf = weechat_string_replace (ptr_arg, "%v", (version) ? version : "");
- irc_server_sendf (ptr_server, "PART %s :%s", channel_name,
+ irc_server_sendf (ptr_server, 0, "PART %s :%s", channel_name,
(buf) ? buf : ptr_arg);
if (buf)
free (buf);
}
else
- irc_server_sendf (ptr_server, "PART %s", channel_name);
+ irc_server_sendf (ptr_server, 0, "PART %s", channel_name);
return WEECHAT_RC_OK;
}
@@ -978,7 +978,7 @@ irc_command_dehalfop (void *data, struct t_gui_buffer *buffer, int argc,
if (ptr_channel && (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL))
{
if (argc < 2)
- irc_server_sendf (ptr_server, "MODE %s -h %s",
+ irc_server_sendf (ptr_server, 0, "MODE %s -h %s",
ptr_channel->name,
ptr_server->nick);
else
@@ -1015,7 +1015,7 @@ irc_command_deop (void *data, struct t_gui_buffer *buffer, int argc,
if (ptr_channel && (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL))
{
if (argc < 2)
- irc_server_sendf (ptr_server, "MODE %s -o %s",
+ irc_server_sendf (ptr_server, 0, "MODE %s -o %s",
ptr_channel->name,
ptr_server->nick);
else
@@ -1052,7 +1052,7 @@ irc_command_devoice (void *data, struct t_gui_buffer *buffer, int argc,
if (ptr_channel && (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL))
{
if (argc < 2)
- irc_server_sendf (ptr_server, "MODE %s -v %s",
+ irc_server_sendf (ptr_server, 0, "MODE %s -v %s",
ptr_channel->name,
ptr_server->nick);
else
@@ -1088,7 +1088,7 @@ irc_command_die (void *data, struct t_gui_buffer *buffer, int argc,
(void) argv;
(void) argv_eol;
- irc_server_sendf (ptr_server, "DIE");
+ irc_server_sendf (ptr_server, 0, "DIE");
return WEECHAT_RC_OK;
}
@@ -1118,13 +1118,13 @@ irc_command_quit_server (struct t_irc_server *server, const char *arguments)
version = weechat_info_get ("version", "");
buf = weechat_string_replace (ptr_arg, "%v",
(version) ? version : "");
- irc_server_sendf (server, "QUIT :%s",
+ irc_server_sendf (server, 0, "QUIT :%s",
(buf) ? buf : ptr_arg);
if (buf)
free (buf);
}
else
- irc_server_sendf (server, "QUIT");
+ irc_server_sendf (server, 0, "QUIT");
}
}
@@ -1243,7 +1243,7 @@ irc_command_halfop (void *data, struct t_gui_buffer *buffer, int argc,
if (ptr_channel && (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL))
{
if (argc < 2)
- irc_server_sendf (ptr_server, "MODE %s +h %s",
+ irc_server_sendf (ptr_server, 0, "MODE %s +h %s",
ptr_channel->name,
ptr_server->nick);
else
@@ -1466,9 +1466,9 @@ irc_command_info (void *data, struct t_gui_buffer *buffer, int argc,
(void) argv;
if (argc > 1)
- irc_server_sendf (ptr_server, "INFO %s", argv_eol[1]);
+ irc_server_sendf (ptr_server, 0, "INFO %s", argv_eol[1]);
else
- irc_server_sendf (ptr_server, "INFO");
+ irc_server_sendf (ptr_server, 0, "INFO");
return WEECHAT_RC_OK;
}
@@ -1489,11 +1489,11 @@ irc_command_invite (void *data, struct t_gui_buffer *buffer, int argc,
(void) argv_eol;
if (argc > 2)
- irc_server_sendf (ptr_server, "INVITE %s %s", argv[1], argv[2]);
+ irc_server_sendf (ptr_server, 0, "INVITE %s %s", argv[1], argv[2]);
else
{
if (ptr_channel && (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL))
- irc_server_sendf (ptr_server, "INVITE %s %s",
+ irc_server_sendf (ptr_server, 0, "INVITE %s %s",
argv[1], ptr_channel->name);
else
{
@@ -1526,7 +1526,7 @@ irc_command_ison (void *data, struct t_gui_buffer *buffer, int argc,
(void) argv;
if (argc > 1)
- irc_server_sendf (ptr_server, "ISON %s", argv_eol[1]);
+ irc_server_sendf (ptr_server, 0, "ISON %s", argv_eol[1]);
else
{
IRC_COMMAND_TOO_FEW_ARGUMENTS(ptr_server->buffer, "ison");
@@ -1543,9 +1543,9 @@ void
irc_command_join_server (struct t_irc_server *server, const char *arguments)
{
if (irc_channel_is_channel (arguments))
- irc_server_sendf (server, "JOIN %s", arguments);
+ irc_server_sendf (server, 0, "JOIN %s", arguments);
else
- irc_server_sendf (server, "JOIN #%s", arguments);
+ irc_server_sendf (server, 0, "JOIN #%s", arguments);
}
/*
@@ -1626,10 +1626,10 @@ irc_command_kick (void *data, struct t_gui_buffer *buffer, int argc,
}
if (pos_comment)
- irc_server_sendf (ptr_server, "KICK %s %s :%s",
+ irc_server_sendf (ptr_server, 0, "KICK %s %s :%s",
pos_channel, pos_nick, pos_comment);
else
- irc_server_sendf (ptr_server, "KICK %s %s",
+ irc_server_sendf (ptr_server, 0, "KICK %s %s",
pos_channel, pos_nick);
}
else
@@ -1693,7 +1693,7 @@ irc_command_kickban (void *data, struct t_gui_buffer *buffer, int argc,
}
/* set ban for nick(+host) on channel */
- irc_server_sendf (ptr_server, "MODE %s +b %s",
+ irc_server_sendf (ptr_server, 0, "MODE %s +b %s",
pos_channel, pos_nick);
/* kick nick from channel */
@@ -1706,7 +1706,7 @@ irc_command_kickban (void *data, struct t_gui_buffer *buffer, int argc,
pos = strchr (nick_only, '!');
if (pos)
pos[0] = '\0';
- irc_server_sendf (ptr_server, "KICK %s %s%s%s",
+ irc_server_sendf (ptr_server, 0, "KICK %s %s%s%s",
pos_channel,
nick_only,
(pos_comment) ? " :" : "",
@@ -1738,7 +1738,7 @@ irc_command_kill (void *data, struct t_gui_buffer *buffer, int argc,
if (argc > 2)
{
- irc_server_sendf (ptr_server, "KILL %s :%s",
+ irc_server_sendf (ptr_server, 0, "KILL %s :%s",
argv[1], argv_eol[2]);
}
else
@@ -1766,9 +1766,9 @@ irc_command_links (void *data, struct t_gui_buffer *buffer, int argc,
(void) argv;
if (argc > 1)
- irc_server_sendf (ptr_server, "LINKS %s", argv_eol[1]);
+ irc_server_sendf (ptr_server, 0, "LINKS %s", argv_eol[1]);
else
- irc_server_sendf (ptr_server, "LINKS");
+ irc_server_sendf (ptr_server, 0, "LINKS");
return WEECHAT_RC_OK;
}
@@ -1817,7 +1817,7 @@ irc_command_list (void *data, struct t_gui_buffer *buffer, int argc,
return WEECHAT_RC_OK;
}
else
- irc_server_sendf (ptr_server, "LIST");
+ irc_server_sendf (ptr_server, 0, "LIST");
}
else
{
@@ -1830,7 +1830,7 @@ irc_command_list (void *data, struct t_gui_buffer *buffer, int argc,
}
}
else
- irc_server_sendf (ptr_server, "LIST");
+ irc_server_sendf (ptr_server, 0, "LIST");
return WEECHAT_RC_OK;
}
@@ -1851,9 +1851,9 @@ irc_command_lusers (void *data, struct t_gui_buffer *buffer, int argc,
(void) argv;
if (argc > 1)
- irc_server_sendf (ptr_server, "LUSERS %s", argv_eol[1]);
+ irc_server_sendf (ptr_server, 0, "LUSERS %s", argv_eol[1]);
else
- irc_server_sendf (ptr_server, "LUSERS");
+ irc_server_sendf (ptr_server, 0, "LUSERS");
return WEECHAT_RC_OK;
}
@@ -1900,12 +1900,12 @@ irc_command_mode_server (struct t_irc_server *server,
{
if (channel && arguments)
{
- irc_server_sendf (server, "MODE %s %s",
+ irc_server_sendf (server, 0, "MODE %s %s",
channel->name, arguments);
}
else
{
- irc_server_sendf (server, "MODE %s",
+ irc_server_sendf (server, 0, "MODE %s",
(channel) ? channel->name : arguments);
}
}
@@ -1971,9 +1971,9 @@ irc_command_motd (void *data, struct t_gui_buffer *buffer, int argc,
(void) argv;
if (argc > 1)
- irc_server_sendf (ptr_server, "MOTD %s", argv_eol[1]);
+ irc_server_sendf (ptr_server, 0, "MOTD %s", argv_eol[1]);
else
- irc_server_sendf (ptr_server, "MOTD");
+ irc_server_sendf (ptr_server, 0, "MOTD");
return WEECHAT_RC_OK;
}
@@ -2048,7 +2048,7 @@ irc_command_msg (void *data, struct t_gui_buffer *buffer, int argc,
if (string)
free (string);
- irc_server_sendf (ptr_server, "PRIVMSG %s :%s",
+ irc_server_sendf (ptr_server, 1, "PRIVMSG %s :%s",
ptr_channel->name, argv_eol[arg_text]);
}
else
@@ -2070,7 +2070,7 @@ irc_command_msg (void *data, struct t_gui_buffer *buffer, int argc,
if (string)
free (string);
}
- irc_server_sendf (ptr_server, "PRIVMSG %s :%s",
+ irc_server_sendf (ptr_server, 1, "PRIVMSG %s :%s",
targets[i], argv_eol[arg_text]);
}
else
@@ -2129,7 +2129,7 @@ irc_command_msg (void *data, struct t_gui_buffer *buffer, int argc,
if (string)
free (string);
}
- irc_server_sendf (ptr_server, "PRIVMSG %s :%s",
+ irc_server_sendf (ptr_server, 1, "PRIVMSG %s :%s",
targets[i], argv_eol[arg_text]);
}
}
@@ -2156,11 +2156,11 @@ irc_command_names (void *data, struct t_gui_buffer *buffer, int argc,
(void) argv;
if (argc > 1)
- irc_server_sendf (ptr_server, "NAMES %s", argv_eol[1]);
+ irc_server_sendf (ptr_server, 0, "NAMES %s", argv_eol[1]);
else
{
if (ptr_channel && (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL))
- irc_server_sendf (ptr_server, "NAMES %s",
+ irc_server_sendf (ptr_server, 0, "NAMES %s",
ptr_channel->name);
else
{
@@ -2187,7 +2187,7 @@ irc_send_nick_server (struct t_irc_server *server, const char *nickname)
return;
if (server->is_connected)
- irc_server_sendf (server, "NICK %s", nickname);
+ irc_server_sendf (server, 0, "NICK %s", nickname);
else
irc_server_set_nick (server, nickname);
}
@@ -2276,7 +2276,7 @@ irc_command_notice (void *data, struct t_gui_buffer *buffer, int argc,
(string) ? string : argv_eol[arg_text]);
if (string)
free (string);
- irc_server_sendf (ptr_server, "NOTICE %s :%s",
+ irc_server_sendf (ptr_server, 1, "NOTICE %s :%s",
argv[arg_nick], argv_eol[arg_text]);
}
else
@@ -2306,7 +2306,7 @@ irc_command_op (void *data, struct t_gui_buffer *buffer, int argc, char **argv,
if (ptr_channel && (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL))
{
if (argc < 2)
- irc_server_sendf (ptr_server, "MODE %s +o %s",
+ irc_server_sendf (ptr_server, 0, "MODE %s +o %s",
ptr_channel->name,
ptr_server->nick);
else
@@ -2341,7 +2341,7 @@ irc_command_oper (void *data, struct t_gui_buffer *buffer, int argc,
(void) argv;
if (argc > 2)
- irc_server_sendf (ptr_server, "OPER %s", argv_eol[1]);
+ irc_server_sendf (ptr_server, 0, "OPER %s", argv_eol[1]);
else
{
IRC_COMMAND_TOO_FEW_ARGUMENTS(ptr_server->buffer, "oper");
@@ -2371,14 +2371,14 @@ irc_command_part_channel (struct t_irc_server *server, const char *channel_name,
{
version = weechat_info_get ("version", "");
buf = weechat_string_replace (ptr_arg, "%v", (version) ? version : "");
- irc_server_sendf (server, "PART %s :%s",
+ irc_server_sendf (server, 0, "PART %s :%s",
channel_name,
(buf) ? buf : ptr_arg);
if (buf)
free (buf);
}
else
- irc_server_sendf (server, "PART %s", channel_name);
+ irc_server_sendf (server, 0, "PART %s", channel_name);
}
/*
@@ -2462,7 +2462,7 @@ irc_command_ping (void *data, struct t_gui_buffer *buffer, int argc,
(void) argv;
if (argc > 1)
- irc_server_sendf (ptr_server, "PING %s", argv_eol[1]);
+ irc_server_sendf (ptr_server, 0, "PING %s", argv_eol[1]);
else
{
IRC_COMMAND_TOO_FEW_ARGUMENTS(ptr_server->buffer, "ping");
@@ -2487,7 +2487,7 @@ irc_command_pong (void *data, struct t_gui_buffer *buffer, int argc,
(void) argv;
if (argc > 1)
- irc_server_sendf (ptr_server, "PONG %s", argv_eol[1]);
+ irc_server_sendf (ptr_server, 0, "PONG %s", argv_eol[1]);
else
{
IRC_COMMAND_TOO_FEW_ARGUMENTS(ptr_server->buffer, "pong");
@@ -2553,7 +2553,7 @@ irc_command_query (void *data, struct t_gui_buffer *buffer, int argc,
(string) ? string : argv_eol[arg_text]);
if (string)
free (string);
- irc_server_sendf (ptr_server, "PRIVMSG %s :%s",
+ irc_server_sendf (ptr_server, 1, "PRIVMSG %s :%s",
argv[arg_nick], argv_eol[arg_text]);
}
}
@@ -2586,13 +2586,13 @@ irc_command_quote (void *data, struct t_gui_buffer *buffer, int argc,
ptr_server = irc_server_search (argv[2]);
if (!ptr_server || (ptr_server->sock < 0))
return WEECHAT_RC_ERROR;
- irc_server_sendf (ptr_server, "%s", argv_eol[3]);
+ irc_server_sendf (ptr_server, 1, "%s", argv_eol[3]);
}
else
{
if (!ptr_server || (ptr_server->sock < 0))
return WEECHAT_RC_ERROR;
- irc_server_sendf (ptr_server, "%s", argv_eol[1]);
+ irc_server_sendf (ptr_server, 1, "%s", argv_eol[1]);
}
}
else
@@ -2729,7 +2729,7 @@ irc_command_rehash (void *data, struct t_gui_buffer *buffer, int argc,
(void) argv;
(void) argv_eol;
- irc_server_sendf (ptr_server, "REHASH");
+ irc_server_sendf (ptr_server, 0, "REHASH");
return WEECHAT_RC_OK;
}
@@ -2751,7 +2751,7 @@ irc_command_restart (void *data, struct t_gui_buffer *buffer, int argc,
(void) argv;
(void) argv_eol;
- irc_server_sendf (ptr_server, "RESTART");
+ irc_server_sendf (ptr_server, 0, "RESTART");
return WEECHAT_RC_OK;
}
@@ -3171,7 +3171,7 @@ irc_command_service (void *data, struct t_gui_buffer *buffer, int argc,
(void) argv;
if (argc > 1)
- irc_server_sendf (ptr_server, "SERVICE %s", argv_eol[1]);
+ irc_server_sendf (ptr_server, 0, "SERVICE %s", argv_eol[1]);
else
{
IRC_COMMAND_TOO_FEW_ARGUMENTS(ptr_server->buffer, "service");
@@ -3196,9 +3196,9 @@ irc_command_servlist (void *data, struct t_gui_buffer *buffer, int argc,
(void) argv;
if (argc > 1)
- irc_server_sendf (ptr_server, "SERVLIST %s", argv_eol[1]);
+ irc_server_sendf (ptr_server, 0, "SERVLIST %s", argv_eol[1]);
else
- irc_server_sendf (ptr_server, "SERVLIST");
+ irc_server_sendf (ptr_server, 0, "SERVLIST");
return WEECHAT_RC_OK;
}
@@ -3220,10 +3220,10 @@ irc_command_squery (void *data, struct t_gui_buffer *buffer, int argc,
if (argc > 1)
{
if (argc > 2)
- irc_server_sendf (ptr_server, "SQUERY %s :%s",
+ irc_server_sendf (ptr_server, 1, "SQUERY %s :%s",
argv[1], argv_eol[2]);
else
- irc_server_sendf (ptr_server, "SQUERY %s", argv_eol[1]);
+ irc_server_sendf (ptr_server, 1, "SQUERY %s", argv_eol[1]);
}
else
{
@@ -3249,7 +3249,7 @@ irc_command_squit (void *data, struct t_gui_buffer *buffer, int argc,
(void) argv;
if (argc > 1)
- irc_server_sendf (ptr_server, "SQUIT %s", argv_eol[1]);
+ irc_server_sendf (ptr_server, 0, "SQUIT %s", argv_eol[1]);
else
{
IRC_COMMAND_TOO_FEW_ARGUMENTS(ptr_server->buffer, "squit");
@@ -3274,9 +3274,9 @@ irc_command_stats (void *data, struct t_gui_buffer *buffer, int argc,
(void) argv;
if (argc > 1)
- irc_server_sendf (ptr_server, "STATS %s", argv_eol[1]);
+ irc_server_sendf (ptr_server, 0, "STATS %s", argv_eol[1]);
else
- irc_server_sendf (ptr_server, "STATS");
+ irc_server_sendf (ptr_server, 0, "STATS");
return WEECHAT_RC_OK;
}
@@ -3298,7 +3298,7 @@ irc_command_summon (void *data, struct t_gui_buffer *buffer, int argc,
(void) argv;
if (argc > 1)
- irc_server_sendf (ptr_server, "SUMMON %s", argv_eol[1]);
+ irc_server_sendf (ptr_server, 0, "SUMMON %s", argv_eol[1]);
else
{
IRC_COMMAND_TOO_FEW_ARGUMENTS(ptr_server->buffer, "summon");
@@ -3323,9 +3323,9 @@ irc_command_time (void *data, struct t_gui_buffer *buffer, int argc,
(void) argv;
if (argc > 1)
- irc_server_sendf (ptr_server, "TIME %s", argv_eol[1]);
+ irc_server_sendf (ptr_server, 0, "TIME %s", argv_eol[1]);
else
- irc_server_sendf (ptr_server, "TIME");
+ irc_server_sendf (ptr_server, 0, "TIME");
return WEECHAT_RC_OK;
}
@@ -3380,13 +3380,13 @@ irc_command_topic (void *data, struct t_gui_buffer *buffer, int argc,
if (new_topic)
{
if (weechat_strcasecmp (new_topic, "-delete") == 0)
- irc_server_sendf (ptr_server, "TOPIC %s :",
+ irc_server_sendf (ptr_server, 1, "TOPIC %s :",
channel_name);
else
{
new_topic_color = irc_color_encode (new_topic,
weechat_config_boolean (irc_config_network_colors_send));
- irc_server_sendf (ptr_server, "TOPIC %s :%s",
+ irc_server_sendf (ptr_server, 1, "TOPIC %s :%s",
channel_name,
(new_topic_color) ? new_topic_color : new_topic);
if (new_topic_color)
@@ -3394,8 +3394,7 @@ irc_command_topic (void *data, struct t_gui_buffer *buffer, int argc,
}
}
else
- irc_server_sendf (ptr_server, "TOPIC %s",
- channel_name);
+ irc_server_sendf (ptr_server, 1, "TOPIC %s", channel_name);
return WEECHAT_RC_OK;
}
@@ -3416,9 +3415,9 @@ irc_command_trace (void *data, struct t_gui_buffer *buffer, int argc,
(void) argv;
if (argc > 1)
- irc_server_sendf (ptr_server, "TRACE %s", argv_eol[1]);
+ irc_server_sendf (ptr_server, 0, "TRACE %s", argv_eol[1]);
else
- irc_server_sendf (ptr_server, "TRACE");
+ irc_server_sendf (ptr_server, 0, "TRACE");
return WEECHAT_RC_OK;
}
@@ -3473,7 +3472,7 @@ irc_command_unban (void *data, struct t_gui_buffer *buffer, int argc,
/* loop on users */
while (argv[pos_args])
{
- irc_server_sendf (ptr_server, "MODE %s -b %s",
+ irc_server_sendf (ptr_server, 0, "MODE %s -b %s",
pos_channel, argv[pos_args]);
pos_args++;
}
@@ -3506,7 +3505,7 @@ irc_command_userhost (void *data, struct t_gui_buffer *buffer, int argc,
(void) argv;
if (argc > 1)
- irc_server_sendf (ptr_server, "USERHOST %s", argv_eol[1]);
+ irc_server_sendf (ptr_server, 0, "USERHOST %s", argv_eol[1]);
else
{
IRC_COMMAND_TOO_FEW_ARGUMENTS(ptr_server->buffer, "userhost");
@@ -3531,9 +3530,9 @@ irc_command_users (void *data, struct t_gui_buffer *buffer, int argc,
(void) argv;
if (argc > 1)
- irc_server_sendf (ptr_server, "USERS %s", argv_eol[1]);
+ irc_server_sendf (ptr_server, 0, "USERS %s", argv_eol[1]);
else
- irc_server_sendf (ptr_server, "USERS");
+ irc_server_sendf (ptr_server, 0, "USERS");
return WEECHAT_RC_OK;
}
@@ -3557,14 +3556,14 @@ irc_command_version (void *data, struct t_gui_buffer *buffer, int argc,
{
if (ptr_channel && (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL)
&& irc_nick_search (ptr_channel, argv[1]))
- irc_server_sendf (ptr_server, "PRIVMSG %s :\01VERSION\01",
+ irc_server_sendf (ptr_server, 1, "PRIVMSG %s :\01VERSION\01",
argv[1]);
else
- irc_server_sendf (ptr_server, "VERSION %s",
+ irc_server_sendf (ptr_server, 1, "VERSION %s",
argv[1]);
}
else
- irc_server_sendf (ptr_server, "VERSION");
+ irc_server_sendf (ptr_server, 1, "VERSION");
return WEECHAT_RC_OK;
}
@@ -3587,7 +3586,7 @@ irc_command_voice (void *data, struct t_gui_buffer *buffer, int argc,
if (ptr_channel && (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL))
{
if (argc < 2)
- irc_server_sendf (ptr_server, "MODE %s +v %s",
+ irc_server_sendf (ptr_server, 0, "MODE %s +v %s",
ptr_channel->name,
ptr_server->nick);
else
@@ -3624,7 +3623,7 @@ irc_command_wallops (void *data, struct t_gui_buffer *buffer, int argc,
(void) argv;
if (argc > 1)
- irc_server_sendf (ptr_server, "WALLOPS :%s", argv_eol[1]);
+ irc_server_sendf (ptr_server, 1, "WALLOPS :%s", argv_eol[1]);
else
{
IRC_COMMAND_TOO_FEW_ARGUMENTS(ptr_server->buffer, "wallops");
@@ -3649,9 +3648,9 @@ irc_command_who (void *data, struct t_gui_buffer *buffer, int argc,
(void) argv;
if (argc > 1)
- irc_server_sendf (ptr_server, "WHO %s", argv_eol[1]);
+ irc_server_sendf (ptr_server, 0, "WHO %s", argv_eol[1]);
else
- irc_server_sendf (ptr_server, "WHO");
+ irc_server_sendf (ptr_server, 0, "WHO");
return WEECHAT_RC_OK;
}
@@ -3672,13 +3671,13 @@ irc_command_whois (void *data, struct t_gui_buffer *buffer, int argc,
(void) argv;
if (argc > 1)
- irc_server_sendf (ptr_server, "WHOIS %s", argv_eol[1]);
+ irc_server_sendf (ptr_server, 0, "WHOIS %s", argv_eol[1]);
else
{
if (ptr_channel
&& (ptr_channel->type == IRC_CHANNEL_TYPE_PRIVATE))
{
- irc_server_sendf (ptr_server, "WHOIS %s", ptr_channel->name);
+ irc_server_sendf (ptr_server, 0, "WHOIS %s", ptr_channel->name);
}
else
{
@@ -3705,7 +3704,7 @@ irc_command_whowas (void *data, struct t_gui_buffer *buffer, int argc,
(void) argv;
if (argc > 1)
- irc_server_sendf (ptr_server, "WHOWAS %s", argv_eol[1]);
+ irc_server_sendf (ptr_server, 0, "WHOWAS %s", argv_eol[1]);
else
{
IRC_COMMAND_TOO_FEW_ARGUMENTS(ptr_server->buffer, "whowas");
diff --git a/src/plugins/irc/irc-input.c b/src/plugins/irc/irc-input.c
index b81f7b00a..b6373a424 100644
--- a/src/plugins/irc/irc-input.c
+++ b/src/plugins/irc/irc-input.c
@@ -124,8 +124,8 @@ irc_input_send_user_message (struct t_gui_buffer *buffer, char *text)
}
}
- irc_server_sendf_queued (ptr_server, "PRIVMSG %s :%s",
- ptr_channel->name, text);
+ irc_server_sendf (ptr_server, 1, "PRIVMSG %s :%s",
+ ptr_channel->name, text);
irc_input_user_message_display (buffer, text);
if (next)
@@ -157,7 +157,7 @@ irc_input_data_cb (void *data, struct t_gui_buffer *buffer,
&& (input_data[0] == '/') && (input_data[1] != '/'))
{
if (ptr_server)
- irc_server_sendf (ptr_server, input_data + 1);
+ irc_server_sendf (ptr_server, 1, input_data + 1);
return WEECHAT_RC_OK;
}
diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c
index fd167d471..1b64213e5 100644
--- a/src/plugins/irc/irc-protocol.c
+++ b/src/plugins/irc/irc-protocol.c
@@ -575,7 +575,7 @@ irc_protocol_cmd_mode (struct t_irc_server *server, const char *command,
if (ptr_channel)
{
if (irc_mode_channel_set (server, ptr_channel, pos_modes))
- irc_server_sendf (server, "MODE %s", ptr_channel->name);
+ irc_server_sendf (server, 0, "MODE %s", ptr_channel->name);
}
ptr_nick = irc_nick_search (ptr_channel, nick);
if (!irc_ignore_check (server, ptr_channel, nick, host))
@@ -1079,7 +1079,7 @@ irc_protocol_cmd_ping (struct t_irc_server *server, const char *command,
/* make C compiler happy */
(void) argv_eol;
- irc_server_sendf (server, "PONG :%s",
+ irc_server_sendf (server, 0, "PONG :%s",
(argv[1][0] == ':') ? argv[1] + 1 : argv[1]);
return WEECHAT_RC_OK;
@@ -1152,7 +1152,7 @@ irc_protocol_reply_version (struct t_irc_server *server,
date = weechat_info_get ("date", "");
if (version && date)
{
- irc_server_sendf (server,
+ irc_server_sendf (server, 0,
"NOTICE %s :%sVERSION WeeChat %s (%s)%s",
nick, "\01", version, date, "\01");
@@ -1299,10 +1299,12 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command,
if (pos_args && !pos_args[0])
pos_args = NULL;
if (pos_args)
- irc_server_sendf (server, "NOTICE %s :\01PING %s\01",
+ irc_server_sendf (server, 0,
+ "NOTICE %s :\01PING %s\01",
nick, pos_args);
else
- irc_server_sendf (server, "NOTICE %s :\01PING\01",
+ irc_server_sendf (server, 0,
+ "NOTICE %s :\01PING\01",
nick);
weechat_printf_tags (ptr_channel->buffer,
irc_protocol_tags (command, "irc_ctcp"),
@@ -1459,10 +1461,10 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command,
if (pos_args && !pos_args[0])
pos_args = NULL;
if (pos_args)
- irc_server_sendf (server, "NOTICE %s :\01PING %s\01",
+ irc_server_sendf (server, 0, "NOTICE %s :\01PING %s\01",
nick, pos_args);
else
- irc_server_sendf (server, "NOTICE %s :\01PING\01",
+ irc_server_sendf (server, 0, "NOTICE %s :\01PING\01",
nick);
weechat_printf_tags (server->buffer,
irc_protocol_tags (command, "irc_ctcp"),
@@ -4184,7 +4186,7 @@ irc_protocol_cmd_432 (struct t_irc_server *server, const char *command,
irc_server_set_nick (server, server->nicks_array[nick_to_use]);
- irc_server_sendf (server, "NICK %s", server->nick);
+ irc_server_sendf (server, 0, "NICK %s", server->nick);
}
return WEECHAT_RC_OK;
@@ -4240,7 +4242,7 @@ irc_protocol_cmd_433 (struct t_irc_server *server, const char *command,
irc_server_set_nick (server, server->nicks_array[nick_to_use]);
- irc_server_sendf (server, "NICK %s", server->nick);
+ irc_server_sendf (server, 0, "NICK %s", server->nick);
}
else
{
diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c
index ded43fa79..ffcfc651c 100644
--- a/src/plugins/irc/irc-server.c
+++ b/src/plugins/irc/irc-server.c
@@ -356,7 +356,6 @@ irc_server_alloc (const char *name)
new_server->lag_next_check = time (NULL) +
weechat_config_integer (irc_config_network_lag_check);
new_server->cmd_list_regexp = NULL;
- new_server->queue_msg = 0;
new_server->last_user_message = 0;
new_server->outqueue = NULL;
new_server->last_outqueue = NULL;
@@ -1109,18 +1108,22 @@ irc_server_parse_message (const char *message, char **nick, char **host,
/*
* irc_server_send_one_msg: send one message to IRC server
+ * if queue_msg == 1, then messages are in a queue and
+ * sent slowly (to be sure there will not be any
+ * "excess flood")
* return: 1 if ok, 0 if error
*/
int
-irc_server_send_one_msg (struct t_irc_server *server, const char *message)
+irc_server_send_one_msg (struct t_irc_server *server, int queue_msg,
+ const char *message)
{
static char buffer[4096];
const char *ptr_msg;
char *new_msg, *pos, *nick, *command, *channel;
char *ptr_chan_nick, *msg_encoded;
char str_modifier[64], modifier_data[256];
- int rc, queue, first_message;
+ int rc, add_to_queue, first_message;
time_t time_now;
rc = 1;
@@ -1185,17 +1188,17 @@ irc_server_send_one_msg (struct t_irc_server *server, const char *message)
if (server->last_user_message > time_now)
server->last_user_message = time_now;
- queue = 0;
- if ((server->queue_msg)
- && ((server->outqueue)
+ add_to_queue = 0;
+ if (queue_msg
+ && (server->outqueue
|| ((weechat_config_integer (irc_config_network_anti_flood) > 0)
&& (time_now - server->last_user_message <
weechat_config_integer (irc_config_network_anti_flood)))))
- queue = 1;
+ add_to_queue = 1;
- /* if queue, then only queue message and send nothing now */
- if (queue)
+ if (add_to_queue)
{
+ /* queue message (do not send anything now) */
irc_server_outqueue_add (server, command,
(new_msg && first_message) ? message : NULL,
buffer,
@@ -1217,7 +1220,7 @@ irc_server_send_one_msg (struct t_irc_server *server, const char *message)
rc = 0;
else
{
- if (server->queue_msg)
+ if (queue_msg)
server->last_user_message = time_now;
}
}
@@ -1252,10 +1255,13 @@ irc_server_send_one_msg (struct t_irc_server *server, const char *message)
/*
* irc_server_sendf: send formatted data to IRC server
* many messages may be sent, separated by '\n'
+ * if queue_msg == 1, then messages are in a queue and sent
+ * slowly (to be sure there will not be any "excess flood")
*/
void
-irc_server_sendf (struct t_irc_server *server, const char *format, ...)
+irc_server_sendf (struct t_irc_server *server, int queue_msg,
+ const char *format, ...)
{
va_list args;
static char buffer[4096];
@@ -1272,7 +1278,7 @@ irc_server_sendf (struct t_irc_server *server, const char *format, ...)
items = weechat_string_explode (buffer, "\n", 0, 0, &items_count);
for (i = 0; i < items_count; i++)
{
- if (!irc_server_send_one_msg (server, items[i]))
+ if (!irc_server_send_one_msg (server, queue_msg, items[i]))
break;
}
if (items)
@@ -1638,7 +1644,7 @@ irc_server_timer_cb (void *data, int remaining_calls)
if ((ptr_server->lag_check_time.tv_sec == 0)
&& (new_time >= ptr_server->lag_next_check))
{
- irc_server_sendf (ptr_server, "PING %s",
+ irc_server_sendf (ptr_server, 0, "PING %s",
ptr_server->addresses_array[ptr_server->index_current_address]);
gettimeofday (&(ptr_server->lag_check_time), NULL);
}
@@ -1794,7 +1800,7 @@ irc_server_login (struct t_irc_server *server)
realname = IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_REALNAME);
if (password && password[0])
- irc_server_sendf (server, "PASS %s", password);
+ irc_server_sendf (server, 0, "PASS %s", password);
if (!server->nick)
{
@@ -1803,7 +1809,7 @@ irc_server_login (struct t_irc_server *server)
server->nicks_array[0] : "weechat");
}
- irc_server_sendf (server,
+ irc_server_sendf (server, 0,
"NICK %s\n"
"USER %s %s %s :%s",
server->nick,
@@ -2541,10 +2547,10 @@ irc_server_autojoin_channels (struct t_irc_server *server)
if (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL)
{
if (ptr_channel->key)
- irc_server_sendf (server, "JOIN %s %s",
+ irc_server_sendf (server, 0, "JOIN %s %s",
ptr_channel->name, ptr_channel->key);
else
- irc_server_sendf (server, "JOIN %s",
+ irc_server_sendf (server, 0, "JOIN %s",
ptr_channel->name);
}
}
@@ -2794,7 +2800,7 @@ irc_server_xfer_send_ready_cb (void *data, const char *signal,
{
filename = weechat_infolist_string (infolist, "filename");
spaces_in_name = (strchr (filename, ' ') != NULL);
- irc_server_sendf (server,
+ irc_server_sendf (server, 1,
"PRIVMSG %s :\01DCC SEND %s%s%s "
"%s %d %s\01",
weechat_infolist_string (infolist, "remote_nick"),
@@ -2807,7 +2813,7 @@ irc_server_xfer_send_ready_cb (void *data, const char *signal,
}
else if (strcmp (type, "chat_send") == 0)
{
- irc_server_sendf (server,
+ irc_server_sendf (server, 1,
"PRIVMSG %s :\01DCC CHAT chat %s %d\01",
weechat_infolist_string (infolist, "remote_nick"),
weechat_infolist_string (infolist, "address"),
@@ -2864,7 +2870,7 @@ irc_server_xfer_resume_ready_cb (void *data, const char *signal,
{
filename = weechat_infolist_string (infolist, "filename");
spaces_in_name = (strchr (filename, ' ') != NULL);
- irc_server_sendf (server,
+ irc_server_sendf (server, 1,
"PRIVMSG %s :\01DCC RESUME %s%s%s %d %s\01",
weechat_infolist_string (infolist, "remote_nick"),
(spaces_in_name) ? "\"" : "",
@@ -2923,7 +2929,7 @@ irc_server_xfer_send_accept_resume_cb (void *data, const char *signal,
{
filename = weechat_infolist_string (infolist, "filename");
spaces_in_name = (strchr (filename, ' ') != NULL);
- irc_server_sendf (server,
+ irc_server_sendf (server, 1,
"PRIVMSG %s :\01DCC ACCEPT %s%s%s %d %s\01",
weechat_infolist_string (infolist, "remote_nick"),
(spaces_in_name) ? "\"" : "",
@@ -3061,8 +3067,6 @@ irc_server_add_to_infolist (struct t_infolist *infolist,
return 0;
if (!weechat_infolist_new_var_time (ptr_item, "lag_next_check", server->lag_next_check))
return 0;
- if (!weechat_infolist_new_var_integer (ptr_item, "queue_msg", server->queue_msg))
- return 0;
if (!weechat_infolist_new_var_time (ptr_item, "last_user_message", server->last_user_message))
return 0;
@@ -3222,7 +3226,6 @@ irc_server_print_log ()
ptr_server->lag_check_time.tv_usec);
weechat_log_printf (" lag_next_check . . . : %ld", ptr_server->lag_next_check);
weechat_log_printf (" cmd_list_regexp. . . : 0x%lx", ptr_server->cmd_list_regexp);
- weechat_log_printf (" queue_msg. . . . . . : %d", ptr_server->queue_msg);
weechat_log_printf (" last_user_message. . : %ld", ptr_server->last_user_message);
weechat_log_printf (" outqueue . . . . . . : 0x%lx", ptr_server->outqueue);
weechat_log_printf (" last_outqueue. . . . : 0x%lx", ptr_server->last_outqueue);
diff --git a/src/plugins/irc/irc-server.h b/src/plugins/irc/irc-server.h
index 92c286402..2ed059176 100644
--- a/src/plugins/irc/irc-server.h
+++ b/src/plugins/irc/irc-server.h
@@ -79,14 +79,6 @@ enum t_irc_server_option
#define IRC_SERVER_DEFAULT_NICKS "weechat1,weechat2,weechat3," \
"weechat4,weechat5"
-#define irc_server_sendf_queued(server, fmt, argz...) \
- if (server) \
- { \
- server->queue_msg = 1; \
- irc_server_sendf (server, fmt, ##argz); \
- server->queue_msg = 0; \
- }
-
/* output queue of messages to server (for sending slowly to server) */
struct t_irc_outqueue
@@ -140,7 +132,6 @@ struct t_irc_server
struct timeval lag_check_time; /* last time lag was checked (ping sent) */
time_t lag_next_check; /* time for next check */
regex_t *cmd_list_regexp; /* compiled Regular Expression for /list */
- int queue_msg; /* set to 1 when queue (out) is required */
time_t last_user_message; /* time of last user message (anti flood)*/
struct t_irc_outqueue *outqueue; /* queue for outgoing user msgs */
struct t_irc_outqueue *last_outqueue; /* last outgoing user message */
@@ -188,7 +179,8 @@ extern int irc_server_rename (struct t_irc_server *server, const char *new_name)
extern void irc_server_send_signal (struct t_irc_server *server,
const char *signal, const char *command,
const char *full_message);
-extern void irc_server_sendf (struct t_irc_server *server, const char *format, ...);
+extern void irc_server_sendf (struct t_irc_server *server, int queue_msg,
+ const char *format, ...);
extern struct t_irc_server *irc_server_search (const char *server_name);
extern void irc_server_set_buffer_title (struct t_irc_server *server);
extern struct t_gui_buffer *irc_server_create_buffer (struct t_irc_server *server,
diff --git a/src/plugins/irc/irc-upgrade.c b/src/plugins/irc/irc-upgrade.c
index 759aeafac..01bbad4a9 100644
--- a/src/plugins/irc/irc-upgrade.c
+++ b/src/plugins/irc/irc-upgrade.c
@@ -277,7 +277,6 @@ irc_upgrade_read_cb (void *data,
if (buf)
memcpy (&(irc_upgrade_current_server->lag_check_time), buf, size);
irc_upgrade_current_server->lag_next_check = weechat_infolist_time (infolist, "lag_next_check");
- irc_upgrade_current_server->queue_msg = weechat_infolist_integer (infolist, "queue_msg");
irc_upgrade_current_server->last_user_message = weechat_infolist_time (infolist, "last_user_message");
}
break;