diff options
-rw-r--r-- | doc/user-guide/misc.xml | 25 | ||||
-rw-r--r-- | nick.c | 11 |
2 files changed, 32 insertions, 4 deletions
diff --git a/doc/user-guide/misc.xml b/doc/user-guide/misc.xml index 825d80ee..fcbdda0e 100644 --- a/doc/user-guide/misc.xml +++ b/doc/user-guide/misc.xml @@ -203,12 +203,31 @@ text that will be copied to the nick, combined with several variables: </variablelist> <para> -One modifier is currently available: %-@variable will remove all characters from the first @ in the string. +Invalid characters (like spaces) will always be stripped. Depending on your +locale settings, characters with accents will be converted to ASCII. </para> <para> -In all cases, invalid characters (like spaces) will be stripped. Depending -on your locale settings, characters with accents will be converted to ASCII. +See <emphasis>set nick_format2</emphasis> for some more information. +</para> + +</sect1> + +<sect1 id="nick_format2"> +<title>Nickname formatting - modifiers</title> + +<para> +Two modifiers ares currently available: You can include only the first few +characters of a variable by putting a number right after the %. For example, +<emphasis>[%3group]%-@nick</emphasis> will include only the first three +characters of the group name in the nick. +</para> + +<para> +Also, you can truncate variables from a certain character using +the <emphasis>-</emphasis>modifier. For example, you may want to leave out +everything after the @. <emphasis>%-@handle</emphasis> will expand to +everything in the handle up to the first @. </para> </sect1> @@ -116,6 +116,7 @@ char *nick_gen( bee_user_t *bu ) while( fmt && *fmt && ret->len < MAX_NICK_LENGTH ) { char *part, chop = '\0', *asc = NULL; + int len = MAX_NICK_LENGTH; if( *fmt != '%' ) { @@ -135,6 +136,13 @@ char *nick_gen( bee_user_t *bu ) return NULL; fmt += 2; } + else if( isdigit( *fmt ) ) + { + len = 0; + /* Grab a number. */ + while( isdigit( *fmt ) ) + len = len * 10 + ( *(fmt++) - '0' ); + } else if( g_strncasecmp( fmt, "nick", 4 ) == 0 ) { part = bu->nick ? : bu->handle; @@ -187,13 +195,14 @@ char *nick_gen( bee_user_t *bu ) if( ret->len == 0 && part && isdigit( *part ) ) g_string_append_c( ret, '_' ); - while( part && *part && *part != chop ) + while( part && *part && *part != chop && len > 0 ) { if( strchr( nick_lc_chars, *part ) || strchr( nick_uc_chars, *part ) ) g_string_append_c( ret, *part ); part ++; + len --; } g_free( asc ); } |