Ticket #6: unidentified_change_nick.diff

File unidentified_change_nick.diff, 1.2 KB (added by Olof 'zibri' Johansson <olof@…>, at 2010-05-23T00:45:08Z)
  • irc_commands.c

    === modified file 'irc_commands.c'
     
    7272
    7373static void irc_cmd_nick( irc_t *irc, char **cmd )
    7474{
    75         if( irc->nick )
     75        if(irc->status & USTATUS_IDENTIFIED && irc->nick )
    7676        {
    7777                irc_reply( irc, 438, ":The hand of the deity is upon thee, thy nick may not change" );
    7878        }
    7979        /* This is not clean, but for now it'll have to be like this... */
    80         else if( ( nick_cmp( cmd[1], irc->mynick ) == 0 ) || ( nick_cmp( cmd[1], NS_NICK ) == 0 ) )
     80        else if( ( nick_cmp( cmd[1], irc->mynick ) == 0 ) || ( nick_cmp( cmd[1], NS_NICK ) == 0 ) || ( user_find( irc, cmd[1] ) != NULL ) )
    8181        {
    82                 irc_reply( irc, 433, ":This nick is already in use" );
     82                irc_reply( irc, 433, "%s :This nick is already in use", cmd[1] );
    8383        }
    8484        else if( !nick_ok( cmd[1] ) )
    8585        {
    8686                /* [SH] Invalid characters. */
    8787                irc_reply( irc, 432, ":This nick contains invalid characters" );
    8888        }
     89        else if(irc->nick)
     90        {
     91                if(user_find(irc, irc->nick)) {
     92                        user_rename(irc, irc->nick, cmd[1]);
     93                }
     94
     95                irc_write( irc, ":%s!%s@%s NICK %s", irc->nick, irc->user, irc->host, cmd[1] );
     96                g_free(irc->nick);
     97                irc->nick = g_strdup( cmd[1] );
     98        }
    8999        else
    90100        {
    91101                irc->nick = g_strdup( cmd[1] );