ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid-7.3/contrib/m_opme.c
Revision: 1028
Committed: Sun Nov 8 13:03:38 2009 UTC (16 years, 11 months ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid/contrib/m_opme.c
File size: 4467 byte(s)
Error occurred while calculating annotation data.
Log Message:
- move ircd-hybrid-7.2 to trunk

File Contents

# Content
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 #ifndef STATIC_MODULES
51 void
52 _modinit(void)
53 {
54 mod_add_cmd(&opme_msgtab);
55 }
56
57 void
58 _moddeinit(void)
59 {
60 mod_del_cmd(&opme_msgtab);
61 }
62
63 const char *_version = "$Revision$";
64 #endif
65
66 static int
67 chan_is_opless(const struct Channel *const chptr)
68 {
69 const dlink_node *ptr = NULL;
70
71 DLINK_FOREACH(ptr, chptr->members.head)
72 if (((struct Membership *)ptr->data)->flags & CHFL_CHANOP)
73 return 0;
74
75 return 1;
76 }
77
78 /*
79 * mo_opme()
80 * parv[0] = sender prefix
81 * parv[1] = channel
82 */
83 static void
84 mo_opme(struct Client *client_p, struct Client *source_p,
85 int parc, char *parv[])
86 {
87 struct Channel *chptr = NULL;
88 struct Membership *member = NULL;
89
90 if (!IsAdmin(source_p))
91 {
92 sendto_one(source_p, form_str(ERR_NOPRIVILEGES),
93 me.name, source_p->name);
94 return;
95 }
96
97 if ((chptr = hash_find_channel(parv[1])) == NULL)
98 {
99 sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
100 me.name, source_p->name, parv[1]);
101 return;
102 }
103
104 if ((member = find_channel_link(source_p, chptr)) == NULL)
105 {
106 sendto_one(source_p, form_str(ERR_NOTONCHANNEL),
107 me.name, source_p->name, chptr->chname);
108 return;
109 }
110
111 if (!chan_is_opless(chptr))
112 {
113 sendto_one(source_p, ":%s NOTICE %s :%s Channel is not opless",
114 me.name, source_p->name, chptr->chname);
115 return;
116 }
117
118 AddMemberFlag(member, CHFL_CHANOP);
119
120 if (*parv[1] == '&')
121 {
122 sendto_wallops_flags(UMODE_LOCOPS, &me,
123 "OPME called for [%s] by %s!%s@%s",
124 chptr->chname, source_p->name, source_p->username,
125 source_p->host);
126 }
127 else
128 {
129 sendto_wallops_flags(UMODE_WALLOP, &me,
130 "OPME called for [%s] by %s!%s@%s",
131 chptr->chname, source_p->name, source_p->username,
132 source_p->host);
133 sendto_server(NULL, NULL, NOCAPS, NOCAPS,
134 ":%s WALLOPS :OPME called for [%s] by %s!%s@%s",
135 me.name, chptr->chname, source_p->name, source_p->username,
136 source_p->host);
137 }
138
139 ilog(L_NOTICE, "OPME called for [%s] by %s!%s@%s",
140 chptr->chname, source_p->name, source_p->username,
141 source_p->host);
142
143 sendto_server(NULL, chptr, CAP_TS6, NOCAPS,
144 ":%s PART %s", ID(source_p), chptr->chname);
145 sendto_server(NULL, chptr, NOCAPS, CAP_TS6,
146 ":%s PART %s", source_p->name, chptr->chname);
147
148 sendto_server(NULL, chptr, CAP_TS6, NOCAPS,
149 ":%s SJOIN %lu %s + :@%s",
150 me.id, (unsigned long)chptr->channelts,
151 chptr->chname, ID(source_p));
152 sendto_server(NULL, chptr, NOCAPS, CAP_TS6,
153 ":%s SJOIN %lu %s + :@%s",
154 me.name, (unsigned long)chptr->channelts,
155 chptr->chname, source_p->name);
156
157 sendto_channel_local(ALL_MEMBERS, 0, chptr, ":%s MODE %s +o %s",
158 me.name, chptr->chname, source_p->name);
159 }

Properties

Name Value
svn:eol-style native
svn:keywords Id Revision