Changeset b95932e for irc_commands.c


Ignore:
Timestamp:
2010-03-27T03:39:23Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
83e92bf
Parents:
63a520b
Message:

Added WHOIS command.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • irc_commands.c

    r63a520b rb95932e  
    155155                irc_send_num( irc, 442, "%s :You're not on that channel", cmd[1] );
    156156        }
     157}
     158
     159static void irc_cmd_whois( irc_t *irc, char **cmd )
     160{
     161        char *nick = cmd[1];
     162        irc_user_t *iu = irc_user_find( irc, nick );
     163       
     164        if( iu )
     165                irc_send_whois( iu );
     166        else
     167                irc_send_num( irc, 401, "%s :Nick does not exist", nick );
     168}
     169
     170static void irc_cmd_whowas( irc_t *irc, char **cmd )
     171{
     172        /* For some reason irssi tries a whowas when whois fails. We can
     173           ignore this, but then the user never gets a "user not found"
     174           message from irssi which is a bit annoying. So just respond
     175           with not-found and irssi users will get better error messages */
     176       
     177        irc_send_num( irc, 406, "%s :Nick does not exist", cmd[1] );
     178        irc_send_num( irc, 369, "%s :End of WHOWAS", cmd[1] );
    157179}
    158180
     
    475497}
    476498
    477 static void irc_cmd_whois( irc_t *irc, char **cmd )
    478 {
    479         char *nick = cmd[1];
    480         user_t *u = user_find( irc, nick );
    481        
    482         if( u )
    483         {
    484                 irc_send_num( irc, 311, "%s %s %s * :%s", u->nick, u->user, u->host, u->realname );
    485                
    486                 if( u->ic )
    487                         irc_send_num( irc, 312, "%s %s.%s :%s network", u->nick, u->ic->acc->user,
    488                                    u->ic->acc->server && *u->ic->acc->server ? u->ic->acc->server : "",
    489                                    u->ic->acc->prpl->name );
    490                 else
    491                         irc_send_num( irc, 312, "%s %s :%s", u->nick, irc->myhost, IRCD_INFO );
    492                
    493                 if( !u->online )
    494                         irc_send_num( irc, 301, "%s :%s", u->nick, "User is offline" );
    495                 else if( u->away )
    496                         irc_send_num( irc, 301, "%s :%s", u->nick, u->away );
    497                 if( u->status_msg )
    498                         irc_send_num( irc, 333, "%s :Status: %s", u->nick, u->status_msg );
    499                
    500                 irc_send_num( irc, 318, "%s :End of /WHOIS list", nick );
    501         }
    502         else
    503         {
    504                 irc_send_num( irc, 401, "%s :Nick does not exist", nick );
    505         }
    506 }
    507 
    508 static void irc_cmd_whowas( irc_t *irc, char **cmd )
    509 {
    510         /* For some reason irssi tries a whowas when whois fails. We can
    511            ignore this, but then the user never gets a "user not found"
    512            message from irssi which is a bit annoying. So just respond
    513            with not-found and irssi users will get better error messages */
    514        
    515         irc_send_num( irc, 406, "%s :Nick does not exist", cmd[1] );
    516         irc_send_num( irc, 369, "%s :End of WHOWAS", cmd[1] );
    517 }
    518 
    519499static void irc_cmd_nickserv( irc_t *irc, char **cmd )
    520500{
     
    583563        { "names",       1, irc_cmd_names,       IRC_CMD_LOGGED_IN },
    584564        { "part",        1, irc_cmd_part,        IRC_CMD_LOGGED_IN },
     565        { "whois",       1, irc_cmd_whois,       IRC_CMD_LOGGED_IN },
     566        { "whowas",      1, irc_cmd_whowas,      IRC_CMD_LOGGED_IN },
    585567#if 0
    586568        { "oper",        2, irc_cmd_oper,        IRC_CMD_LOGGED_IN },
     
    595577        { "topic",       1, irc_cmd_topic,       IRC_CMD_LOGGED_IN },
    596578        { "away",        0, irc_cmd_away,        IRC_CMD_LOGGED_IN },
    597         { "whois",       1, irc_cmd_whois,       IRC_CMD_LOGGED_IN },
    598         { "whowas",      1, irc_cmd_whowas,      IRC_CMD_LOGGED_IN },
    599579        { "nickserv",    1, irc_cmd_nickserv,    IRC_CMD_LOGGED_IN },
    600580        { "ns",          1, irc_cmd_nickserv,    IRC_CMD_LOGGED_IN },
Note: See TracChangeset for help on using the changeset viewer.