aboutsummaryrefslogtreecommitdiffstats
path: root/irc_user.c
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2010-04-04 20:39:04 -0400
committerWilmer van der Gaast <wilmer@gaast.net>2010-04-04 20:39:04 -0400
commit0b5cc72bc7b4192ff5b474b81038c299d03721f1 (patch)
treee727779c8d5a02dae6f9baad5a834706059a6307 /irc_user.c
parent1d3915951bfbcdfa1a7829a4082e90e154d4a486 (diff)
Send nickname change notifications when necessary.
Diffstat (limited to 'irc_user.c')
-rw-r--r--irc_user.c18
1 files changed, 17 insertions, 1 deletions
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 );