ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/branches/8.2.x/modules/extra/m_opme.c
Revision: 9082
Committed: Sun Oct 13 09:58:37 2019 UTC (6 years, 9 months ago) by michael
Content type: text/x-csrc
File size: 4005 byte(s)
Log Message:
- Rename struct Membership to ChannelMember
- Rename Channel::last_knock to last_knock_time
- Rename Channel::last_invite to last_invite_time
- Rename chptr to channel

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 *
4 * Copyright (c) 2014-2019 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_mode.h"
39 #include "conf.h"
40
41
42 /*! \brief OPME command handler
43 *
44 * \param source_p Pointer to allocated Client struct from which the message
45 * originally comes from. This can be a local or remote client.
46 * \param parc Integer holding the number of supplied arguments.
47 * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
48 * pointers.
49 * \note Valid arguments for this command are:
50 * - parv[0] = command
51 * - parv[1] = channel name
52 */
53 static void
54 mo_opme(struct Client *source_p, int parc, char *parv[])
55 {
56 const char *const name = parv[1];
57 struct Channel *channel = NULL;
58 struct ChannelMember *member = NULL;
59 dlink_node *node = NULL;
60
61 if (EmptyString(name))
62 {
63 sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, "OPME");
64 return;
65 }
66
67 if (!HasOFlag(source_p, OPER_FLAG_OPME))
68 {
69 sendto_one_numeric(source_p, &me, ERR_NOPRIVS, "opme");
70 return;
71 }
72
73 if ((channel = hash_find_channel(name)) == NULL)
74 {
75 sendto_one_numeric(source_p, &me, ERR_NOSUCHCHANNEL, name);
76 return;
77 }
78
79 if ((member = find_channel_link(source_p, channel)) == NULL)
80 {
81 sendto_one_numeric(source_p, &me, ERR_NOTONCHANNEL, channel->name);
82 return;
83 }
84
85 DLINK_FOREACH(node, channel->members.head)
86 {
87 if (((struct ChannelMember *)node->data)->flags & CHFL_CHANOP)
88 {
89 sendto_one_notice(source_p, &me, ":Cannot use OPME on %s: channel is not opless",
90 channel->name);
91 return;
92 }
93 }
94
95 ilog(LOG_TYPE_IRCD, "%s used OPME on channel %s",
96 get_oper_name(source_p), channel->name);
97 sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_GLOBAL, "from %s: %s used OPME on channel %s",
98 me.name, get_oper_name(source_p), channel->name);
99 sendto_server(NULL, 0, 0, ":%s GLOBOPS :%s used OPME on channel %s",
100 me.id, get_oper_name(source_p), channel->name);
101
102 AddMemberFlag(member, CHFL_CHANOP);
103 sendto_channel_local(NULL, channel, 0, 0, 0, ":%s MODE %s +o %s",
104 me.name, channel->name, source_p->name);
105 sendto_server(NULL, 0, 0, ":%s TMODE %ju %s +o %s", me.id, channel->creation_time,
106 channel->name, source_p->id);
107 }
108
109 static struct Message opme_msgtab =
110 {
111 .cmd = "OPME",
112 .args_min = 2,
113 .args_max = MAXPARA,
114 .handlers[UNREGISTERED_HANDLER] = m_unregistered,
115 .handlers[CLIENT_HANDLER] = m_not_oper,
116 .handlers[SERVER_HANDLER] = m_ignore,
117 .handlers[ENCAP_HANDLER] = m_ignore,
118 .handlers[OPER_HANDLER] = mo_opme
119 };
120
121 static void
122 module_init(void)
123 {
124 mod_add_cmd(&opme_msgtab);
125 }
126
127 static void
128 module_exit(void)
129 {
130 mod_del_cmd(&opme_msgtab);
131 }
132
133 struct module module_entry =
134 {
135 .version = "$Revision$",
136 .modinit = module_init,
137 .modexit = module_exit,
138 };

Properties

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