diff options
author | Wilmer van der Gaast <wilmer@gaast.net> | 2010-07-13 00:22:53 +0100 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@gaast.net> | 2010-07-13 00:22:53 +0100 |
commit | badd1484469ab6280de977eb179db00820868c03 (patch) | |
tree | 6887227b5b1a273674b421cc61261aeddfbe68cc /nick.c | |
parent | 09dfb686be1297e9ff0a9b434ef865b779a60bc3 (diff) |
Reformat nicks whenever fullname/nick/group changes (but at least for now
still only for offline users).
Diffstat (limited to 'nick.c')
-rw-r--r-- | nick.c | 15 |
1 files changed, 13 insertions, 2 deletions
@@ -115,7 +115,7 @@ char *nick_gen( bee_user_t *bu ) while( fmt && *fmt && ret->len < MAX_NICK_LENGTH ) { - char *part, chop = '\0'; + char *part, chop = '\0', *asc = NULL; if( *fmt != '%' ) { @@ -176,6 +176,14 @@ char *nick_gen( bee_user_t *bu ) } } + /* Credits to Josay_ in #bitlbee for this idea. //TRANSLIT + should do lossy/approximate conversions, so letters with + accents don't just get stripped. Note that it depends on + LC_CTYPE being set to something other than C/POSIX. */ + if( part ) + part = asc = g_convert( part, -1, "ASCII//TRANSLIT//IGNORE", + "UTF-8", NULL, NULL, NULL ); + while( part && *part && *part != chop ) { if( strchr( nick_lc_chars, *part ) || @@ -184,6 +192,7 @@ char *nick_gen( bee_user_t *bu ) part ++; } + g_free( asc ); } /* This returns NULL if the nick is empty or otherwise not ok. */ @@ -194,10 +203,12 @@ void nick_dedupe( bee_user_t *bu, char nick[MAX_NICK_LENGTH+1] ) { irc_t *irc = (irc_t*) bu->bee->ui_data; int inf_protection = 256; + irc_user_t *iu; /* Now, find out if the nick is already in use at the moment, and make subtle changes to make it unique. */ - while( !nick_ok( nick ) || irc_user_by_name( irc, nick ) ) + while( !nick_ok( nick ) || + ( ( iu = irc_user_by_name( irc, nick ) ) && iu->bu != bu ) ) { if( strlen( nick ) < ( MAX_NICK_LENGTH - 1 ) ) { |