ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/contrib/m_ojoin.c
Revision: 812
Committed: Thu Sep 7 09:41:54 2006 UTC (17 years, 7 months ago) by michael
Content type: text/x-csrc
File size: 5303 byte(s)
Log Message:
- Imported contrib/

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 * m_ojoin.c: Allows opers join channels with @%+ modes
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: m_ojoin.c 801 2006-08-30 16:54:25Z adx $
23 */
24
25 #include "stdinc.h"
26 #include "handlers.h"
27 #include "channel.h"
28 #include "client.h"
29 #include "ircd.h"
30 #include "numeric.h"
31 #include "send.h"
32 #include "hash.h"
33 #include "msg.h"
34 #include "server.h"
35 #include "conf/modules.h"
36 #include "channel_mode.h"
37 #include "parse.h"
38
39 static void mo_ojoin(struct Client *, struct Client *, int, char *[]);
40
41 struct Message ojoin_msgtab = {
42 "OJOIN", 0, 0, 2, 0, MFLG_SLOW, 0,
43 { m_unregistered, m_not_oper, m_ignore, m_ignore, mo_ojoin, m_ignore }
44 };
45
46 INIT_MODULE(m_ojoin, "$Revision: 801 $")
47 {
48 mod_add_cmd(&ojoin_msgtab);
49 }
50
51 CLEANUP_MODULE
52 {
53 mod_del_cmd(&ojoin_msgtab);
54 }
55
56
57 /*! \brief OJOIN command handler (called for operators only)
58 *
59 * \param client_p Pointer to allocated Client struct with physical connection
60 * to this server, i.e. with an open socket connected.
61 * \param source_p Pointer to allocated Client struct from which the message
62 * originally comes from. This can be a local or remote client.
63 * \param parc Integer holding the number of supplied arguments.
64 * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
65 * pointers.
66 * \note Valid arguments for this command are:
67 * - parv[0] = sender prefix
68 * - parv[1] = comma separated list of channels
69 */
70 static void
71 mo_ojoin(struct Client *client_p, struct Client *source_p,
72 int parc, char *parv[])
73 {
74 struct Channel *chptr = NULL;
75 const char *prefix = "";
76 char modeletter = '\0';
77 char *name = parv[1];
78 char *t = NULL;
79 unsigned int flags = 0;
80
81 if (!IsAdmin(source_p))
82 {
83 sendto_one(source_p, form_str(ERR_NOPRIVILEGES),
84 me.name, source_p->name);
85 return;
86 }
87
88 for (name = strtoken(&t, name, ","); name;
89 name = strtoken(&t, NULL, ","))
90 {
91 switch (*name)
92 {
93 case '@':
94 prefix = "@";
95 flags = CHFL_CHANOP;
96 modeletter = 'o';
97 ++name;
98 break;
99 #ifdef HALFOPS
100 case '%':
101 prefix = "%";
102 flags = CHFL_HALFOP;
103 modeletter = 'h';
104 ++name;
105 break;
106 #endif
107 case '+':
108 prefix = "+";
109 flags = CHFL_VOICE;
110 modeletter = 'v';
111 ++name;
112 break;
113 case '#':
114 case '&':
115 prefix = "";
116 flags = 0;
117 modeletter = '\0';
118 break;
119
120 default:
121 sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
122 me.name, source_p->name, name);
123 continue;
124 }
125
126 /* Error checking here */
127 if ((chptr = hash_find_channel(name)) == NULL)
128 sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
129 me.name, source_p->name, name);
130 else if (IsMember(source_p, chptr))
131 sendto_one(source_p, ":%s NOTICE %s :Please part %s before using OJOIN",
132 me.name, source_p->name, chptr->chname);
133 else
134 {
135 add_user_to_channel(chptr, source_p, flags, 0);
136
137 if (chptr->chname[0] == '#')
138 {
139 dlink_node *ptr = NULL;
140
141 DLINK_FOREACH(ptr, serv_list.head)
142 {
143 struct Client *serv_p = ptr->data;
144
145 sendto_one(serv_p, ":%s SJOIN %lu %s + :%s%s", ID_or_name(&me, serv_p),
146 (unsigned long)chptr->channelts, chptr->chname,
147 (*prefix == '%' && !IsCapable(serv_p, CAP_HOPS)) ?
148 "@" : prefix, ID_or_name(source_p, serv_p));
149 }
150 }
151
152 sendto_channel_local(ALL_MEMBERS, 0, chptr, ":%s!%s@%s JOIN %s",
153 source_p->name, source_p->username,
154 source_p->host, chptr->chname);
155
156 if (modeletter != '\0')
157 sendto_channel_local(ALL_MEMBERS, 0, chptr, ":%s MODE %s +%c %s",
158 me.name, chptr->chname, modeletter, source_p->name);
159
160 del_invite(chptr, source_p);
161
162 /* send the topic... */
163 if (chptr->topic != NULL)
164 {
165 sendto_one(source_p, form_str(RPL_TOPIC),
166 me.name, source_p->name, chptr->chname,
167 chptr->topic);
168 sendto_one(source_p, form_str(RPL_TOPICWHOTIME),
169 me.name, source_p->name, chptr->chname,
170 chptr->topic_info, chptr->topic_time);
171 }
172
173 source_p->localClient->last_join_time = CurrentTime;
174 channel_member_names(source_p, chptr, 1);
175 }
176 }
177 }

Properties

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