1 |
adx |
30 |
/* |
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 |
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 "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, 0, MFLG_SLOW, 0, |
45 |
|
|
{ m_unregistered, m_not_oper, m_ignore, m_ignore, mo_ojoin, m_ignore } |
46 |
|
|
}; |
47 |
|
|
|
48 |
|
|
#ifndef STATIC_MODULES |
49 |
|
|
void |
50 |
|
|
_modinit(void) |
51 |
|
|
{ |
52 |
|
|
mod_add_cmd(&ojoin_msgtab); |
53 |
|
|
} |
54 |
|
|
|
55 |
|
|
void |
56 |
|
|
_moddeinit(void) |
57 |
|
|
{ |
58 |
|
|
mod_del_cmd(&ojoin_msgtab); |
59 |
|
|
} |
60 |
|
|
|
61 |
knight |
31 |
const char *_version = "$Revision$"; |
62 |
adx |
30 |
#endif |
63 |
|
|
|
64 |
|
|
/* mo_ojoin() |
65 |
|
|
* parv[0] = sender prefix |
66 |
|
|
* parv[1] = channels separated by commas |
67 |
|
|
*/ |
68 |
|
|
static void |
69 |
|
|
mo_ojoin(struct Client *client_p, struct Client *source_p, |
70 |
|
|
int parc, char *parv[]) |
71 |
|
|
{ |
72 |
|
|
struct Channel *chptr = NULL; |
73 |
|
|
const char *prefix = ""; |
74 |
|
|
char modeletter = '\0'; |
75 |
|
|
char *name = parv[1]; |
76 |
|
|
char *t = NULL; |
77 |
|
|
unsigned int flags = 0; |
78 |
adx |
356 |
dlink_node *ptr; |
79 |
adx |
30 |
|
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 |
adx |
356 |
DLINK_FOREACH(ptr, serv_list.head) |
143 |
|
|
{ |
144 |
|
|
struct Client *serv_p = ptr->data; |
145 |
adx |
30 |
|
146 |
michael |
537 |
sendto_one(serv_p, ":%s SJOIN %lu %s + :%s%s", ID_or_name(&me, serv_p), |
147 |
|
|
(unsigned long)chptr->channelts, chptr->chname, |
148 |
|
|
(*prefix == '%' && !IsCapable(serv_p, CAP_HOPS)) ? |
149 |
|
|
"@" : prefix, ID_or_name(source_p, serv_p)); |
150 |
adx |
356 |
} |
151 |
|
|
|
152 |
adx |
30 |
sendto_channel_local(ALL_MEMBERS, NO, chptr, ":%s!%s@%s JOIN %s", |
153 |
|
|
source_p->name, source_p->username, |
154 |
|
|
source_p->host, |
155 |
|
|
chptr->chname); |
156 |
|
|
|
157 |
|
|
if (modeletter != '\0') |
158 |
|
|
sendto_channel_local(ALL_MEMBERS, NO, chptr, ":%s MODE %s +%c %s", |
159 |
|
|
me.name, chptr->chname, modeletter, source_p->name); |
160 |
|
|
|
161 |
|
|
/* send the topic... */ |
162 |
|
|
if (chptr->topic != NULL) |
163 |
|
|
{ |
164 |
|
|
sendto_one(source_p, form_str(RPL_TOPIC), |
165 |
|
|
me.name, source_p->name, chptr->chname, |
166 |
|
|
chptr->topic); |
167 |
|
|
sendto_one(source_p, form_str(RPL_TOPICWHOTIME), |
168 |
|
|
me.name, source_p->name, chptr->chname, |
169 |
|
|
chptr->topic_info, chptr->topic_time); |
170 |
|
|
} |
171 |
|
|
|
172 |
|
|
source_p->localClient->last_join_time = CurrentTime; |
173 |
|
|
channel_member_names(source_p, chptr, 1); |
174 |
|
|
} |
175 |
|
|
} |
176 |
|
|
} |