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 490f28ff 2002-12-12 alex * This program is free software; you can redistribute it and/or modify
6 490f28ff 2002-12-12 alex * it under the terms of the GNU General Public License as published by
7 490f28ff 2002-12-12 alex * the Free Software Foundation; either version 2 of the License, or
8 490f28ff 2002-12-12 alex * (at your option) any later version.
9 490f28ff 2002-12-12 alex * Please read the file COPYING, README and AUTHORS for more information.
10 ea9b72ef 2002-05-27 alex *
11 490f28ff 2002-12-12 alex * Channel operator commands
12 ea9b72ef 2002-05-27 alex */
13 ea9b72ef 2002-05-27 alex
14 ea9b72ef 2002-05-27 alex
15 ea9b72ef 2002-05-27 alex #include "portab.h"
16 ea9b72ef 2002-05-27 alex
17 490f28ff 2002-12-12 alex static char UNUSED id[] = "$Id: irc-op.c,v 1.11 2002/12/12 12:24:18 alex Exp $";
18 490f28ff 2002-12-12 alex
19 ea9b72ef 2002-05-27 alex #include "imp.h"
20 ea9b72ef 2002-05-27 alex #include <assert.h>
21 ea9b72ef 2002-05-27 alex #include <string.h>
22 234f9472 2002-06-01 alex #include <stdio.h>
23 ea9b72ef 2002-05-27 alex
24 ea9b72ef 2002-05-27 alex #include "conn.h"
25 ea9b72ef 2002-05-27 alex #include "client.h"
26 ea9b72ef 2002-05-27 alex #include "channel.h"
27 ea9b72ef 2002-05-27 alex #include "defines.h"
28 ea9b72ef 2002-05-27 alex #include "irc-write.h"
29 adc1eedd 2002-06-02 alex #include "lists.h"
30 ea9b72ef 2002-05-27 alex #include "log.h"
31 ea9b72ef 2002-05-27 alex #include "messages.h"
32 ea9b72ef 2002-05-27 alex #include "parse.h"
33 ea9b72ef 2002-05-27 alex
34 ea9b72ef 2002-05-27 alex #include "exp.h"
35 ea9b72ef 2002-05-27 alex #include "irc-op.h"
36 ea9b72ef 2002-05-27 alex
37 ea9b72ef 2002-05-27 alex
38 ea9b72ef 2002-05-27 alex GLOBAL BOOLEAN
39 ea9b72ef 2002-05-27 alex IRC_KICK( CLIENT *Client, REQUEST *Req )
40 ea9b72ef 2002-05-27 alex {
41 234f9472 2002-06-01 alex CLIENT *target, *from;
42 234f9472 2002-06-01 alex
43 ea9b72ef 2002-05-27 alex assert( Client != NULL );
44 ea9b72ef 2002-05-27 alex assert( Req != NULL );
45 ea9b72ef 2002-05-27 alex
46 234f9472 2002-06-01 alex /* Falsche Anzahl Parameter? */
47 234f9472 2002-06-01 alex if(( Req->argc < 2) || ( Req->argc > 3 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
48 ea9b72ef 2002-05-27 alex
49 234f9472 2002-06-01 alex if( Client_Type( Client ) == CLIENT_SERVER ) from = Client_Search( Req->prefix );
50 234f9472 2002-06-01 alex else from = Client;
51 234f9472 2002-06-01 alex if( ! from ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix );
52 234f9472 2002-06-01 alex
53 234f9472 2002-06-01 alex /* Ziel-User suchen */
54 234f9472 2002-06-01 alex target = Client_Search( Req->argv[1] );
55 234f9472 2002-06-01 alex if( ! target ) return IRC_WriteStrClient( from, ERR_NOSUCHNICK_MSG, Client_ID( from ), Req->argv[1] );
56 234f9472 2002-06-01 alex
57 234f9472 2002-06-01 alex Channel_Kick( target, from, Req->argv[0], Req->argc == 3 ? Req->argv[2] : Client_ID( from ));
58 ea9b72ef 2002-05-27 alex return CONNECTED;
59 ea9b72ef 2002-05-27 alex } /* IRC_KICK */
60 ea9b72ef 2002-05-27 alex
61 ea9b72ef 2002-05-27 alex
62 ea9b72ef 2002-05-27 alex GLOBAL BOOLEAN
63 ea9b72ef 2002-05-27 alex IRC_INVITE( CLIENT *Client, REQUEST *Req )
64 ea9b72ef 2002-05-27 alex {
65 adc1eedd 2002-06-02 alex CHANNEL *chan;
66 adc1eedd 2002-06-02 alex CLIENT *target, *from;
67 adc1eedd 2002-06-02 alex BOOLEAN remember = FALSE;
68 adc1eedd 2002-06-02 alex
69 ea9b72ef 2002-05-27 alex assert( Client != NULL );
70 ea9b72ef 2002-05-27 alex assert( Req != NULL );
71 ea9b72ef 2002-05-27 alex
72 adc1eedd 2002-06-02 alex /* Falsche Anzahl Parameter? */
73 adc1eedd 2002-06-02 alex if( Req->argc != 2 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
74 ea9b72ef 2002-05-27 alex
75 adc1eedd 2002-06-02 alex if( Client_Type( Client ) == CLIENT_SERVER ) from = Client_Search( Req->prefix );
76 adc1eedd 2002-06-02 alex else from = Client;
77 adc1eedd 2002-06-02 alex if( ! from ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix );
78 adc1eedd 2002-06-02 alex
79 adc1eedd 2002-06-02 alex /* User suchen */
80 adc1eedd 2002-06-02 alex target = Client_Search( Req->argv[0] );
81 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] );
82 adc1eedd 2002-06-02 alex
83 adc1eedd 2002-06-02 alex chan = Channel_Search( Req->argv[1] );
84 adc1eedd 2002-06-02 alex
85 adc1eedd 2002-06-02 alex if( chan )
86 adc1eedd 2002-06-02 alex {
87 adc1eedd 2002-06-02 alex /* Der Channel existiert bereits; ist der User Mitglied? */
88 adc1eedd 2002-06-02 alex if( ! Channel_IsMemberOf( chan, from )) return IRC_WriteStrClient( from, ERR_NOTONCHANNEL_MSG, Client_ID( Client ), Req->argv[1] );
89 adc1eedd 2002-06-02 alex
90 adc1eedd 2002-06-02 alex /* Ist der Channel "invite-only"? */
91 adc1eedd 2002-06-02 alex if( strchr( Channel_Modes( chan ), 'i' ))
92 adc1eedd 2002-06-02 alex {
93 adc1eedd 2002-06-02 alex /* Ja. Der User muss Channel-Operator sein! */
94 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 ));
95 adc1eedd 2002-06-02 alex remember = TRUE;
96 adc1eedd 2002-06-02 alex }
97 adc1eedd 2002-06-02 alex
98 adc1eedd 2002-06-02 alex /* Ist der Ziel-User bereits Mitglied? */
99 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] );
100 adc1eedd 2002-06-02 alex }
101 adc1eedd 2002-06-02 alex
102 ce4b7194 2002-09-08 alex /* Wenn der User gebanned ist, so muss das Invite auch gespeichert werden */
103 ce4b7194 2002-09-08 alex if( Lists_CheckBanned( target, chan )) remember = TRUE;
104 ce4b7194 2002-09-08 alex
105 adc1eedd 2002-06-02 alex Log( LOG_DEBUG, "User \"%s\" invites \"%s\" to \"%s\" ...", Client_Mask( from ), Req->argv[0], Req->argv[1] );
106 81a26d98 2002-07-15 alex if( remember )
107 81a26d98 2002-07-15 alex {
108 f3c0c7c0 2002-09-08 alex if( ! Lists_AddInvited( from, Client_Mask( target ), chan, TRUE )) return CONNECTED;
109 81a26d98 2002-07-15 alex }
110 b1f42006 2002-07-25 alex
111 b1f42006 2002-07-25 alex /* an Ziel-Client forwarden ... */
112 adc1eedd 2002-06-02 alex IRC_WriteStrClientPrefix( target, from, "INVITE %s %s", Req->argv[0], Req->argv[1] );
113 adc1eedd 2002-06-02 alex
114 adc1eedd 2002-06-02 alex if( Client_Conn( target ) > NONE )
115 adc1eedd 2002-06-02 alex {
116 b1f42006 2002-07-25 alex /* lokaler Ziel-Client, Status-Code melden */
117 b1f42006 2002-07-25 alex if( ! IRC_WriteStrClientPrefix( from, target, RPL_INVITING_MSG, Client_ID( from ), Req->argv[0], Req->argv[1] )) return DISCONNECTED;
118 adc1eedd 2002-06-02 alex }
119 adc1eedd 2002-06-02 alex
120 ea9b72ef 2002-05-27 alex return CONNECTED;
121 ea9b72ef 2002-05-27 alex } /* IRC_INVITE */
122 ea9b72ef 2002-05-27 alex
123 ea9b72ef 2002-05-27 alex
124 ea9b72ef 2002-05-27 alex /* -eof- */