2 * ngIRCd -- The Next Generation IRC Daemon
3 * Copyright (c)2001-2005 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.17 2006/12/07 17:57:20 fw 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 bool remember = false;
69 assert( Client != NULL );
70 assert( Req != NULL );
73 return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
74 Client_ID(Client), Req->command);
76 if (Client_Type(Client) == CLIENT_SERVER)
77 from = Client_Search(Req->prefix);
81 return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG,
82 Client_ID(Client), Req->prefix);
85 target = Client_Search(Req->argv[0]);
86 if (!target || (Client_Type(target) != CLIENT_USER))
87 return IRC_WriteStrClient(from, ERR_NOSUCHNICK_MSG,
88 Client_ID(Client), Req->argv[0]);
90 chan = Channel_Search(Req->argv[1]);
92 /* Channel exists. Is the user a valid member of the channel? */
93 if (!Channel_IsMemberOf(chan, from))
94 return IRC_WriteStrClient(from, ERR_NOTONCHANNEL_MSG, Client_ID(Client), Req->argv[1]);
96 /* Is the channel "invite-only"? */
97 if (strchr(Channel_Modes(chan), 'i')) {
98 /* Yes. The user must be channel operator! */
99 if (!strchr(Channel_UserModes(chan, from), 'o'))
100 return IRC_WriteStrClient(from, ERR_CHANOPRIVSNEEDED_MSG,
101 Client_ID(from), Channel_Name(chan));
105 /* Is the target user already member of the channel? */
106 if (Channel_IsMemberOf(chan, target))
107 return IRC_WriteStrClient(from, ERR_USERONCHANNEL_MSG,
108 Client_ID(from), Req->argv[0], Req->argv[1]);
110 /* If the target user is banned on that channel: remember invite */
111 if (Lists_Check(Channel_GetListBans(chan), target))
115 /* We must remember this invite */
116 if (!Channel_AddInvite(chan, Client_Mask(target), true))
121 LogDebug("User \"%s\" invites \"%s\" to \"%s\" ...", Client_Mask(from), Req->argv[0], Req->argv[1]);
123 /* Inform target client */
124 IRC_WriteStrClientPrefix(target, from, "INVITE %s %s", Req->argv[0], Req->argv[1]);
126 if (Client_Conn(target) > NONE) {
127 /* The target user is local, so we have to send the status code */
128 if (!IRC_WriteStrClientPrefix(from, target, RPL_INVITING_MSG, Client_ID(from), Req->argv[0], Req->argv[1]))