Blame


1 ea9b72ef 2002-05-27 alex /*
2 ea9b72ef 2002-05-27 alex * ngIRCd -- The Next Generation IRC Daemon
3 ea9b72ef 2002-05-27 alex * Copyright (c)2001,2002 by Alexander Barton (alex@barton.de)
4 ea9b72ef 2002-05-27 alex *
5 ea9b72ef 2002-05-27 alex * Dieses Programm ist freie Software. Sie koennen es unter den Bedingungen
6 ea9b72ef 2002-05-27 alex * der GNU General Public License (GPL), wie von der Free Software Foundation
7 ea9b72ef 2002-05-27 alex * herausgegeben, weitergeben und/oder modifizieren, entweder unter Version 2
8 ea9b72ef 2002-05-27 alex * der Lizenz oder (wenn Sie es wuenschen) jeder spaeteren Version.
9 ea9b72ef 2002-05-27 alex * Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
10 ea9b72ef 2002-05-27 alex * der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
11 ea9b72ef 2002-05-27 alex *
12 f3c0c7c0 2002-09-08 alex * $Id: irc-op.c,v 1.9 2002/09/08 17:06:54 alex Exp $
13 ea9b72ef 2002-05-27 alex *
14 ea9b72ef 2002-05-27 alex * irc-op.c: Befehle zur Channel-Verwaltung
15 ea9b72ef 2002-05-27 alex */
16 ea9b72ef 2002-05-27 alex
17 ea9b72ef 2002-05-27 alex
18 ea9b72ef 2002-05-27 alex #include "portab.h"
19 ea9b72ef 2002-05-27 alex
20 ea9b72ef 2002-05-27 alex #include "imp.h"
21 ea9b72ef 2002-05-27 alex #include <assert.h>
22 ea9b72ef 2002-05-27 alex #include <string.h>
23 234f9472 2002-06-01 alex #include <stdio.h>
24 ea9b72ef 2002-05-27 alex
25 ea9b72ef 2002-05-27 alex #include "conn.h"
26 ea9b72ef 2002-05-27 alex #include "client.h"
27 ea9b72ef 2002-05-27 alex #include "channel.h"
28 ea9b72ef 2002-05-27 alex #include "defines.h"
29 ea9b72ef 2002-05-27 alex #include "irc-write.h"
30 adc1eedd 2002-06-02 alex #include "lists.h"
31 ea9b72ef 2002-05-27 alex #include "log.h"
32 ea9b72ef 2002-05-27 alex #include "messages.h"
33 ea9b72ef 2002-05-27 alex #include "parse.h"
34 ea9b72ef 2002-05-27 alex
35 ea9b72ef 2002-05-27 alex #include "exp.h"
36 ea9b72ef 2002-05-27 alex #include "irc-op.h"
37 ea9b72ef 2002-05-27 alex
38 ea9b72ef 2002-05-27 alex
39 ea9b72ef 2002-05-27 alex GLOBAL BOOLEAN
40 ea9b72ef 2002-05-27 alex IRC_KICK( CLIENT *Client, REQUEST *Req )
41 ea9b72ef 2002-05-27 alex {
42 234f9472 2002-06-01 alex CLIENT *target, *from;
43 234f9472 2002-06-01 alex
44 ea9b72ef 2002-05-27 alex assert( Client != NULL );
45 ea9b72ef 2002-05-27 alex assert( Req != NULL );
46 ea9b72ef 2002-05-27 alex
47 ea9b72ef 2002-05-27 alex /* Valider Client? */
48 ea9b72ef 2002-05-27 alex if(( Client_Type( Client ) != CLIENT_USER ) && ( Client_Type( Client ) != CLIENT_SERVER )) return IRC_WriteStrClient( Client, ERR_NOTREGISTERED_MSG, Client_ID( Client ));
49 ea9b72ef 2002-05-27 alex
50 234f9472 2002-06-01 alex /* Falsche Anzahl Parameter? */
51 234f9472 2002-06-01 alex if(( Req->argc < 2) || ( Req->argc > 3 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
52 ea9b72ef 2002-05-27 alex
53 234f9472 2002-06-01 alex if( Client_Type( Client ) == CLIENT_SERVER ) from = Client_Search( Req->prefix );
54 234f9472 2002-06-01 alex else from = Client;
55 234f9472 2002-06-01 alex if( ! from ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix );
56 234f9472 2002-06-01 alex
57 234f9472 2002-06-01 alex /* Ziel-User suchen */
58 234f9472 2002-06-01 alex target = Client_Search( Req->argv[1] );
59 234f9472 2002-06-01 alex if( ! target ) return IRC_WriteStrClient( from, ERR_NOSUCHNICK_MSG, Client_ID( from ), Req->argv[1] );
60 234f9472 2002-06-01 alex
61 234f9472 2002-06-01 alex Channel_Kick( target, from, Req->argv[0], Req->argc == 3 ? Req->argv[2] : Client_ID( from ));
62 ea9b72ef 2002-05-27 alex return CONNECTED;
63 ea9b72ef 2002-05-27 alex } /* IRC_KICK */
64 ea9b72ef 2002-05-27 alex
65 ea9b72ef 2002-05-27 alex
66 ea9b72ef 2002-05-27 alex GLOBAL BOOLEAN
67 ea9b72ef 2002-05-27 alex IRC_INVITE( CLIENT *Client, REQUEST *Req )
68 ea9b72ef 2002-05-27 alex {
69 adc1eedd 2002-06-02 alex CHANNEL *chan;
70 adc1eedd 2002-06-02 alex CLIENT *target, *from;
71 adc1eedd 2002-06-02 alex BOOLEAN remember = FALSE;
72 adc1eedd 2002-06-02 alex
73 ea9b72ef 2002-05-27 alex assert( Client != NULL );
74 ea9b72ef 2002-05-27 alex assert( Req != NULL );
75 ea9b72ef 2002-05-27 alex
76 ea9b72ef 2002-05-27 alex /* Valider Client? */
77 ea9b72ef 2002-05-27 alex if(( Client_Type( Client ) != CLIENT_USER ) && ( Client_Type( Client ) != CLIENT_SERVER )) return IRC_WriteStrClient( Client, ERR_NOTREGISTERED_MSG, Client_ID( Client ));
78 ea9b72ef 2002-05-27 alex
79 adc1eedd 2002-06-02 alex /* Falsche Anzahl Parameter? */
80 adc1eedd 2002-06-02 alex if( Req->argc != 2 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
81 ea9b72ef 2002-05-27 alex
82 adc1eedd 2002-06-02 alex if( Client_Type( Client ) == CLIENT_SERVER ) from = Client_Search( Req->prefix );
83 adc1eedd 2002-06-02 alex else from = Client;
84 adc1eedd 2002-06-02 alex if( ! from ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix );
85 adc1eedd 2002-06-02 alex
86 adc1eedd 2002-06-02 alex /* User suchen */
87 adc1eedd 2002-06-02 alex target = Client_Search( Req->argv[0] );
88 151babd1 2002-06-11 alex if(( ! target ) || ( Client_Type( target ) != CLIENT_USER )) return IRC_WriteStrClient( from, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->argv[0] );
89 adc1eedd 2002-06-02 alex
90 adc1eedd 2002-06-02 alex chan = Channel_Search( Req->argv[1] );
91 adc1eedd 2002-06-02 alex
92 adc1eedd 2002-06-02 alex if( chan )
93 adc1eedd 2002-06-02 alex {
94 adc1eedd 2002-06-02 alex /* Der Channel existiert bereits; ist der User Mitglied? */
95 adc1eedd 2002-06-02 alex if( ! Channel_IsMemberOf( chan, from )) return IRC_WriteStrClient( from, ERR_NOTONCHANNEL_MSG, Client_ID( Client ), Req->argv[1] );
96 adc1eedd 2002-06-02 alex
97 adc1eedd 2002-06-02 alex /* Ist der Channel "invite-only"? */
98 adc1eedd 2002-06-02 alex if( strchr( Channel_Modes( chan ), 'i' ))
99 adc1eedd 2002-06-02 alex {
100 adc1eedd 2002-06-02 alex /* Ja. Der User muss Channel-Operator sein! */
101 adc1eedd 2002-06-02 alex if( ! strchr( Channel_UserModes( chan, from ), 'o' )) return IRC_WriteStrClient( from, ERR_CHANOPRIVSNEEDED_MSG, Client_ID( from ), Channel_Name( chan ));
102 adc1eedd 2002-06-02 alex remember = TRUE;
103 adc1eedd 2002-06-02 alex }
104 adc1eedd 2002-06-02 alex
105 adc1eedd 2002-06-02 alex /* Ist der Ziel-User bereits Mitglied? */
106 adc1eedd 2002-06-02 alex if( Channel_IsMemberOf( chan, target )) return IRC_WriteStrClient( from, ERR_USERONCHANNEL_MSG, Client_ID( from ), Req->argv[0], Req->argv[1] );
107 adc1eedd 2002-06-02 alex }
108 adc1eedd 2002-06-02 alex
109 ce4b7194 2002-09-08 alex /* Wenn der User gebanned ist, so muss das Invite auch gespeichert werden */
110 ce4b7194 2002-09-08 alex if( Lists_CheckBanned( target, chan )) remember = TRUE;
111 ce4b7194 2002-09-08 alex
112 adc1eedd 2002-06-02 alex Log( LOG_DEBUG, "User \"%s\" invites \"%s\" to \"%s\" ...", Client_Mask( from ), Req->argv[0], Req->argv[1] );
113 81a26d98 2002-07-15 alex if( remember )
114 81a26d98 2002-07-15 alex {
115 f3c0c7c0 2002-09-08 alex if( ! Lists_AddInvited( from, Client_Mask( target ), chan, TRUE )) return CONNECTED;
116 81a26d98 2002-07-15 alex }
117 b1f42006 2002-07-25 alex
118 b1f42006 2002-07-25 alex /* an Ziel-Client forwarden ... */
119 adc1eedd 2002-06-02 alex IRC_WriteStrClientPrefix( target, from, "INVITE %s %s", Req->argv[0], Req->argv[1] );
120 adc1eedd 2002-06-02 alex
121 adc1eedd 2002-06-02 alex if( Client_Conn( target ) > NONE )
122 adc1eedd 2002-06-02 alex {
123 b1f42006 2002-07-25 alex /* lokaler Ziel-Client, Status-Code melden */
124 b1f42006 2002-07-25 alex if( ! IRC_WriteStrClientPrefix( from, target, RPL_INVITING_MSG, Client_ID( from ), Req->argv[0], Req->argv[1] )) return DISCONNECTED;
125 adc1eedd 2002-06-02 alex }
126 adc1eedd 2002-06-02 alex
127 ea9b72ef 2002-05-27 alex return CONNECTED;
128 ea9b72ef 2002-05-27 alex } /* IRC_INVITE */
129 ea9b72ef 2002-05-27 alex
130 ea9b72ef 2002-05-27 alex
131 ea9b72ef 2002-05-27 alex /* -eof- */