summaryrefslogtreecommitdiff
path: root/src/irc
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2001-01-04 08:49:48 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2001-01-04 08:49:48 +0000
commit69f3b3f1592800dc909c010969ada6ea6cb5640a (patch)
tree482facf93627ecf25135af38a86cdfa20770f0de /src/irc
parent131825ea0e3465c1d88e776990b972ee15abe208 (diff)
downloadirssi-69f3b3f1592800dc909c010969ada6ea6cb5640a.zip
/LIST: don't require -yes option if there's 1000 channels or less.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1057 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/irc')
-rw-r--r--src/irc/core/irc-commands.c11
-rw-r--r--src/irc/core/irc-servers.c13
-rw-r--r--src/irc/core/irc-servers.h1
3 files changed, 23 insertions, 2 deletions
diff --git a/src/irc/core/irc-commands.c b/src/irc/core/irc-commands.c
index 25c36aef..5dd0023e 100644
--- a/src/irc/core/irc-commands.c
+++ b/src/irc/core/irc-commands.c
@@ -40,6 +40,10 @@
/* How often to check if there's anyone to be unbanned in knockout list */
#define KNOCKOUT_TIMECHECK 10000
+/* /LIST: Max. number of channels in IRC network before -yes option
+ is required */
+#define LIST_MAX_CHANNELS_PASS 1000
+
typedef struct {
IRC_CHANNEL_REC *channel;
char *ban;
@@ -363,7 +367,8 @@ static void cmd_invite(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *it
}
/* SYNTAX: LIST [-yes] [<channel>] */
-static void cmd_list(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
+static void cmd_list(const char *data, IRC_SERVER_REC *server,
+ WI_ITEM_REC *item)
{
GHashTable *optlist;
char *str;
@@ -377,7 +382,9 @@ static void cmd_list(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item
PARAM_FLAG_GETREST, "list", &optlist, &str))
return;
- if (*str == '\0' && g_hash_table_lookup(optlist, "yes") == NULL)
+ if (*str == '\0' && g_hash_table_lookup(optlist, "yes") == NULL &&
+ (server->channels_formed <= 0 ||
+ server->channels_formed > LIST_MAX_CHANNELS_PASS))
cmd_param_error(CMDERR_NOT_GOOD_IDEA);
irc_send_cmdv(server, "LIST %s", str);
diff --git a/src/irc/core/irc-servers.c b/src/irc/core/irc-servers.c
index f39d858a..680f0c68 100644
--- a/src/irc/core/irc-servers.c
+++ b/src/irc/core/irc-servers.c
@@ -401,6 +401,17 @@ static void event_server_info(IRC_SERVER_REC *server, const char *data)
g_free(params);
}
+static void event_channels_formed(IRC_SERVER_REC *server, const char *data)
+{
+ char *params, *channels;
+
+ g_return_if_fail(server != NULL);
+
+ params = event_get_params(data, 2, NULL, &channels);
+ server->channels_formed = atoi(channels);
+ g_free(params);
+}
+
static void event_server_banned(IRC_SERVER_REC *server, const char *data)
{
g_return_if_fail(server != NULL);
@@ -448,6 +459,7 @@ void irc_servers_init(void)
signal_add_last("server quit", (SIGNAL_FUNC) sig_server_quit);
signal_add("event 001", (SIGNAL_FUNC) event_connected);
signal_add("event 004", (SIGNAL_FUNC) event_server_info);
+ signal_add("event 254", (SIGNAL_FUNC) event_channels_formed);
signal_add("event 465", (SIGNAL_FUNC) event_server_banned);
signal_add("event error", (SIGNAL_FUNC) event_error);
signal_add("event ping", (SIGNAL_FUNC) event_ping);
@@ -475,6 +487,7 @@ void irc_servers_deinit(void)
signal_remove("server quit", (SIGNAL_FUNC) sig_server_quit);
signal_remove("event 001", (SIGNAL_FUNC) event_connected);
signal_remove("event 004", (SIGNAL_FUNC) event_server_info);
+ signal_remove("event 254", (SIGNAL_FUNC) event_channels_formed);
signal_remove("event 465", (SIGNAL_FUNC) event_server_banned);
signal_remove("event error", (SIGNAL_FUNC) event_error);
signal_remove("event ping", (SIGNAL_FUNC) event_ping);
diff --git a/src/irc/core/irc-servers.h b/src/irc/core/irc-servers.h
index 7dab4972..04c6efdf 100644
--- a/src/irc/core/irc-servers.h
+++ b/src/irc/core/irc-servers.h
@@ -39,6 +39,7 @@ typedef struct {
char *real_address; /* address the irc server gives */
char *usermode; /* The whole mode string .. */
char *userhost; /* /USERHOST <nick> - set when joined to first channel */
+ int channels_formed; /* channels formed in irc network */
unsigned int nick_changing:1; /* We've sent nick change command to server */
unsigned int whois_coming:1; /* Mostly just to display away message right.. */