1
0
mirror of https://github.com/irssi/irssi.git synced 2024-12-04 14:46:39 -05:00

/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
This commit is contained in:
Timo Sirainen 2001-01-04 08:49:48 +00:00 committed by cras
parent 131825ea0e
commit 69f3b3f159
4 changed files with 28 additions and 11 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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.. */