diff options
author | Wilmer van der Gaast <wilmer@gaast.net> | 2010-12-05 12:28:07 +0000 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@gaast.net> | 2010-12-05 12:28:07 +0000 |
commit | a429907207d5b8b05463c72a9b8c880ba03ad921 (patch) | |
tree | e04d31c6dc6ee8461d3401cae386ab14167c1f43 | |
parent | fd65edb3a40d4c73130b0be8dfa08ae8092c6935 (diff) |
rename -del
-rw-r--r-- | doc/user-guide/commands.xml | 5 | ||||
-rw-r--r-- | irc.h | 1 | ||||
-rw-r--r-- | irc_im.c | 18 | ||||
-rw-r--r-- | root_commands.c | 9 |
4 files changed, 32 insertions, 1 deletions
diff --git a/doc/user-guide/commands.xml b/doc/user-guide/commands.xml index 2aa30546..b86328b5 100644 --- a/doc/user-guide/commands.xml +++ b/doc/user-guide/commands.xml @@ -1539,11 +1539,16 @@ <bitlbee-command name="rename"> <short-description>Rename (renick) a buddy</short-description> <syntax>rename <oldnick> <newnick></syntax> + <syntax>rename -del <oldnick></syntax> <description> <para> Renick a user in your buddy list. Very useful, in fact just very important, if you got a lot of people with stupid account names (or hard ICQ numbers). </para> + + <para> + <emphasis>rename -del</emphasis> can be used to erase your manually set nickname for a contact and reset it to what was automatically generated. + </para> </description> <ircexample> @@ -338,5 +338,6 @@ char *irc_format_timestamp( irc_t *irc, time_t msg_ts ); /* irc_im.c */ void bee_irc_channel_update( irc_t *irc, irc_channel_t *ic, irc_user_t *iu ); +void bee_irc_user_nick_reset( irc_user_t *iu ); #endif @@ -362,6 +362,24 @@ static gboolean bee_irc_user_nick_update( irc_user_t *iu ) return TRUE; } +void bee_irc_user_nick_reset( irc_user_t *iu ) +{ + bee_user_t *bu = iu->bu; + bee_user_flags_t online; + + if( bu == FALSE ) + return; + + /* In this case, pretend the user is offline. */ + if( ( online = bu->flags & BEE_USER_ONLINE ) ) + bu->flags &= ~BEE_USER_ONLINE; + + nick_del( bu ); + bee_irc_user_nick_update( iu ); + + bu->flags |= online; +} + /* IRC->IM calls */ static gboolean bee_irc_user_privmsg_cb( gpointer data, gint fd, b_input_condition cond ); diff --git a/root_commands.c b/root_commands.c index 207f9678..a7b626b8 100644 --- a/root_commands.c +++ b/root_commands.c @@ -773,13 +773,20 @@ static void cmd_info( irc_t *irc, char **cmd ) static void cmd_rename( irc_t *irc, char **cmd ) { irc_user_t *iu, *old; + gboolean del = g_strcasecmp( cmd[1], "-del" ) == 0; - iu = irc_user_by_name( irc, cmd[1] ); + iu = irc_user_by_name( irc, cmd[del ? 2 : 1] ); if( iu == NULL ) { irc_usermsg( irc, "Nick `%s' does not exist", cmd[1] ); } + else if( del ) + { + if( iu->bu ) + bee_irc_user_nick_reset( iu ); + irc_usermsg( irc, "Nickname reset to `%s'", iu->nick ); + } else if( iu == irc->user ) { irc_usermsg( irc, "Use /nick to change your own nickname" ); |