From 92cb8c4c251fb04a483b29e7108e7a52388f14dd Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 7 Jun 2010 00:47:46 +0100 Subject: Complete (hopefully) fix for nickname changes: Add flags to the identify command to allow identifying without loading any new settings. With some documentation hints. --- doc/user-guide/commands.xml | 10 +++++++++- doc/user-guide/misc.xml | 17 +++++++++++++++++ irc_commands.c | 4 ++++ root_commands.c | 42 +++++++++++++++++++++++++++++++++++++----- 4 files changed, 67 insertions(+), 6 deletions(-) diff --git a/doc/user-guide/commands.xml b/doc/user-guide/commands.xml index 97c54bae..bba2df73 100644 --- a/doc/user-guide/commands.xml +++ b/doc/user-guide/commands.xml @@ -1113,7 +1113,7 @@ - identify <password> + identify [-noload|-force] <password> Identify yourself with your password @@ -1124,6 +1124,14 @@ Once you're registered, you can change your password using set password <password>. + + + The -noload and -force flags can be used to identify when you're logged into some IM accounts already. -force will let you identify yourself and load all saved accounts (and keep the accounts you're logged into already). + + + + -noload will log you in but not load any accounts and settings saved under your current nickname. These will be overwritten once you save your settings (i.e. when you disconnect). + diff --git a/doc/user-guide/misc.xml b/doc/user-guide/misc.xml index a926775a..2427ef69 100644 --- a/doc/user-guide/misc.xml +++ b/doc/user-guide/misc.xml @@ -116,4 +116,21 @@ If you want to set an away state for only one of your connections, you can use t + +Changing your nickname + + +BitlBee now allows you to change your nickname. So far this was not possible because it made managing saved accounts more complicated. + + + +The restriction no longer exists now though. When you change your nick (just using the /nick command), your logged-in status will be reset, which means any changes made to your settings/accounts will not be saved. + + + +To restore your logged-in status, you need to either use the register command to create an account under the new nickname, or use identify -noload to re-identify yourself under the new nickname. The -noload flag tells the command to verify your password and log you in, but not load any new settings. See help identify for more information. + + + + diff --git a/irc_commands.c b/irc_commands.c index 4ea53299..4ce68f07 100644 --- a/irc_commands.c +++ b/irc_commands.c @@ -88,6 +88,10 @@ static void irc_cmd_nick( irc_t *irc, char **cmd ) irc_setpass( irc, NULL ); irc->status &= ~USTATUS_IDENTIFIED; irc_umode_set( irc, "-R", 1 ); + irc_usermsg( irc, "Changing nicks resets your identify status. " + "Re-identify or register a new account if you want " + "your configuration to be saved. See \x02help " + "nick_changes\x02." ); } irc_user_set_nick( irc->user, cmd[1] ); diff --git a/root_commands.c b/root_commands.c index cdc1ccdb..bb9b26cd 100644 --- a/root_commands.c +++ b/root_commands.c @@ -104,15 +104,46 @@ static void cmd_account( irc_t *irc, char **cmd ); static void cmd_identify( irc_t *irc, char **cmd ) { - storage_status_t status = storage_load( irc, cmd[1] ); + storage_status_t status; char *account_on[] = { "account", "on", NULL }; + gboolean load = TRUE; + char *password = cmd[1]; - if( strchr( irc->umode, 'R' ) != NULL ) + if( irc->status & USTATUS_IDENTIFIED ) { irc_usermsg( irc, "You're already logged in." ); return; } + if( strncmp( cmd[1], "-no", 3 ) == 0 ) + { + load = FALSE; + password = cmd[2]; + } + else if( strncmp( cmd[1], "-force", 6 ) == 0 ) + { + password = cmd[2]; + } + else if( irc->b->accounts != NULL ) + { + irc_usermsg( irc, + "You're trying to identify yourself, but already have " + "at least one IM account set up. " + "Use \x02identify -noload\x02 or \x02identify -force\x02 " + "instead (see \x02help identify\x02)." ); + return; + } + + if( password == NULL ) + { + MIN_ARGS( 2 ); + } + + if( load ) + status = storage_load( irc, password ); + else + status = storage_check_pass( irc->user->nick, password ); + switch (status) { case STORAGE_INVALID_PASSWORD: irc_usermsg( irc, "Incorrect password" ); @@ -121,11 +152,12 @@ static void cmd_identify( irc_t *irc, char **cmd ) irc_usermsg( irc, "The nick is (probably) not registered" ); break; case STORAGE_OK: - irc_usermsg( irc, "Password accepted, settings and accounts loaded" ); - irc_setpass( irc, cmd[1] ); + irc_usermsg( irc, "Password accepted%s", + load ? ", settings and accounts loaded" : "" ); + irc_setpass( irc, password ); irc->status |= USTATUS_IDENTIFIED; irc_umode_set( irc, "+R", 1 ); - if( set_getbool( &irc->b->set, "auto_connect" ) ) + if( load && set_getbool( &irc->b->set, "auto_connect" ) ) cmd_account( irc, account_on ); break; case STORAGE_OTHER_ERROR: -- cgit v1.2.3