ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/modules/m_invite.c
Revision: 741
Committed: Sun Jul 23 13:49:20 2006 UTC (19 years, 1 month ago) by adx
Content type: text/x-csrc
File size: 5963 byte(s)
Log Message:
+ removed s_conf.h and superseded parts of s_conf.c

File Contents

# Content
1 /*
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 * $Id$
23 */
24
25 #include "stdinc.h"
26 #include "handlers.h"
27 #include "common.h"
28 #include "channel.h"
29 #include "channel_mode.h"
30 #include "client.h"
31 #include "hash.h"
32 #include "ircd.h"
33 #include "numeric.h"
34 #include "send.h"
35 #include "s_serv.h"
36 #include "msg.h"
37 #include "parse.h"
38 #include "conf/modules.h"
39 #include "packet.h"
40
41 static void m_invite(struct Client *, struct Client *, int, char *[]);
42
43 struct Message invite_msgtab = {
44 "INVITE", 0, 0, 3, 0, MFLG_SLOW, 0,
45 { m_unregistered, m_invite, m_invite, m_ignore, m_invite, m_ignore }
46 };
47
48 INIT_MODULE(m_invite, "$Revision$")
49 {
50 mod_add_cmd(&invite_msgtab);
51 }
52
53 CLEANUP_MODULE
54 {
55 mod_del_cmd(&invite_msgtab);
56 }
57
58 /*! \brief INVITE command handler (called for clients only)
59 *
60 * \param client_p Pointer to allocated Client struct with physical connection
61 * to this server, i.e. with an open socket connected.
62 * \param source_p Pointer to allocated Client struct from which the message
63 * originally comes from. This can be a local or remote client.
64 * \param parc Integer holding the number of supplied arguments.
65 * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
66 * pointers.
67 * \note Valid arguments for this command are:
68 * - parv[0] = sender prefix
69 * - parv[1] = user to invite
70 * - parv[2] = channel name
71 * - parv[3] = invite timestamp
72 */
73 static void
74 m_invite(struct Client *client_p, struct Client *source_p,
75 int parc, char *parv[])
76 {
77 struct Client *target_p = NULL;
78 struct Channel *chptr = NULL;
79 struct Membership *ms = NULL;
80
81 if (IsServer(source_p))
82 return;
83
84 if (*parv[2] == '\0')
85 {
86 sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
87 me.name, source_p->name, "INVITE");
88 return;
89 }
90
91 if (MyClient(source_p) && !IsFloodDone(source_p))
92 flood_endgrace(source_p);
93
94 if ((target_p = find_person(client_p, parv[1])) == NULL)
95 {
96 sendto_one(source_p, form_str(ERR_NOSUCHNICK),
97 me.name, source_p->name, parv[1]);
98 return;
99 }
100
101 /*
102 * Do not send local channel invites to users if they are not on the
103 * same server as the person sending the INVITE message.
104 */
105 if ((*parv[2] == '&') && !MyConnect(target_p))
106 {
107 if (!ConfigServerHide.hide_servers)
108 sendto_one(source_p, form_str(ERR_USERNOTONSERV),
109 me.name, source_p->name, target_p->name);
110 return;
111 }
112
113 if ((chptr = hash_find_channel(parv[2])) == NULL)
114 {
115 sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
116 me.name, source_p->name, parv[2]);
117 return;
118 }
119
120 if (MyConnect(source_p) && (ms = find_channel_link(source_p, chptr)) == NULL)
121 {
122 sendto_one(source_p, form_str(ERR_NOTONCHANNEL),
123 me.name, source_p->name, chptr->chname);
124 return;
125 }
126
127 if (chptr->mode.mode & (MODE_INVITEONLY | MODE_PARANOID))
128 {
129 if (MyConnect(source_p) && !has_member_flags(ms, CHFL_CHANOP|CHFL_HALFOP))
130 {
131 sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
132 me.name, source_p->name, chptr->chname);
133 return;
134 }
135 }
136
137 if (IsMember(target_p, chptr))
138 {
139 sendto_one(source_p, form_str(ERR_USERONCHANNEL),
140 me.name, source_p->name, target_p->name, chptr->chname);
141 return;
142 }
143
144 if (MyConnect(source_p))
145 {
146 sendto_one(source_p, form_str(RPL_INVITING), me.name,
147 source_p->name, target_p->name, chptr->chname);
148
149 if (target_p->away)
150 sendto_one(source_p, form_str(RPL_AWAY),
151 me.name, source_p->name, target_p->name,
152 target_p->away);
153 }
154 else if (parc > 3 && IsDigit(*parv[3]))
155 if (atoi(parv[3]) > chptr->channelts)
156 return;
157
158 if (MyConnect(target_p))
159 {
160 sendto_one(target_p, ":%s!%s@%s INVITE %s :%s",
161 source_p->name, source_p->username,
162 source_p->host,
163 target_p->name, chptr->chname);
164
165 if (chptr->mode.mode & MODE_INVITEONLY)
166 {
167 if (chptr->mode.mode & MODE_PARANOID)
168 {
169 /* Only do this if channel is set +i AND +p */
170 sendto_channel_local(CHFL_CHANOP|CHFL_HALFOP, NO, chptr,
171 ":%s NOTICE %s :%s is inviting %s to %s.",
172 me.name, chptr->chname, source_p->name,
173 target_p->name, chptr->chname);
174 sendto_channel_remote(source_p, client_p, CHFL_CHANOP|CHFL_HALFOP,
175 NOCAPS, NOCAPS, chptr,
176 ":%s NOTICE %s :%s is inviting %s to %s.",
177 source_p->name, chptr->chname, source_p->name,
178 target_p->name, chptr->chname);
179 }
180
181 /* Add the invite if channel is +i */
182 add_invite(chptr, target_p);
183 }
184 }
185 else if (target_p->from != client_p)
186 sendto_one(target_p, ":%s INVITE %s %s %lu",
187 ID_or_name(source_p, target_p->from),
188 ID_or_name(target_p, target_p->from),
189 chptr->chname, (unsigned long)chptr->channelts);
190 }

Properties

Name Value
svn:eol-style native
svn:keywords Id Revision