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$ |
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$"; |
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 |
dlink_node *ptr; |
80 |
|
81 |
/* admins only */ |
82 |
if (!IsAdmin(source_p)) |
83 |
{ |
84 |
sendto_one(source_p, form_str(ERR_NOPRIVILEGES), |
85 |
me.name, source_p->name); |
86 |
return; |
87 |
} |
88 |
|
89 |
for (name = strtoken(&t, name, ","); name; |
90 |
name = strtoken(&t, NULL, ",")) |
91 |
{ |
92 |
switch (*name) |
93 |
{ |
94 |
case '@': |
95 |
prefix = "@"; |
96 |
flags = CHFL_CHANOP; |
97 |
modeletter = 'o'; |
98 |
++name; |
99 |
break; |
100 |
#ifdef HALFOPS |
101 |
case '%': |
102 |
prefix = "%"; |
103 |
flags = CHFL_HALFOP; |
104 |
modeletter = 'h'; |
105 |
++name; |
106 |
break; |
107 |
#endif |
108 |
case '+': |
109 |
prefix = "+"; |
110 |
flags = CHFL_VOICE; |
111 |
modeletter = 'v'; |
112 |
++name; |
113 |
break; |
114 |
case '#': |
115 |
case '&': |
116 |
prefix = ""; |
117 |
flags = 0; |
118 |
modeletter = '\0'; |
119 |
break; |
120 |
|
121 |
default: |
122 |
sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL), |
123 |
me.name, source_p->name, name); |
124 |
continue; |
125 |
} |
126 |
|
127 |
/* Error checking here */ |
128 |
if ((chptr = hash_find_channel(name)) == NULL) |
129 |
{ |
130 |
sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL), |
131 |
me.name, source_p->name, name); |
132 |
} |
133 |
else if (IsMember(source_p, chptr)) |
134 |
{ |
135 |
sendto_one(source_p, ":%s NOTICE %s :Please part %s before using OJOIN", |
136 |
me.name, source_p->name, name); |
137 |
} |
138 |
else |
139 |
{ |
140 |
add_user_to_channel(chptr, source_p, flags, NO); |
141 |
|
142 |
if (chptr->chname[0] == '#') |
143 |
DLINK_FOREACH(ptr, serv_list.head) |
144 |
{ |
145 |
struct Client *serv_p = ptr->data; |
146 |
if (IsDead(serv_p)) |
147 |
continue; |
148 |
|
149 |
sendto_server(client_p, source_p, chptr, CAP_TS6, NOCAPS, LL_ICLIENT, |
150 |
":%s SJOIN %lu %s + :%s%s", ID_or_name(&me, serv_p), |
151 |
(unsigned long)chptr->channelts, chptr->chname, |
152 |
(*prefix == '%' && !IsCapable(serv_p, CAP_HOPS)) ? |
153 |
"@" : prefix, ID_or_name(source_p, serv_p)); |
154 |
} |
155 |
|
156 |
sendto_channel_local(ALL_MEMBERS, NO, chptr, ":%s!%s@%s JOIN %s", |
157 |
source_p->name, source_p->username, |
158 |
source_p->host, |
159 |
chptr->chname); |
160 |
|
161 |
if (modeletter != '\0') |
162 |
sendto_channel_local(ALL_MEMBERS, NO, chptr, ":%s MODE %s +%c %s", |
163 |
me.name, chptr->chname, modeletter, source_p->name); |
164 |
|
165 |
/* send the topic... */ |
166 |
if (chptr->topic != NULL) |
167 |
{ |
168 |
sendto_one(source_p, form_str(RPL_TOPIC), |
169 |
me.name, source_p->name, chptr->chname, |
170 |
chptr->topic); |
171 |
sendto_one(source_p, form_str(RPL_TOPICWHOTIME), |
172 |
me.name, source_p->name, chptr->chname, |
173 |
chptr->topic_info, chptr->topic_time); |
174 |
} |
175 |
|
176 |
source_p->localClient->last_join_time = CurrentTime; |
177 |
channel_member_names(source_p, chptr, 1); |
178 |
} |
179 |
} |
180 |
} |