ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/extra/m_opme.c
Revision: 9857
Committed: Fri Jan 1 04:43:22 2021 UTC (4 years, 7 months ago) by michael
Content type: text/x-csrc
File size: 3955 byte(s)
Log Message:
- Bump copyright years

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 *
4 * Copyright (c) 2014-2021 ircd-hybrid development team
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 * USA
20 */
21
22 /*! \file m_opme.c
23 * \brief Includes required functions for processing the OPME command.
24 * \version $Id$
25 */
26
27 #include "stdinc.h"
28 #include "list.h"
29 #include "client.h"
30 #include "hash.h"
31 #include "ircd.h"
32 #include "numeric.h"
33 #include "log.h"
34 #include "send.h"
35 #include "irc_string.h"
36 #include "parse.h"
37 #include "modules.h"
38 #include "channel.h"
39 #include "channel_mode.h"
40 #include "conf.h"
41
42
43 /*! \brief OPME command handler
44 *
45 * \param source_p Pointer to allocated Client struct from which the message
46 * originally comes from. This can be a local or remote client.
47 * \param parc Integer holding the number of supplied arguments.
48 * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
49 * pointers.
50 * \note Valid arguments for this command are:
51 * - parv[0] = command
52 * - parv[1] = channel name
53 */
54 static void
55 mo_opme(struct Client *source_p, int parc, char *parv[])
56 {
57 const char *const name = parv[1];
58 dlink_node *node;
59
60 if (!HasOFlag(source_p, OPER_FLAG_OPME))
61 {
62 sendto_one_numeric(source_p, &me, ERR_NOPRIVS, "opme");
63 return;
64 }
65
66 struct Channel *channel = hash_find_channel(name);
67 if (channel == NULL)
68 {
69 sendto_one_numeric(source_p, &me, ERR_NOSUCHCHANNEL, name);
70 return;
71 }
72
73 struct ChannelMember *member = member_find_link(source_p, channel);
74 if (member == NULL)
75 {
76 sendto_one_numeric(source_p, &me, ERR_NOTONCHANNEL, channel->name);
77 return;
78 }
79
80 DLINK_FOREACH(node, channel->members.head)
81 {
82 const struct ChannelMember *tmp = node->data;
83
84 if (tmp->flags & CHFL_CHANOP)
85 {
86 sendto_one_notice(source_p, &me, ":Cannot use OPME on %s: channel is not opless",
87 channel->name);
88 return;
89 }
90 }
91
92 ilog(LOG_TYPE_IRCD, "%s used OPME on channel %s",
93 get_oper_name(source_p), channel->name);
94 sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_GLOBAL, "from %s: %s used OPME on channel %s",
95 me.name, get_oper_name(source_p), channel->name);
96 sendto_server(NULL, 0, 0, ":%s GLOBOPS :%s used OPME on channel %s",
97 me.id, get_oper_name(source_p), channel->name);
98
99 AddMemberFlag(member, CHFL_CHANOP);
100 sendto_channel_local(NULL, channel, 0, 0, 0, ":%s MODE %s +o %s",
101 me.name, channel->name, source_p->name);
102 sendto_server(NULL, 0, 0, ":%s TMODE %ju %s +o %s", me.id, channel->creation_time,
103 channel->name, source_p->id);
104 }
105
106 static struct Message opme_msgtab =
107 {
108 .cmd = "OPME",
109 .handlers[UNREGISTERED_HANDLER] = { .handler = m_unregistered },
110 .handlers[CLIENT_HANDLER] = { .handler = m_not_oper },
111 .handlers[SERVER_HANDLER] = { .handler = m_ignore },
112 .handlers[ENCAP_HANDLER] = { .handler = m_ignore },
113 .handlers[OPER_HANDLER] = { .handler = mo_opme, .args_min = 2 }
114 };
115
116 static void
117 module_init(void)
118 {
119 mod_add_cmd(&opme_msgtab);
120 }
121
122 static void
123 module_exit(void)
124 {
125 mod_del_cmd(&opme_msgtab);
126 }
127
128 struct module module_entry =
129 {
130 .version = "$Revision$",
131 .modinit = module_init,
132 .modexit = module_exit,
133 };

Properties

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