ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid-8/contrib/m_opme.c
Revision: 1268
Committed: Wed Jan 18 08:20:31 2012 UTC (14 years, 6 months ago) by michael
Content type: text/x-csrc
File size: 4464 byte(s)
Log Message:
- get contributed modules to work with new module api

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

Properties

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