2 * ngIRCd -- The Next Generation IRC Daemon
3 * Copyright (c)2001-2003 by Alexander Barton (alex@barton.de)
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 * Please read the file COPYING, README and AUTHORS for more information.
11 * Channel operator commands
17 static char UNUSED id[] = "$Id: irc-op.c,v 1.13 2004/04/09 21:41:52 alex Exp $";
28 #include "irc-write.h"
39 IRC_KICK( CLIENT *Client, REQUEST *Req )
41 CLIENT *target, *from;
43 assert( Client != NULL );
44 assert( Req != NULL );
46 /* Falsche Anzahl Parameter? */
47 if(( Req->argc < 2) || ( Req->argc > 3 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
49 if( Client_Type( Client ) == CLIENT_SERVER ) from = Client_Search( Req->prefix );
51 if( ! from ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix );
53 /* Ziel-User suchen */
54 target = Client_Search( Req->argv[1] );
55 if( ! target ) return IRC_WriteStrClient( from, ERR_NOSUCHNICK_MSG, Client_ID( from ), Req->argv[1] );
57 Channel_Kick( target, from, Req->argv[0], Req->argc == 3 ? Req->argv[2] : Client_ID( from ));
63 IRC_INVITE( CLIENT *Client, REQUEST *Req )
66 CLIENT *target, *from;
67 BOOLEAN remember = FALSE;
69 assert( Client != NULL );
70 assert( Req != NULL );
72 /* Wrong number of parameters? */
73 if( Req->argc != 2 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
75 if( Client_Type( Client ) == CLIENT_SERVER ) from = Client_Search( Req->prefix );
77 if( ! from ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix );
80 target = Client_Search( Req->argv[0] );
81 if(( ! target ) || ( Client_Type( target ) != CLIENT_USER )) return IRC_WriteStrClient( from, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->argv[0] );
83 chan = Channel_Search( Req->argv[1] );
87 /* Channel exists. Is the user a valid member of the channel? */
88 if( ! Channel_IsMemberOf( chan, from )) return IRC_WriteStrClient( from, ERR_NOTONCHANNEL_MSG, Client_ID( Client ), Req->argv[1] );
90 /* Is the channel "invite-only"? */
91 if( strchr( Channel_Modes( chan ), 'i' ))
93 /* Yes. The user must be channel operator! */
94 if( ! strchr( Channel_UserModes( chan, from ), 'o' )) return IRC_WriteStrClient( from, ERR_CHANOPRIVSNEEDED_MSG, Client_ID( from ), Channel_Name( chan ));
98 /* Is the target user already member of the channel? */
99 if( Channel_IsMemberOf( chan, target )) return IRC_WriteStrClient( from, ERR_USERONCHANNEL_MSG, Client_ID( from ), Req->argv[0], Req->argv[1] );
101 /* If the target user is banned on that channel: remember invite */
102 if( Lists_CheckBanned( target, chan )) remember = TRUE;
106 /* We must memember this invite */
107 if( ! Lists_AddInvited( Client_Mask( target ), chan, TRUE )) return CONNECTED;
111 Log( LOG_DEBUG, "User \"%s\" invites \"%s\" to \"%s\" ...", Client_Mask( from ), Req->argv[0], Req->argv[1] );
113 /* Inform target client */
114 IRC_WriteStrClientPrefix( target, from, "INVITE %s %s", Req->argv[0], Req->argv[1] );
116 if( Client_Conn( target ) > NONE )
118 /* The target user is local, so we have to send the status code */
119 if( ! IRC_WriteStrClientPrefix( from, target, RPL_INVITING_MSG, Client_ID( from ), Req->argv[0], Req->argv[1] )) return DISCONNECTED;