ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_invite.c
Revision: 1156
Committed: Tue Aug 9 20:29:20 2011 UTC (14 years, 11 months ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid-8/modules/m_invite.c
File size: 5643 byte(s)
Log Message:
- create ircd-hybrid-8 "branch"

File Contents

# User Rev Content
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 "handlers.h"
28     #include "channel.h"
29     #include "channel_mode.h"
30     #include "client.h"
31     #include "hash.h"
32     #include "irc_string.h"
33     #include "ircd.h"
34     #include "numeric.h"
35     #include "send.h"
36     #include "s_conf.h"
37     #include "s_serv.h"
38     #include "msg.h"
39     #include "parse.h"
40     #include "modules.h"
41     #include "packet.h"
42    
43     static void m_invite(struct Client *, struct Client *, int, char *[]);
44    
45     struct Message invite_msgtab = {
46     "INVITE", 0, 0, 3, 0, MFLG_SLOW, 0,
47     { m_unregistered, m_invite, m_invite, m_ignore, m_invite, m_ignore }
48     };
49    
50     void
51     _modinit(void)
52     {
53     mod_add_cmd(&invite_msgtab);
54     }
55    
56     void
57     _moddeinit(void)
58     {
59     mod_del_cmd(&invite_msgtab);
60     }
61    
62 knight 31 const char *_version = "$Revision$";
63 adx 30
64     /*
65     ** m_invite
66     ** parv[0] - sender prefix
67     ** parv[1] - user to invite
68     ** parv[2] - channel name
69     ** parv[3] - invite timestamp
70     */
71     static void
72     m_invite(struct Client *client_p, struct Client *source_p,
73     int parc, char *parv[])
74     {
75     struct Client *target_p = NULL;
76     struct Channel *chptr = NULL;
77     struct Membership *ms = NULL;
78    
79     if (IsServer(source_p))
80     return;
81    
82 michael 885 if (EmptyString(parv[2]))
83 adx 30 {
84     sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
85     me.name, source_p->name, "INVITE");
86     return;
87     }
88    
89     if (MyClient(source_p) && !IsFloodDone(source_p))
90     flood_endgrace(source_p);
91    
92     if ((target_p = find_person(client_p, parv[1])) == NULL)
93     {
94     sendto_one(source_p, form_str(ERR_NOSUCHNICK),
95     me.name, source_p->name, parv[1]);
96     return;
97     }
98    
99     /* Do not send local channel invites to users if they are not on the
100     * same server as the person sending the INVITE message.
101     */
102     /* Possibly should be an error sent to source_p */
103     /* done .. there should be no problem because MyConnect(source_p) should
104     * always be true if parse() and such is working correctly --is
105     */
106     if (!MyConnect(target_p) && (*parv[2] == '&'))
107     {
108     if (ConfigServerHide.hide_servers == 0)
109     sendto_one(source_p, form_str(ERR_USERNOTONSERV),
110     me.name, source_p->name, target_p->name);
111     return;
112     }
113    
114     if ((chptr = hash_find_channel(parv[2])) == NULL)
115     {
116     sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
117     me.name, source_p->name, parv[2]);
118     return;
119     }
120    
121 michael 322 if (MyConnect(source_p) && (ms = find_channel_link(source_p, chptr)) == NULL)
122 adx 30 {
123     sendto_one(source_p, form_str(ERR_NOTONCHANNEL),
124     me.name, source_p->name, chptr->chname);
125     return;
126     }
127    
128 db 219 if ((chptr->mode.mode & (MODE_INVITEONLY | MODE_PRIVATE)))
129 adx 30 {
130     if (MyConnect(source_p) && !has_member_flags(ms, CHFL_CHANOP|CHFL_HALFOP))
131     {
132     sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
133     me.name, source_p->name, chptr->chname);
134     return;
135     }
136     }
137    
138     if (IsMember(target_p, chptr))
139     {
140     sendto_one(source_p, form_str(ERR_USERONCHANNEL),
141     me.name, source_p->name, target_p->name, chptr->chname);
142     return;
143     }
144    
145     if (MyConnect(source_p))
146     {
147     sendto_one(source_p, form_str(RPL_INVITING), me.name,
148     source_p->name, target_p->name, chptr->chname);
149    
150     if (target_p->away)
151     sendto_one(source_p, form_str(RPL_AWAY),
152     me.name, source_p->name, target_p->name,
153     target_p->away);
154     }
155     else if (parc > 3 && IsDigit(*parv[3]))
156     if (atoi(parv[3]) > chptr->channelts)
157     return;
158    
159     if (MyConnect(target_p))
160     {
161     sendto_one(target_p, ":%s!%s@%s INVITE %s :%s",
162     source_p->name, source_p->username,
163     source_p->host,
164     target_p->name, chptr->chname);
165    
166     if (chptr->mode.mode & MODE_INVITEONLY)
167     {
168     if (chptr->mode.mode & MODE_PRIVATE)
169     {
170     /* Only do this if channel is set +i AND +p */
171 michael 1011 sendto_channel_local(CHFL_CHANOP|CHFL_HALFOP, 0, chptr,
172 adx 30 ":%s NOTICE %s :%s is inviting %s to %s.",
173     me.name, chptr->chname, source_p->name,
174     target_p->name, chptr->chname);
175     sendto_channel_remote(source_p, client_p, CHFL_CHANOP|CHFL_HALFOP,
176     NOCAPS, NOCAPS, chptr,
177     ":%s NOTICE %s :%s is inviting %s to %s.",
178     source_p->name, chptr->chname, source_p->name,
179     target_p->name, chptr->chname);
180     }
181    
182     /* Add the invite if channel is +i */
183     add_invite(chptr, target_p);
184     }
185     }
186     else if (target_p->from != client_p)
187     sendto_one(target_p, ":%s INVITE %s %s %lu",
188     ID_or_name(source_p, target_p->from),
189     ID_or_name(target_p, target_p->from),
190     chptr->chname, (unsigned long)chptr->channelts);
191     }

Properties

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