Changeset b919363 for irc_commands.c


Ignore:
Timestamp:
2010-03-27T14:31:03Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
2f53ada
Parents:
9b69eb7
Message:

Mode stuff. Also disallow unsetting +R umode which was possible so far
(and shouldn't be).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • irc_commands.c

    r9b69eb7 rb919363  
    184184}
    185185
     186static void irc_cmd_mode( irc_t *irc, char **cmd )
     187{
     188        if( irc_channel_name_ok( cmd[1] ) )
     189        {
     190                irc_channel_t *ic;
     191               
     192                if( ( ic = irc_channel_by_name( irc, cmd[1] ) ) == NULL )
     193                        irc_send_num( irc, 403, "%s :No such channel", cmd[1] );
     194                else if( cmd[2] )
     195                {
     196                        if( *cmd[2] == '+' || *cmd[2] == '-' )
     197                                irc_send_num( irc, 477, "%s :Can't change channel modes", cmd[1] );
     198                        else if( *cmd[2] == 'b' )
     199                                irc_send_num( irc, 368, "%s :No bans possible", cmd[1] );
     200                }
     201                else
     202                        irc_send_num( irc, 324, "%s +%s", cmd[1], ic->mode );
     203        }
     204        else
     205        {
     206                if( nick_cmp( cmd[1], irc->user->nick ) == 0 )
     207                {
     208                        if( cmd[2] )
     209                                irc_umode_set( irc, cmd[2], 0 );
     210                        else
     211                                irc_send_num( irc, 221, "+%s", irc->umode );
     212                }
     213                else
     214                        irc_send_num( irc, 502, ":Don't touch their modes" );
     215        }
     216}
     217
    186218#if 0
    187219//#if 0
     
    199231        {
    200232                irc_send_num( irc, 432, ":Incorrect password" );
    201         }
    202 }
    203 
    204 static void irc_cmd_mode( irc_t *irc, char **cmd )
    205 {
    206         if( strchr( CTYPES, *cmd[1] ) )
    207         {
    208                 if( cmd[2] )
    209                 {
    210                         if( *cmd[2] == '+' || *cmd[2] == '-' )
    211                                 irc_send_num( irc, 477, "%s :Can't change channel modes", cmd[1] );
    212                         else if( *cmd[2] == 'b' )
    213                                 irc_send_num( irc, 368, "%s :No bans possible", cmd[1] );
    214                 }
    215                 else
    216                         irc_send_num( irc, 324, "%s +%s", cmd[1], CMODE );
    217         }
    218         else
    219         {
    220                 if( nick_cmp( cmd[1], irc->nick ) == 0 )
    221                 {
    222                         if( cmd[2] )
    223                                 irc_umode_set( irc, cmd[2], 0 );
    224                         else
    225                                 irc_send_num( irc, 221, "+%s", irc->umode );
    226                 }
    227                 else
    228                         irc_send_num( irc, 502, ":Don't touch their modes" );
    229233        }
    230234}
     
    566570        { "whowas",      1, irc_cmd_whowas,      IRC_CMD_LOGGED_IN },
    567571        { "motd",        0, irc_cmd_motd,        IRC_CMD_LOGGED_IN },
     572        { "mode",        1, irc_cmd_mode,        IRC_CMD_LOGGED_IN },
    568573#if 0
    569574        { "oper",        2, irc_cmd_oper,        IRC_CMD_LOGGED_IN },
    570         { "mode",        1, irc_cmd_mode,        IRC_CMD_LOGGED_IN },
    571575        { "invite",      2, irc_cmd_invite,      IRC_CMD_LOGGED_IN },
    572576        { "privmsg",     1, irc_cmd_privmsg,     IRC_CMD_LOGGED_IN },
Note: See TracChangeset for help on using the changeset viewer.