Beispiel #1
0
static void irc_cmd_nick( irc_t *irc, char **cmd )
{
	irc_user_t *iu;
	
	if( ( iu = irc_user_by_name( irc, cmd[1] ) ) && iu != irc->user )
	{
		irc_send_num( irc, 433, "%s :This nick is already in use", cmd[1] );
	}
	else if( !nick_ok( cmd[1] ) )
	{
		/* [SH] Invalid characters. */
		irc_send_num( irc, 432, "%s :This nick contains invalid characters", cmd[1] );
	}
	else if( irc->status & USTATUS_LOGGED_IN )
	{
		/* WATCH OUT: iu from the first if reused here to check if the
		   new nickname is the same (other than case, possibly). If it
		   is, no need to reset identify-status. */
		if( ( irc->status & USTATUS_IDENTIFIED ) && iu != irc->user )
		{
			irc_setpass( irc, NULL );
			irc->status &= ~USTATUS_IDENTIFIED;
			irc_umode_set( irc, "-R", 1 );
			irc_rootmsg( 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." );
		}
		
		if( strcmp( cmd[1], irc->user->nick ) != 0 )
			irc_user_set_nick( irc->user, cmd[1] );
	}
	else
	{
		g_free( irc->user->nick );
		irc->user->nick = g_strdup( cmd[1] );
		
		irc_check_login( irc );
	}
}
Beispiel #2
0
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[del ? 2 : 1]);

	if (iu == NULL) {
		irc_rootmsg(irc, "Nick `%s' does not exist", cmd[1]);
	} else if (del) {
		if (iu->bu) {
			bee_irc_user_nick_reset(iu);
		}
		irc_rootmsg(irc, "Nickname reset to `%s'", iu->nick);
	} else if (iu == irc->user) {
		irc_rootmsg(irc, "Use /nick to change your own nickname");
	} else if (!nick_ok(irc, cmd[2])) {
		irc_rootmsg(irc, "Nick `%s' is invalid", cmd[2]);
	} else if ((old = irc_user_by_name(irc, cmd[2])) && old != iu) {
		irc_rootmsg(irc, "Nick `%s' already exists", cmd[2]);
	} else {
		if (!irc_user_set_nick(iu, cmd[2])) {
			irc_rootmsg(irc, "Error while changing nick");
			return;
		}

		if (iu == irc->root) {
			/* If we're called internally (user did "set root_nick"),
			   let's not go O(INF). :-) */
			if (strcmp(cmd[0], "set_rename") != 0) {
				set_setstr(&irc->b->set, "root_nick", cmd[2]);
			}
		} else if (iu->bu) {
			nick_set(iu->bu, cmd[2]);
		}

		irc_rootmsg(irc, "Nick successfully changed");
	}
}
Beispiel #3
0
static void irc_cmd_nick( irc_t *irc, char **cmd )
{
	irc_user_t *iu;
	
	if( ( iu = irc_user_by_name( irc, cmd[1] ) ) && iu != irc->user )
	{
		irc_send_num( irc, 433, "%s :This nick is already in use", cmd[1] );
	}
	else if( !nick_ok( cmd[1] ) )
	{
		/* [SH] Invalid characters. */
		irc_send_num( irc, 432, "%s :This nick contains invalid characters", cmd[1] );
	}
	else if( irc->status & USTATUS_LOGGED_IN )
	{
		if( irc->status & USTATUS_IDENTIFIED )
		{
			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] );
	}
	else
	{
		g_free( irc->user->nick );
		irc->user->nick = g_strdup( cmd[1] );
		
		irc_check_login( irc );
	}
}