From 0b5cc72bc7b4192ff5b474b81038c299d03721f1 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 4 Apr 2010 20:39:04 -0400 Subject: Send nickname change notifications when necessary. --- irc_user.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'irc_user.c') diff --git a/irc_user.c b/irc_user.c index b3075c3b..7f356d8d 100644 --- a/irc_user.c +++ b/irc_user.c @@ -82,15 +82,31 @@ irc_user_t *irc_user_by_name( irc_t *irc, const char *nick ) return NULL; } -int irc_user_rename( irc_t *irc, const char *old, const char *new ) +int irc_user_set_nick( irc_t *irc, const char *old, const char *new ) { irc_user_t *iu = irc_user_by_name( irc, old ); char key[strlen(new)+1]; + GSList *cl; strcpy( key, new ); if( iu == NULL || !nick_lc( key ) || irc_user_by_name( irc, new ) ) return 0; + for( cl = irc->channels; cl; cl = cl->next ) + { + irc_channel_t *ic = cl->data; + + /* Send a NICK update if we're renaming our user, or someone + who's in the same channel like our user. */ + if( iu == irc->user || + ( irc_channel_has_user( ic, irc->user ) && + irc_channel_has_user( ic, iu ) ) ) + { + irc_send_nick( iu, new ); + break; + } + } + irc->users = g_slist_remove( irc->users, iu ); g_hash_table_remove( irc->nick_user_hash, iu->key ); -- cgit v1.2.3