1 |
/* |
2 |
* ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). |
3 |
* m_opme.c: Regains ops on opless channels |
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 "channel_mode.h" |
30 |
#include "client.h" |
31 |
#include "ircd.h" |
32 |
#include "numeric.h" |
33 |
#include "s_log.h" |
34 |
#include "s_serv.h" |
35 |
#include "send.h" |
36 |
#include "whowas.h" |
37 |
#include "irc_string.h" |
38 |
#include "hash.h" |
39 |
#include "msg.h" |
40 |
#include "parse.h" |
41 |
#include "modules.h" |
42 |
|
43 |
static void mo_opme(struct Client *, struct Client *, int, char *[]); |
44 |
|
45 |
struct Message opme_msgtab = { |
46 |
"OPME", 0, 0, 2, 0, MFLG_SLOW, 0, |
47 |
{ m_unregistered, m_not_oper, m_ignore, m_ignore, mo_opme, m_ignore } |
48 |
}; |
49 |
|
50 |
void |
51 |
_modinit(void) |
52 |
{ |
53 |
mod_add_cmd(&opme_msgtab); |
54 |
} |
55 |
|
56 |
void |
57 |
_moddeinit(void) |
58 |
{ |
59 |
mod_del_cmd(&opme_msgtab); |
60 |
} |
61 |
|
62 |
const char *_version = "$Revision$"; |
63 |
|
64 |
static int |
65 |
chan_is_opless(const struct Channel *const chptr) |
66 |
{ |
67 |
const dlink_node *ptr = NULL; |
68 |
|
69 |
DLINK_FOREACH(ptr, chptr->members.head) |
70 |
if (((struct Membership *)ptr->data)->flags & CHFL_CHANOP) |
71 |
return 0; |
72 |
|
73 |
return 1; |
74 |
} |
75 |
|
76 |
/* |
77 |
* mo_opme() |
78 |
* parv[0] = sender prefix |
79 |
* parv[1] = channel |
80 |
*/ |
81 |
static void |
82 |
mo_opme(struct Client *client_p, struct Client *source_p, |
83 |
int parc, char *parv[]) |
84 |
{ |
85 |
struct Channel *chptr = NULL; |
86 |
struct Membership *member = NULL; |
87 |
|
88 |
if (!IsAdmin(source_p)) |
89 |
{ |
90 |
sendto_one(source_p, form_str(ERR_NOPRIVILEGES), |
91 |
me.name, source_p->name); |
92 |
return; |
93 |
} |
94 |
|
95 |
if ((chptr = hash_find_channel(parv[1])) == NULL) |
96 |
{ |
97 |
sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL), |
98 |
me.name, source_p->name, parv[1]); |
99 |
return; |
100 |
} |
101 |
|
102 |
if ((member = find_channel_link(source_p, chptr)) == NULL) |
103 |
{ |
104 |
sendto_one(source_p, form_str(ERR_NOTONCHANNEL), |
105 |
me.name, source_p->name, chptr->chname); |
106 |
return; |
107 |
} |
108 |
|
109 |
if (!chan_is_opless(chptr)) |
110 |
{ |
111 |
sendto_one(source_p, ":%s NOTICE %s :%s Channel is not opless", |
112 |
me.name, source_p->name, chptr->chname); |
113 |
return; |
114 |
} |
115 |
|
116 |
AddMemberFlag(member, CHFL_CHANOP); |
117 |
|
118 |
if (*parv[1] == '&') |
119 |
{ |
120 |
sendto_wallops_flags(UMODE_LOCOPS, &me, |
121 |
"OPME called for [%s] by %s!%s@%s", |
122 |
chptr->chname, source_p->name, source_p->username, |
123 |
source_p->host); |
124 |
} |
125 |
else |
126 |
{ |
127 |
sendto_wallops_flags(UMODE_WALLOP, &me, |
128 |
"OPME called for [%s] by %s!%s@%s", |
129 |
chptr->chname, source_p->name, source_p->username, |
130 |
source_p->host); |
131 |
sendto_server(NULL, NULL, NOCAPS, NOCAPS, |
132 |
":%s WALLOPS :OPME called for [%s] by %s!%s@%s", |
133 |
me.name, chptr->chname, source_p->name, source_p->username, |
134 |
source_p->host); |
135 |
} |
136 |
|
137 |
ilog(L_NOTICE, "OPME called for [%s] by %s!%s@%s", |
138 |
chptr->chname, source_p->name, source_p->username, |
139 |
source_p->host); |
140 |
|
141 |
sendto_server(NULL, chptr, CAP_TS6, NOCAPS, |
142 |
":%s PART %s", ID(source_p), chptr->chname); |
143 |
sendto_server(NULL, chptr, NOCAPS, CAP_TS6, |
144 |
":%s PART %s", source_p->name, chptr->chname); |
145 |
|
146 |
sendto_server(NULL, chptr, CAP_TS6, NOCAPS, |
147 |
":%s SJOIN %lu %s + :@%s", |
148 |
me.id, (unsigned long)chptr->channelts, |
149 |
chptr->chname, ID(source_p)); |
150 |
sendto_server(NULL, chptr, NOCAPS, CAP_TS6, |
151 |
":%s SJOIN %lu %s + :@%s", |
152 |
me.name, (unsigned long)chptr->channelts, |
153 |
chptr->chname, source_p->name); |
154 |
|
155 |
sendto_channel_local(ALL_MEMBERS, 0, chptr, ":%s MODE %s +o %s", |
156 |
me.name, chptr->chname, source_p->name); |
157 |
} |