From 9398746e617c2c39558c1cf1e5a01a0a2efcc2c5 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Sun, 10 Mar 2002 19:23:22 +0000 Subject: Automatically change the nick to correct case in queries (eg. you did /QUERY nick, and the nick really was Nick, irssi would change the query to Nick as well) git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2565 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/irc/core/irc-queries.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) (limited to 'src/irc/core') diff --git a/src/irc/core/irc-queries.c b/src/irc/core/irc-queries.c index 50fed22b..49868e6a 100644 --- a/src/irc/core/irc-queries.c +++ b/src/irc/core/irc-queries.c @@ -40,17 +40,26 @@ QUERY_REC *irc_query_create(const char *server_tag, return rec; } -static void check_address_change(IRC_SERVER_REC *server, const char *nick, - const char *address, const char *target) +static void check_query_changes(IRC_SERVER_REC *server, const char *nick, + const char *address, const char *target) { QUERY_REC *query; - if (address != NULL && !ischannel(*target)) { - /* save nick's address to query */ - query = irc_query_find(server, nick); - if (query != NULL && (query->address == NULL || - strcmp(query->address, address) != 0)) - query_change_address(query, address); + if (ischannel(*target)) + return; + + query = irc_query_find(server, nick); + if (query == NULL) + return; + + if (strcmp(query->name, nick) != 0) { + /* upper/lowercase chars in nick changed */ + query_change_nick(query, nick); + } + + if (query->address == NULL || strcmp(query->address, address) != 0) { + /* host changed */ + query_change_address(query, address); } } @@ -62,7 +71,7 @@ static void event_privmsg(IRC_SERVER_REC *server, const char *data, g_return_if_fail(data != NULL); params = event_get_params(data, 2 | PARAM_FLAG_GETREST, &target, &msg); - check_address_change(server, nick, address, target); + check_query_changes(server, nick, address, target); g_free(params); } @@ -70,10 +79,9 @@ static void ctcp_action(IRC_SERVER_REC *server, const char *msg, const char *nick, const char *address, const char *target) { - check_address_change(server, nick, address, target); + check_query_changes(server, nick, address, target); } - static void event_nick(SERVER_REC *server, const char *data, const char *orignick) { -- cgit v1.2.3