ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_invite.c
Revision: 1477
Committed: Sun Jul 22 15:36:30 2012 UTC (14 years, 2 months ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid-8/modules/m_invite.c
File size: 4989 byte(s)
Log Message:
- m_invite(): using INVITE now always requires channel operator status,
  regardless of channelmode 'i/p'.
  Also, halfops may no longer use the INVITE command

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 "list.h"
27 #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 #include "conf.h"
36 #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 if (EmptyString(parv[2]))
61 {
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 if (MyConnect(source_p) && (ms = find_channel_link(source_p, chptr)) == NULL)
85 {
86 sendto_one(source_p, form_str(ERR_NOTONCHANNEL),
87 me.name, source_p->name, chptr->chname);
88 return;
89 }
90
91 if (MyConnect(source_p) && !has_member_flags(ms, CHFL_CHANOP))
92 {
93 sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
94 me.name, source_p->name, chptr->chname);
95 return;
96 }
97
98 if (IsMember(target_p, chptr))
99 {
100 sendto_one(source_p, form_str(ERR_USERONCHANNEL),
101 me.name, source_p->name, target_p->name, chptr->chname);
102 return;
103 }
104
105 if (MyConnect(source_p))
106 {
107 sendto_one(source_p, form_str(RPL_INVITING), me.name,
108 source_p->name, target_p->name, chptr->chname);
109
110 if (target_p->away)
111 sendto_one(source_p, form_str(RPL_AWAY),
112 me.name, source_p->name, target_p->name,
113 target_p->away);
114 }
115 else if (parc > 3 && IsDigit(*parv[3]))
116 if (atoi(parv[3]) > chptr->channelts)
117 return;
118
119 if (MyConnect(target_p))
120 {
121 sendto_one(target_p, ":%s!%s@%s INVITE %s :%s",
122 source_p->name, source_p->username,
123 source_p->host,
124 target_p->name, chptr->chname);
125
126 if (chptr->mode.mode & MODE_INVITEONLY)
127 {
128 /* Only do this if channel is set +i AND +p */
129 sendto_channel_local(CHFL_CHANOP|CHFL_HALFOP, 0, chptr,
130 ":%s NOTICE @%s :%s is inviting %s to %s.",
131 me.name, chptr->chname, source_p->name,
132 target_p->name, chptr->chname);
133 sendto_channel_remote(source_p, client_p, CHFL_CHANOP|CHFL_HALFOP,
134 NOCAPS, NOCAPS, chptr,
135 ":%s NOTICE @%s :%s is inviting %s to %s.",
136 source_p->name, chptr->chname, source_p->name,
137 target_p->name, chptr->chname);
138 /* Add the invite if channel is +i */
139 add_invite(chptr, target_p);
140 }
141 }
142 else if (target_p->from != client_p)
143 sendto_one(target_p, ":%s INVITE %s %s %lu",
144 ID_or_name(source_p, target_p->from),
145 ID_or_name(target_p, target_p->from),
146 chptr->chname, (unsigned long)chptr->channelts);
147 }
148
149 static struct Message invite_msgtab = {
150 "INVITE", 0, 0, 3, MAXPARA, MFLG_SLOW, 0,
151 { m_unregistered, m_invite, m_invite, m_ignore, m_invite, m_ignore }
152 };
153
154 static void
155 module_init(void)
156 {
157 mod_add_cmd(&invite_msgtab);
158 }
159
160 static void
161 module_exit(void)
162 {
163 mod_del_cmd(&invite_msgtab);
164 }
165
166 struct module module_entry = {
167 .node = { NULL, NULL, NULL },
168 .name = NULL,
169 .version = "$Revision$",
170 .handle = NULL,
171 .modinit = module_init,
172 .modexit = module_exit,
173 .flags = 0
174 };

Properties

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