diff options
Diffstat (limited to 'irc.c')
-rw-r--r-- | irc.c | 36 |
1 files changed, 29 insertions, 7 deletions
@@ -176,7 +176,7 @@ void irc_abort( irc_t *irc, int immed, char *format, ... ) irc->nick ? irc->nick : "(NONE)", irc->host, "No reason given" ); } - irc->status = USTATUS_SHUTDOWN; + irc->status |= USTATUS_SHUTDOWN; if( irc->sendbuffer && !immed ) { /* We won't read from this socket anymore. Instead, we'll connect a timer @@ -210,7 +210,7 @@ void irc_free(irc_t * irc) log_message( LOGLVL_INFO, "Destroying connection with fd %d", irc->fd ); - if( irc->status >= USTATUS_IDENTIFIED && set_getint( irc, "save_on_quit" ) ) + if( irc->status & USTATUS_IDENTIFIED && set_getint( irc, "save_on_quit" ) ) if( storage_save( irc, TRUE ) != STORAGE_OK ) irc_usermsg( irc, "Error while saving settings!" ); @@ -706,7 +706,7 @@ int irc_check_login( irc_t *irc ) { if( irc->user && irc->nick ) { - if( global.conf->authmode == AUTHMODE_CLOSED && irc->status < USTATUS_AUTHORIZED ) + if( global.conf->authmode == AUTHMODE_CLOSED && !( irc->status & USTATUS_AUTHORIZED ) ) { irc_reply( irc, 464, ":This server is password-protected." ); return 0; @@ -763,7 +763,7 @@ void irc_login( irc_t *irc ) if( global.conf->runmode == RUNMODE_FORKDAEMON || global.conf->runmode == RUNMODE_DAEMON ) ipc_to_master_str( "CLIENT %s %s :%s\r\n", irc->host, irc->nick, irc->realname ); - irc->status = USTATUS_LOGGED_IN; + irc->status |= USTATUS_LOGGED_IN; } void irc_motd( irc_t *irc ) @@ -904,9 +904,31 @@ void irc_kick( irc_t *irc, user_t *u, char *channel, user_t *kicker ) void irc_kill( irc_t *irc, user_t *u ) { - char *nick; + char *nick, *s; + char reason[64]; + + if( u->gc && u->gc->flags & OPT_LOGGING_OUT ) + { + if( u->gc->user->proto_opt[0][0] ) + g_snprintf( reason, sizeof( reason ), "%s %s", irc->myhost, + u->gc->user->proto_opt[0] ); + else if( ( s = strchr( u->gc->username, '@' ) ) ) + g_snprintf( reason, sizeof( reason ), "%s %s", irc->myhost, + s + 1 ); + else + g_snprintf( reason, sizeof( reason ), "%s %s.%s", irc->myhost, + u->gc->prpl->name, irc->myhost ); + + /* proto_opt might contain garbage after the : */ + if( ( s = strchr( reason, ':' ) ) ) + *s = 0; + } + else + { + strcpy( reason, "Leaving..." ); + } - irc_write( irc, ":%s!%s@%s QUIT :%s", u->nick, u->user, u->host, "Leaving..." ); + irc_write( irc, ":%s!%s@%s QUIT :%s", u->nick, u->user, u->host, reason ); nick = g_strdup( u->nick ); nick_lc( nick ); @@ -1164,7 +1186,7 @@ static gboolean irc_userping( gpointer _irc, gint fd, b_input_condition cond ) irc_t *irc = _irc; int rv = 0; - if( irc->status < USTATUS_LOGGED_IN ) + if( !( irc->status & USTATUS_LOGGED_IN ) ) { if( gettime() > ( irc->last_pong + IRC_LOGIN_TIMEOUT ) ) rv = gettime() - irc->last_pong; |