Changeset 003a12b


Ignore:
Timestamp:
2010-04-14T13:35:41Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
4c3519a
Parents:
d7d677d
Message:

Restored all remaining IRC commands that make some sense to have at this
point.

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • irc.h

    rd7d677d r003a12b  
    210210int irc_user_set_nick( irc_user_t *iu, const char *new );
    211211gint irc_user_cmp( gconstpointer a_, gconstpointer b_ );
     212const char *irc_user_get_away( irc_user_t *iu );
    212213
    213214/* irc_util.c */
  • irc_commands.c

    rd7d677d r003a12b  
    384384        irc_send_num( irc, 482, "%s :Invite impossible; User/Channel non-existent or incompatible", channel );
    385385}
     386#endif
    386387
    387388static void irc_cmd_userhost( irc_t *irc, char **cmd )
    388389{
    389         user_t *u;
    390390        int i;
    391391       
     
    397397       
    398398        for( i = 1; cmd[i]; i ++ )
    399                 if( ( u = user_find( irc, cmd[i] ) ) )
    400                 {
    401                         if( u->online && u->away )
    402                                 irc_send_num( irc, 302, ":%s=-%s@%s", u->nick, u->user, u->host );
    403                         else
    404                                 irc_send_num( irc, 302, ":%s=+%s@%s", u->nick, u->user, u->host );
    405                 }
     399        {
     400                irc_user_t *iu = irc_user_by_name( irc, cmd[i] );
     401               
     402                if( iu )
     403                        irc_send_num( irc, 302, ":%s=%c%s@%s", iu->nick,
     404                                      irc_user_get_away( iu ) ? '-' : '+',
     405                                      iu->user, iu->host );
     406        }
    406407}
    407408
    408409static void irc_cmd_ison( irc_t *irc, char **cmd )
    409410{
    410         user_t *u;
    411411        char buff[IRC_MAX_LINE];
    412412        int lenleft, i;
     
    424424                while( *this )
    425425                {
     426                        irc_user_t *iu;
     427                       
    426428                        if( ( next = strchr( this, ' ' ) ) )
    427429                                *next = 0;
    428430                       
    429                         if( ( u = user_find( irc, this ) ) && u->online )
    430                         {
    431                                 lenleft -= strlen( u->nick ) + 1;
     431                        if( ( iu = irc_user_by_name( irc, this ) ) &&
     432                            iu->bu && iu->bu->flags & BEE_USER_ONLINE )
     433                        {
     434                                lenleft -= strlen( iu->nick ) + 1;
    432435                               
    433436                                if( lenleft < 0 )
    434437                                        break;
    435438                               
    436                                 strcat( buff, u->nick );
     439                                strcat( buff, iu->nick );
    437440                                strcat( buff, " " );
    438441                        }
     
    470473        {
    471474                char *nick;
    472                 user_t *u;
     475                irc_user_t *iu;
    473476               
    474477                if( !cmd[i][0] || !cmd[i][1] )
     
    478481                nick_lc( nick );
    479482               
    480                 u = user_find( irc, nick );
     483                iu = irc_user_by_name( irc, nick );
    481484               
    482485                if( cmd[i][0] == '+' )
     
    485488                                g_hash_table_insert( irc->watches, nick, nick );
    486489                       
    487                         if( u && u->online )
    488                                 irc_send_num( irc, 604, "%s %s %s %d :%s", u->nick, u->user, u->host, (int) time( NULL ), "is online" );
     490                        if( iu && iu->bu && iu->bu->flags & BEE_USER_ONLINE )
     491                                irc_send_num( irc, 604, "%s %s %s %d :%s", iu->nick, iu->user,
     492                                              iu->host, (int) time( NULL ), "is online" );
    489493                        else
    490                                 irc_send_num( irc, 605, "%s %s %s %d :%s", nick, "*", "*", (int) time( NULL ), "is offline" );
     494                                irc_send_num( irc, 605, "%s %s %s %d :%s", nick, "*", "*",
     495                                              (int) time( NULL ), "is offline" );
    491496                }
    492497                else if( cmd[i][0] == '-' )
     
    505510}
    506511
     512#if 0
    507513static void irc_cmd_topic( irc_t *irc, char **cmd )
    508514{
     
    610616        { "version",     0, irc_cmd_version,     IRC_CMD_LOGGED_IN },
    611617        { "completions", 0, irc_cmd_completions, IRC_CMD_LOGGED_IN },
    612         { "oper",        2, irc_cmd_oper,        IRC_CMD_LOGGED_IN },
     618        { "userhost",    1, irc_cmd_userhost,    IRC_CMD_LOGGED_IN },
     619        { "ison",        1, irc_cmd_ison,        IRC_CMD_LOGGED_IN },
     620        { "watch",       1, irc_cmd_watch,       IRC_CMD_LOGGED_IN },
    613621#if 0
    614622        { "invite",      2, irc_cmd_invite,      IRC_CMD_LOGGED_IN },
    615623        { "notice",      1, irc_cmd_privmsg,     IRC_CMD_LOGGED_IN },
    616         { "userhost",    1, irc_cmd_userhost,    IRC_CMD_LOGGED_IN },
    617         { "ison",        1, irc_cmd_ison,        IRC_CMD_LOGGED_IN },
    618         { "watch",       1, irc_cmd_watch,       IRC_CMD_LOGGED_IN },
    619624        { "topic",       1, irc_cmd_topic,       IRC_CMD_LOGGED_IN },
    620625#endif
     626        { "oper",        2, irc_cmd_oper,        IRC_CMD_LOGGED_IN },
    621627        { "die",         0, NULL,                IRC_CMD_OPER_ONLY | IRC_CMD_TO_MASTER },
    622628        { "deaf",        0, NULL,                IRC_CMD_OPER_ONLY | IRC_CMD_TO_MASTER },
  • irc_im.c

    rd7d677d r003a12b  
    8080{
    8181        irc_t *irc = bee->ui_data;
     82        irc_user_t *iu = bu->ui_data;
    8283        irc_channel_t *ic = irc->channels->data; /* For now, just pick the first channel. */
    8384       
     
    8586        {
    8687                if( bu->flags & BEE_USER_ONLINE )
    87                         irc_channel_add_user( ic, (irc_user_t*) bu->ui_data );
     88                {
     89                        if( g_hash_table_lookup( irc->watches, iu->key ) )
     90                                irc_send_num( irc, 600, "%s %s %s %d :%s", iu->nick, iu->user,
     91                                              iu->host, (int) time( NULL ), "logged online" );
     92                       
     93                        irc_channel_add_user( ic, iu );
     94                }
    8895                else
    89                         irc_channel_del_user( ic, (irc_user_t*) bu->ui_data );
     96                {
     97                        if( g_hash_table_lookup( irc->watches, iu->key ) )
     98                                irc_send_num( irc, 601, "%s %s %s %d :%s", iu->nick, iu->user,
     99                                              iu->host, (int) time( NULL ), "logged offline" );
     100                       
     101                        irc_channel_del_user( ic, iu );
     102                }
    90103        }
    91104       
  • irc_user.c

    rd7d677d r003a12b  
    133133}
    134134
     135const char *irc_user_get_away( irc_user_t *iu )
     136{
     137        irc_t *irc = iu->irc;
     138        bee_user_t *bu = iu->bu;
     139       
     140        if( iu == irc->user )
     141                return set_getstr( &irc->b->set, "away" );
     142        else if( bu )
     143        {
     144                if( !bu->flags & BEE_USER_ONLINE )
     145                        return "Offline";
     146                else if( bu->flags & BEE_USER_AWAY )
     147                        /* TODO: status msgs, etc. */
     148                        return bu->status;
     149        }
     150       
     151        return NULL;
     152}
     153
    135154/* User-type dependent functions, for root/NickServ: */
    136155static gboolean root_privmsg( irc_user_t *iu, const char *msg )
Note: See TracChangeset for help on using the changeset viewer.