summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/fe-common/irc/fe-events-numeric.c14
-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
4 files changed, 28 insertions, 11 deletions
diff --git a/src/fe-common/irc/fe-events-numeric.c b/src/fe-common/irc/fe-events-numeric.c
index f3f3aa4d..c47f45a8 100644
--- a/src/fe-common/irc/fe-events-numeric.c
+++ b/src/fe-common/irc/fe-events-numeric.c
@@ -691,27 +691,21 @@ static void event_received(IRC_SERVER_REC *server, const char *data)
params = event_get_params(data, 2 | PARAM_FLAG_GETREST, NULL, &args);
ptr = strstr(args, " :");
- if (ptr != NULL) *(ptr+1) = ' ';
+ if (ptr != NULL)
+ memmove(ptr+1, ptr+2, strlen(ptr+1));
printtext(server, NULL, MSGLEVEL_CRAP, "%s", args);
g_free(params);
}
static void event_motd(IRC_SERVER_REC *server, const char *data)
{
- /* numeric event. */
- char *params, *args, *ptr;
-
/* don't ignore motd anymore after 3 seconds of connection time -
we might have called /MOTD */
if (settings_get_bool("skip_motd") &&
time(NULL)-3 <= server->real_connect_time)
return;
- params = event_get_params(data, 2 | PARAM_FLAG_GETREST, NULL, &args);
- ptr = strstr(args, " :");
- if (ptr != NULL) *(ptr+1) = ' ';
- printtext(server, NULL, MSGLEVEL_CRAP, "%s", args);
- g_free(params);
+ event_received(server, data);
}
static void sig_empty(void)
@@ -773,6 +767,7 @@ void fe_events_numeric_init(void)
signal_add("event 422", (SIGNAL_FUNC) event_motd);
signal_add("event 004", (SIGNAL_FUNC) event_received);
+ signal_add("event 254", (SIGNAL_FUNC) event_received);
signal_add("event 364", (SIGNAL_FUNC) event_received);
signal_add("event 365", (SIGNAL_FUNC) event_received);
signal_add("event 432", (SIGNAL_FUNC) event_received);
@@ -835,6 +830,7 @@ void fe_events_numeric_deinit(void)
signal_remove("event 422", (SIGNAL_FUNC) event_motd);
signal_remove("event 004", (SIGNAL_FUNC) event_received);
+ signal_remove("event 254", (SIGNAL_FUNC) event_received);
signal_remove("event 364", (SIGNAL_FUNC) event_received);
signal_remove("event 365", (SIGNAL_FUNC) event_received);
signal_remove("event 432", (SIGNAL_FUNC) event_received);
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.. */