diff options
author | Timo Sirainen <cras@irssi.org> | 2000-06-12 22:57:53 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2000-06-12 22:57:53 +0000 |
commit | 18f3c74d68e79f5962000770fca9e663bf1b1c23 (patch) | |
tree | f16183cc068553da6080a481a5c83c14c97b7bd5 /src/irc | |
parent | 919abb2c6f8339e160a59b8ddcacfd403772379d (diff) | |
download | irssi-18f3c74d68e79f5962000770fca9e663bf1b1c23.zip |
CTCP msgs/replies stops the "event privmsg" or "event notice" signals now
so you don't have to check for them anymore (unless you use
signal_add_first()..).
/WINDOW MOVE command had some bugs.
CTCP reply to some channel didn't display the channel name.
Several code cleanups.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@327 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/irc')
-rw-r--r-- | src/irc/bot/bot-irc-commands.c | 4 | ||||
-rw-r--r-- | src/irc/core/ctcp.c | 8 | ||||
-rw-r--r-- | src/irc/core/irc-server.c | 4 | ||||
-rw-r--r-- | src/irc/core/irc-special-vars.c | 14 | ||||
-rw-r--r-- | src/irc/core/query.c | 2 | ||||
-rw-r--r-- | src/irc/flood/flood.c | 26 |
6 files changed, 38 insertions, 20 deletions
diff --git a/src/irc/bot/bot-irc-commands.c b/src/irc/bot/bot-irc-commands.c index a5b88337..f4b2b7f3 100644 --- a/src/irc/bot/bot-irc-commands.c +++ b/src/irc/bot/bot-irc-commands.c @@ -39,9 +39,7 @@ static void event_privmsg(const char *data, IRC_SERVER_REC *server, g_return_if_fail(data != NULL); params = event_get_params(data, 2 | PARAM_FLAG_GETREST, &target, &msg); - if (nick == NULL) nick = server->real_address; - - if (*msg == 1 || ischannel(*target)) { + if (ischannel(*target)) { g_free(params); return; } diff --git a/src/irc/core/ctcp.c b/src/irc/core/ctcp.c index 31768088..067e9aef 100644 --- a/src/irc/core/ctcp.c +++ b/src/irc/core/ctcp.c @@ -156,6 +156,7 @@ static void event_privmsg(const char *data, IRC_SERVER_REC *server, const char * if (ptr != NULL) *ptr = '\0'; signal_emit("ctcp msg", 5, msg, server, nick, addr, target); + signal_stop(); } g_free(params); @@ -167,7 +168,7 @@ static void event_notice(const char *data, IRC_SERVER_REC *server, const char *n g_return_if_fail(data != NULL); - params = event_get_params(data, 2, &target, &msg); /* Channel or nick name */ + params = event_get_params(data, 2, &target, &msg); /* handle only ctcp replies */ if (*msg == 1) { @@ -175,6 +176,7 @@ static void event_notice(const char *data, IRC_SERVER_REC *server, const char *n if (ptr != NULL) *ptr = '\0'; signal_emit("ctcp reply", 5, msg, server, nick, addr, target); + signal_stop(); } g_free(params); @@ -193,8 +195,8 @@ void ctcp_init(void) settings_add_int("flood", "max_ctcp_queue", 5); signal_add("server disconnected", (SIGNAL_FUNC) ctcp_deinit_server); - signal_add("event privmsg", (SIGNAL_FUNC) event_privmsg); - signal_add("event notice", (SIGNAL_FUNC) event_notice); + signal_add_first("event privmsg", (SIGNAL_FUNC) event_privmsg); + signal_add_first("event notice", (SIGNAL_FUNC) event_notice); signal_add("ctcp msg", (SIGNAL_FUNC) ctcp_msg); signal_add("ctcp reply", (SIGNAL_FUNC) ctcp_reply); signal_add("ctcp msg ping", (SIGNAL_FUNC) ctcp_ping); diff --git a/src/irc/core/irc-server.c b/src/irc/core/irc-server.c index d4d58774..c747f757 100644 --- a/src/irc/core/irc-server.c +++ b/src/irc/core/irc-server.c @@ -367,7 +367,9 @@ static void event_connected(const char *data, IRC_SERVER_REC *server, const char if (server->real_address == NULL) { /* set the server address */ - server->real_address = g_strdup(from); + server->real_address = from == NULL ? + g_strdup(server->connrec->address) : /* shouldn't happen.. */ + g_strdup(from); } /* last welcome message found - commands can be sent to server now. */ diff --git a/src/irc/core/irc-special-vars.c b/src/irc/core/irc-special-vars.c index 9fcb5808..09e0db11 100644 --- a/src/irc/core/irc-special-vars.c +++ b/src/irc/core/irc-special-vars.c @@ -223,14 +223,12 @@ static void event_privmsg(const char *data, IRC_SERVER_REC *server, const char * params = event_get_params(data, 2 | PARAM_FLAG_GETREST, &target, &msg); - if (*msg != 1) { - if (!ischannel(*target)) { - g_free_not_null(last_privmsg_from); - last_privmsg_from = g_strdup(nick); - } else { - g_free_not_null(last_public_from); - last_public_from = g_strdup(nick); - } + if (!ischannel(*target)) { + g_free_not_null(last_privmsg_from); + last_privmsg_from = g_strdup(nick); + } else { + g_free_not_null(last_public_from); + last_public_from = g_strdup(nick); } g_free(params); diff --git a/src/irc/core/query.c b/src/irc/core/query.c index 68ec1a73..89a2f9f7 100644 --- a/src/irc/core/query.c +++ b/src/irc/core/query.c @@ -113,7 +113,7 @@ static void event_privmsg(const char *data, IRC_SERVER_REC *server, const char * params = event_get_params(data, 2 | PARAM_FLAG_GETREST, &target, &msg); - if (addr != NULL && *msg != 1 && !ischannel(*target)) { + if (addr != NULL && !ischannel(*target)) { /* save nick's address to query */ query = query_find(server, nick); if (query != NULL && (query->address == NULL || strcmp(query->address, addr) != 0)) { diff --git a/src/irc/flood/flood.c b/src/irc/flood/flood.c index 3e66afa6..90206b5d 100644 --- a/src/irc/flood/flood.c +++ b/src/irc/flood/flood.c @@ -195,7 +195,7 @@ static void flood_privmsg(const char *data, IRC_SERVER_REC *server, const char * g_return_if_fail(data != NULL); g_return_if_fail(server != NULL); - if (nick == NULL) { + if (nick == NULL || addr == NULL) { /* don't try to ignore server messages.. */ return; } @@ -223,18 +223,32 @@ static void flood_notice(const char *data, IRC_SERVER_REC *server, const char *n g_return_if_fail(data != NULL); g_return_if_fail(server != NULL); - if (nick == NULL) { + if (nick == NULL || addr == NULL) { /* don't try to ignore server messages.. */ return; } params = event_get_params(data, 2, &target, &text); - if (addr != NULL && !ignore_check(server, nick, addr, target, text, MSGLEVEL_NOTICES)) - flood_newmsg(server, MSGLEVEL_NOTICES | ischannel(*target) ? MSGLEVEL_PUBLIC : MSGLEVEL_MSGS, nick, addr, target); + if (!ignore_check(server, nick, addr, target, text, MSGLEVEL_NOTICES)) + flood_newmsg(server, MSGLEVEL_NOTICES, nick, addr, target); g_free(params); } +static void flood_ctcp(const char *data, IRC_SERVER_REC *server, const char *nick, const char *addr, const char *target) +{ + g_return_if_fail(data != NULL); + g_return_if_fail(server != NULL); + + if (nick == NULL || addr == NULL) { + /* don't try to ignore server messages.. */ + return; + } + + if (!ignore_check(server, nick, addr, target, data, MSGLEVEL_CTCPS)) + flood_newmsg(server, MSGLEVEL_CTCPS, nick, addr, target); +} + static void read_settings(void) { int time; @@ -255,6 +269,8 @@ static void read_settings(void) flood_tag = g_timeout_add(time, (GSourceFunc) flood_timeout, NULL); signal_add("event privmsg", (SIGNAL_FUNC) flood_privmsg); signal_add("event notice", (SIGNAL_FUNC) flood_notice); + signal_add("ctcp msg", (SIGNAL_FUNC) flood_ctcp); + signal_add("ctcp reply", (SIGNAL_FUNC) flood_ctcp); } } @@ -280,6 +296,8 @@ void irc_flood_deinit(void) g_source_remove(flood_tag); signal_remove("event privmsg", (SIGNAL_FUNC) flood_privmsg); signal_remove("event notice", (SIGNAL_FUNC) flood_notice); + signal_remove("ctcp msg", (SIGNAL_FUNC) flood_ctcp); + signal_remove("ctcp reply", (SIGNAL_FUNC) flood_ctcp); } signal_remove("setup changed", (SIGNAL_FUNC) read_settings); |