1 |
adx |
30 |
/* |
2 |
|
|
* ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). |
3 |
|
|
* m_invite.c: Invites the user to join a channel. |
4 |
|
|
* |
5 |
|
|
* Copyright (C) 2002 by the past and present ircd coders, and others. |
6 |
|
|
* |
7 |
|
|
* This program is free software; you can redistribute it and/or modify |
8 |
|
|
* it under the terms of the GNU General Public License as published by |
9 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
10 |
|
|
* (at your option) any later version. |
11 |
|
|
* |
12 |
|
|
* This program is distributed in the hope that it will be useful, |
13 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
|
|
* GNU General Public License for more details. |
16 |
|
|
* |
17 |
|
|
* You should have received a copy of the GNU General Public License |
18 |
|
|
* along with this program; if not, write to the Free Software |
19 |
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
20 |
|
|
* USA |
21 |
|
|
* |
22 |
knight |
31 |
* $Id$ |
23 |
adx |
30 |
*/ |
24 |
|
|
|
25 |
|
|
#include "stdinc.h" |
26 |
michael |
1011 |
#include "list.h" |
27 |
adx |
30 |
#include "channel.h" |
28 |
|
|
#include "channel_mode.h" |
29 |
|
|
#include "client.h" |
30 |
|
|
#include "hash.h" |
31 |
|
|
#include "irc_string.h" |
32 |
|
|
#include "ircd.h" |
33 |
|
|
#include "numeric.h" |
34 |
|
|
#include "send.h" |
35 |
michael |
1309 |
#include "conf.h" |
36 |
adx |
30 |
#include "s_serv.h" |
37 |
|
|
#include "parse.h" |
38 |
|
|
#include "modules.h" |
39 |
|
|
#include "packet.h" |
40 |
|
|
|
41 |
|
|
|
42 |
|
|
/* |
43 |
|
|
** m_invite |
44 |
|
|
** parv[0] - sender prefix |
45 |
|
|
** parv[1] - user to invite |
46 |
|
|
** parv[2] - channel name |
47 |
|
|
** parv[3] - invite timestamp |
48 |
|
|
*/ |
49 |
|
|
static void |
50 |
|
|
m_invite(struct Client *client_p, struct Client *source_p, |
51 |
|
|
int parc, char *parv[]) |
52 |
|
|
{ |
53 |
|
|
struct Client *target_p = NULL; |
54 |
|
|
struct Channel *chptr = NULL; |
55 |
|
|
struct Membership *ms = NULL; |
56 |
|
|
|
57 |
|
|
if (IsServer(source_p)) |
58 |
|
|
return; |
59 |
|
|
|
60 |
michael |
885 |
if (EmptyString(parv[2])) |
61 |
adx |
30 |
{ |
62 |
|
|
sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), |
63 |
|
|
me.name, source_p->name, "INVITE"); |
64 |
|
|
return; |
65 |
|
|
} |
66 |
|
|
|
67 |
|
|
if (MyClient(source_p) && !IsFloodDone(source_p)) |
68 |
|
|
flood_endgrace(source_p); |
69 |
|
|
|
70 |
|
|
if ((target_p = find_person(client_p, parv[1])) == NULL) |
71 |
|
|
{ |
72 |
|
|
sendto_one(source_p, form_str(ERR_NOSUCHNICK), |
73 |
|
|
me.name, source_p->name, parv[1]); |
74 |
|
|
return; |
75 |
|
|
} |
76 |
|
|
|
77 |
|
|
if ((chptr = hash_find_channel(parv[2])) == NULL) |
78 |
|
|
{ |
79 |
|
|
sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL), |
80 |
|
|
me.name, source_p->name, parv[2]); |
81 |
|
|
return; |
82 |
|
|
} |
83 |
|
|
|
84 |
michael |
322 |
if (MyConnect(source_p) && (ms = find_channel_link(source_p, chptr)) == NULL) |
85 |
adx |
30 |
{ |
86 |
|
|
sendto_one(source_p, form_str(ERR_NOTONCHANNEL), |
87 |
|
|
me.name, source_p->name, chptr->chname); |
88 |
|
|
return; |
89 |
|
|
} |
90 |
|
|
|
91 |
db |
219 |
if ((chptr->mode.mode & (MODE_INVITEONLY | MODE_PRIVATE))) |
92 |
adx |
30 |
{ |
93 |
|
|
if (MyConnect(source_p) && !has_member_flags(ms, CHFL_CHANOP|CHFL_HALFOP)) |
94 |
|
|
{ |
95 |
|
|
sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED), |
96 |
|
|
me.name, source_p->name, chptr->chname); |
97 |
|
|
return; |
98 |
|
|
} |
99 |
|
|
} |
100 |
|
|
|
101 |
|
|
if (IsMember(target_p, chptr)) |
102 |
|
|
{ |
103 |
|
|
sendto_one(source_p, form_str(ERR_USERONCHANNEL), |
104 |
|
|
me.name, source_p->name, target_p->name, chptr->chname); |
105 |
|
|
return; |
106 |
|
|
} |
107 |
|
|
|
108 |
|
|
if (MyConnect(source_p)) |
109 |
|
|
{ |
110 |
|
|
sendto_one(source_p, form_str(RPL_INVITING), me.name, |
111 |
|
|
source_p->name, target_p->name, chptr->chname); |
112 |
|
|
|
113 |
|
|
if (target_p->away) |
114 |
|
|
sendto_one(source_p, form_str(RPL_AWAY), |
115 |
|
|
me.name, source_p->name, target_p->name, |
116 |
|
|
target_p->away); |
117 |
|
|
} |
118 |
|
|
else if (parc > 3 && IsDigit(*parv[3])) |
119 |
|
|
if (atoi(parv[3]) > chptr->channelts) |
120 |
|
|
return; |
121 |
|
|
|
122 |
|
|
if (MyConnect(target_p)) |
123 |
|
|
{ |
124 |
|
|
sendto_one(target_p, ":%s!%s@%s INVITE %s :%s", |
125 |
|
|
source_p->name, source_p->username, |
126 |
|
|
source_p->host, |
127 |
|
|
target_p->name, chptr->chname); |
128 |
|
|
|
129 |
|
|
if (chptr->mode.mode & MODE_INVITEONLY) |
130 |
|
|
{ |
131 |
|
|
if (chptr->mode.mode & MODE_PRIVATE) |
132 |
|
|
{ |
133 |
|
|
/* Only do this if channel is set +i AND +p */ |
134 |
michael |
1011 |
sendto_channel_local(CHFL_CHANOP|CHFL_HALFOP, 0, chptr, |
135 |
adx |
30 |
":%s NOTICE %s :%s is inviting %s to %s.", |
136 |
|
|
me.name, chptr->chname, source_p->name, |
137 |
|
|
target_p->name, chptr->chname); |
138 |
|
|
sendto_channel_remote(source_p, client_p, CHFL_CHANOP|CHFL_HALFOP, |
139 |
|
|
NOCAPS, NOCAPS, chptr, |
140 |
|
|
":%s NOTICE %s :%s is inviting %s to %s.", |
141 |
|
|
source_p->name, chptr->chname, source_p->name, |
142 |
|
|
target_p->name, chptr->chname); |
143 |
|
|
} |
144 |
|
|
|
145 |
|
|
/* Add the invite if channel is +i */ |
146 |
|
|
add_invite(chptr, target_p); |
147 |
|
|
} |
148 |
|
|
} |
149 |
|
|
else if (target_p->from != client_p) |
150 |
|
|
sendto_one(target_p, ":%s INVITE %s %s %lu", |
151 |
|
|
ID_or_name(source_p, target_p->from), |
152 |
|
|
ID_or_name(target_p, target_p->from), |
153 |
|
|
chptr->chname, (unsigned long)chptr->channelts); |
154 |
|
|
} |
155 |
michael |
1230 |
|
156 |
|
|
static struct Message invite_msgtab = { |
157 |
|
|
"INVITE", 0, 0, 3, MAXPARA, MFLG_SLOW, 0, |
158 |
|
|
{ m_unregistered, m_invite, m_invite, m_ignore, m_invite, m_ignore } |
159 |
|
|
}; |
160 |
|
|
|
161 |
|
|
static void |
162 |
|
|
module_init(void) |
163 |
|
|
{ |
164 |
|
|
mod_add_cmd(&invite_msgtab); |
165 |
|
|
} |
166 |
|
|
|
167 |
|
|
static void |
168 |
|
|
module_exit(void) |
169 |
|
|
{ |
170 |
|
|
mod_del_cmd(&invite_msgtab); |
171 |
|
|
} |
172 |
|
|
|
173 |
|
|
struct module module_entry = { |
174 |
|
|
.node = { NULL, NULL, NULL }, |
175 |
|
|
.name = NULL, |
176 |
|
|
.version = "$Revision$", |
177 |
|
|
.handle = NULL, |
178 |
|
|
.modinit = module_init, |
179 |
|
|
.modexit = module_exit, |
180 |
|
|
.flags = 0 |
181 |
|
|
}; |