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 "list.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 "channel_mode.h" |
39 |
#include "common.h" |
40 |
|
41 |
static void mo_ojoin(struct Client *, struct Client *, int, char *[]); |
42 |
|
43 |
struct Message ojoin_msgtab = { |
44 |
"OJOIN", 0, 0, 2, MAXPARA, MFLG_SLOW, 0, |
45 |
{ m_unregistered, m_not_oper, m_ignore, m_ignore, mo_ojoin, m_ignore } |
46 |
}; |
47 |
|
48 |
void |
49 |
_modinit(void) |
50 |
{ |
51 |
mod_add_cmd(&ojoin_msgtab); |
52 |
} |
53 |
|
54 |
void |
55 |
_moddeinit(void) |
56 |
{ |
57 |
mod_del_cmd(&ojoin_msgtab); |
58 |
} |
59 |
|
60 |
const char *_version = "$Revision$"; |
61 |
|
62 |
/* mo_ojoin() |
63 |
* parv[0] = sender prefix |
64 |
* parv[1] = channels separated by commas |
65 |
*/ |
66 |
static void |
67 |
mo_ojoin(struct Client *client_p, struct Client *source_p, |
68 |
int parc, char *parv[]) |
69 |
{ |
70 |
struct Channel *chptr = NULL; |
71 |
const char *prefix = ""; |
72 |
char modeletter = '\0'; |
73 |
char *name = parv[1]; |
74 |
char *t = NULL; |
75 |
unsigned int flags = 0; |
76 |
dlink_node *ptr; |
77 |
|
78 |
/* admins only */ |
79 |
if (!IsAdmin(source_p)) |
80 |
{ |
81 |
sendto_one(source_p, form_str(ERR_NOPRIVILEGES), |
82 |
me.name, source_p->name); |
83 |
return; |
84 |
} |
85 |
|
86 |
for (name = strtoken(&t, name, ","); name; |
87 |
name = strtoken(&t, NULL, ",")) |
88 |
{ |
89 |
switch (*name) |
90 |
{ |
91 |
case '@': |
92 |
prefix = "@"; |
93 |
flags = CHFL_CHANOP; |
94 |
modeletter = 'o'; |
95 |
++name; |
96 |
break; |
97 |
#ifdef HALFOPS |
98 |
case '%': |
99 |
prefix = "%"; |
100 |
flags = CHFL_HALFOP; |
101 |
modeletter = 'h'; |
102 |
++name; |
103 |
break; |
104 |
#endif |
105 |
case '+': |
106 |
prefix = "+"; |
107 |
flags = CHFL_VOICE; |
108 |
modeletter = 'v'; |
109 |
++name; |
110 |
break; |
111 |
case '#': |
112 |
case '&': |
113 |
prefix = ""; |
114 |
flags = 0; |
115 |
modeletter = '\0'; |
116 |
break; |
117 |
|
118 |
default: |
119 |
sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL), |
120 |
me.name, source_p->name, name); |
121 |
continue; |
122 |
} |
123 |
|
124 |
/* Error checking here */ |
125 |
if ((chptr = hash_find_channel(name)) == NULL) |
126 |
{ |
127 |
sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL), |
128 |
me.name, source_p->name, name); |
129 |
} |
130 |
else if (IsMember(source_p, chptr)) |
131 |
{ |
132 |
sendto_one(source_p, ":%s NOTICE %s :Please part %s before using OJOIN", |
133 |
me.name, source_p->name, name); |
134 |
} |
135 |
else |
136 |
{ |
137 |
add_user_to_channel(chptr, source_p, flags, NO); |
138 |
|
139 |
if (chptr->chname[0] == '#') |
140 |
DLINK_FOREACH(ptr, serv_list.head) |
141 |
{ |
142 |
struct Client *serv_p = ptr->data; |
143 |
|
144 |
sendto_one(serv_p, ":%s SJOIN %lu %s + :%s%s", ID_or_name(&me, serv_p), |
145 |
(unsigned long)chptr->channelts, chptr->chname, |
146 |
(*prefix == '%' && !IsCapable(serv_p, CAP_HOPS)) ? |
147 |
"@" : prefix, ID_or_name(source_p, serv_p)); |
148 |
} |
149 |
|
150 |
sendto_channel_local(ALL_MEMBERS, NO, chptr, ":%s!%s@%s JOIN %s", |
151 |
source_p->name, source_p->username, |
152 |
source_p->host, |
153 |
chptr->chname); |
154 |
|
155 |
if (modeletter != '\0') |
156 |
sendto_channel_local(ALL_MEMBERS, NO, chptr, ":%s MODE %s +%c %s", |
157 |
me.name, chptr->chname, modeletter, source_p->name); |
158 |
|
159 |
/* send the topic... */ |
160 |
if (chptr->topic != NULL) |
161 |
{ |
162 |
sendto_one(source_p, form_str(RPL_TOPIC), |
163 |
me.name, source_p->name, chptr->chname, |
164 |
chptr->topic); |
165 |
sendto_one(source_p, form_str(RPL_TOPICWHOTIME), |
166 |
me.name, source_p->name, chptr->chname, |
167 |
chptr->topic_info, chptr->topic_time); |
168 |
} |
169 |
|
170 |
source_p->localClient->last_join_time = CurrentTime; |
171 |
channel_member_names(source_p, chptr, 1); |
172 |
} |
173 |
} |
174 |
} |