aboutsummaryrefslogtreecommitdiffstats
path: root/irc_commands.c
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2010-06-06 00:26:07 +0100
committerWilmer van der Gaast <wilmer@gaast.net>2010-06-06 00:26:07 +0100
commit1fdb0a48438d6dc4a4795d195737890ed3e46a96 (patch)
tree8a50bf83b78ee1c0e516e8ae6e9f9a079a3fe6df /irc_commands.c
parentb308cf9bafbdf76da73a57607b65c4763aa3057b (diff)
parent3dc6d86076dbea16c313bb87aa2f37166f289a8e (diff)
Merging mainline.
Diffstat (limited to 'irc_commands.c')
-rw-r--r--irc_commands.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/irc_commands.c b/irc_commands.c
index 319d549a..7a286ce2 100644
--- a/irc_commands.c
+++ b/irc_commands.c
@@ -72,19 +72,29 @@ static void irc_cmd_user( irc_t *irc, char **cmd )
static void irc_cmd_nick( irc_t *irc, char **cmd )
{
- if( irc->nick )
+ if( irc->status & USTATUS_IDENTIFIED && irc->nick )
{
- irc_reply( irc, 438, ":The hand of the deity is upon thee, thy nick may not change" );
+ irc_reply( irc, 438, "%s %s :You can only change your nick if you're not "
+ "logged in (i.e. pre-identify)", irc->nick, cmd[1] );
}
/* This is not clean, but for now it'll have to be like this... */
- else if( ( nick_cmp( cmd[1], irc->mynick ) == 0 ) || ( nick_cmp( cmd[1], NS_NICK ) == 0 ) )
+ else if( ( nick_cmp( cmd[1], irc->mynick ) == 0 ) || ( nick_cmp( cmd[1], NS_NICK ) == 0 ) || ( user_find( irc, cmd[1] ) != NULL ) )
{
- irc_reply( irc, 433, ":This nick is already in use" );
+ irc_reply( irc, 433, "%s :This nick is already in use", cmd[1] );
}
else if( !nick_ok( cmd[1] ) )
{
/* [SH] Invalid characters. */
- irc_reply( irc, 432, ":This nick contains invalid characters" );
+ irc_reply( irc, 432, "%s :This nick contains invalid characters", cmd[1] );
+ }
+ else if(irc->nick)
+ {
+ if( user_find( irc, irc->nick ) )
+ user_rename(irc, irc->nick, cmd[1]);
+
+ irc_write( irc, ":%s!%s@%s NICK %s", irc->nick, irc->user, irc->host, cmd[1] );
+ g_free(irc->nick);
+ irc->nick = g_strdup( cmd[1] );
}
else
{