ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/contrib/m_ojoin.c
Revision: 30
Committed: Sun Oct 2 20:03:27 2005 UTC (18 years, 5 months ago) by adx
Content type: text/x-csrc
File size: 4944 byte(s)
Log Message:
- imported sources
- can be moved later according to the directory/branching scheme,
  but we need the svn up

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,v 1.37 2005/10/01 14:29:47 michael Exp $
23 */
24
25 #include "stdinc.h"
26 #include "tools.h"
27 #include "handlers.h"
28 #include "channel.h"
29 #include "client.h"
30 #include "ircd.h"
31 #include "numeric.h"
32 #include "send.h"
33 #include "irc_string.h"
34 #include "hash.h"
35 #include "msg.h"
36 #include "s_serv.h"
37 #include "modules.h"
38 #include "list.h"
39 #include "channel_mode.h"
40 #include "common.h"
41
42 static void mo_ojoin(struct Client *, struct Client *, int, char *[]);
43
44 struct Message ojoin_msgtab = {
45 "OJOIN", 0, 0, 2, 0, MFLG_SLOW, 0,
46 { m_unregistered, m_not_oper, m_ignore, m_ignore, mo_ojoin, m_ignore }
47 };
48
49 #ifndef STATIC_MODULES
50 void
51 _modinit(void)
52 {
53 mod_add_cmd(&ojoin_msgtab);
54 }
55
56 void
57 _moddeinit(void)
58 {
59 mod_del_cmd(&ojoin_msgtab);
60 }
61
62 const char *_version = "$Revision: 1.37 $";
63 #endif
64
65 /* mo_ojoin()
66 * parv[0] = sender prefix
67 * parv[1] = channels separated by commas
68 */
69 static void
70 mo_ojoin(struct Client *client_p, struct Client *source_p,
71 int parc, char *parv[])
72 {
73 struct Channel *chptr = NULL;
74 const char *prefix = "";
75 char modeletter = '\0';
76 char *name = parv[1];
77 char *t = NULL;
78 unsigned int flags = 0;
79
80 /* admins only */
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 {
129 sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
130 me.name, source_p->name, name);
131 }
132 else if (IsMember(source_p, chptr))
133 {
134 sendto_one(source_p, ":%s NOTICE %s :Please part %s before using OJOIN",
135 me.name, source_p->name, name);
136 }
137 else
138 {
139 add_user_to_channel(chptr, source_p, flags, NO);
140
141 if (chptr->chname[0] == '#')
142 {
143 sendto_server(client_p, source_p, chptr, CAP_TS6, NOCAPS, LL_ICLIENT,
144 ":%s SJOIN %lu %s + :%s%s",
145 me.id, (unsigned long)chptr->channelts, chptr->chname,
146 prefix, source_p->id);
147 sendto_server(client_p, source_p, chptr, NOCAPS, CAP_TS6, LL_ICLIENT,
148 ":%s SJOIN %lu %s + :%s%s",
149 me.name, (unsigned long)chptr->channelts, chptr->chname,
150 prefix, source_p->name);
151 }
152
153 sendto_channel_local(ALL_MEMBERS, NO, chptr, ":%s!%s@%s JOIN %s",
154 source_p->name, source_p->username,
155 source_p->host,
156 chptr->chname);
157
158 if (modeletter != '\0')
159 sendto_channel_local(ALL_MEMBERS, NO, chptr, ":%s MODE %s +%c %s",
160 me.name, chptr->chname, modeletter, source_p->name);
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"