]> jfr.im git - irc/rqf/shadowircd.git/blob - extensions/m_opme.c
[svn] - the new plan:
[irc/rqf/shadowircd.git] / extensions / m_opme.c
1 /* contrib/m_opme.c
2 * Copyright (C) 2002 Hybrid Development Team
3 * Copyright (C) 2004 ircd-ratbox development team
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 1, or (at your option)
8 * any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 *
19 * $Id: m_opme.c 3121 2007-01-02 13:23:04Z jilles $
20 */
21 #include "stdinc.h"
22 #include "tools.h"
23 #include "patricia.h"
24 #include "channel.h"
25 #include "client.h"
26 #include "ircd.h"
27 #include "numeric.h"
28 #include "s_log.h"
29 #include "s_serv.h"
30 #include "send.h"
31 #include "whowas.h"
32 #include "irc_string.h"
33 #include "hash.h"
34 #include "msg.h"
35 #include "parse.h"
36 #include "modules.h"
37 #include "s_conf.h"
38 #include "s_newconf.h"
39
40 static int mo_opme(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
41
42 struct Message opme_msgtab = {
43 "OPME", 0, 0, 0, MFLG_SLOW,
44 {mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_opme, 2}}
45 };
46
47 mapi_clist_av1 opme_clist[] = { &opme_msgtab, NULL };
48
49 DECLARE_MODULE_AV1(opme, NULL, NULL, opme_clist, NULL, NULL, "$Revision: 3121 $");
50
51
52 /*
53 ** mo_opme
54 ** parv[0] = sender prefix
55 ** parv[1] = channel
56 */
57 static int
58 mo_opme(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
59 {
60 struct Channel *chptr;
61 struct membership *msptr;
62 dlink_node *ptr;
63
64 /* admins only */
65 if(!IsOperAdmin(source_p))
66 {
67 sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "opme");
68 return 0;
69 }
70
71 if((chptr = find_channel(parv[1])) == NULL)
72 {
73 sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL,
74 form_str(ERR_NOSUCHCHANNEL), parv[1]);
75 return 0;
76 }
77
78 DLINK_FOREACH(ptr, chptr->members.head)
79 {
80 msptr = ptr->data;
81
82 if(is_chanop(msptr))
83 {
84 sendto_one(source_p, ":%s NOTICE %s :%s Channel is not opless",
85 me.name, parv[0], parv[1]);
86 return 0;
87 }
88 }
89
90 msptr = find_channel_membership(chptr, source_p);
91
92 if(msptr == NULL)
93 return 0;
94
95 msptr->flags |= CHFL_CHANOP;
96
97 sendto_wallops_flags(UMODE_WALLOP, &me,
98 "OPME called for [%s] by %s!%s@%s",
99 parv[1], source_p->name, source_p->username, source_p->host);
100 ilog(L_MAIN, "OPME called for [%s] by %s",
101 parv[1], get_oper_name(source_p));
102
103 /* dont send stuff for local channels remotely. */
104 if(*chptr->chname != '&')
105 {
106 sendto_server(NULL, NULL, NOCAPS, NOCAPS,
107 ":%s WALLOPS :OPME called for [%s] by %s!%s@%s",
108 me.name, parv[1], source_p->name, source_p->username, source_p->host);
109 sendto_server(NULL, chptr, NOCAPS, NOCAPS, ":%s PART %s", source_p->name, parv[1]);
110 sendto_server(NULL, chptr, NOCAPS, NOCAPS,
111 ":%s SJOIN %ld %s + :@%s",
112 me.name, (long) chptr->channelts, parv[1], source_p->name);
113 }
114
115 sendto_channel_local(ALL_MEMBERS, chptr,
116 ":%s MODE %s +o %s", me.name, parv[1], source_p->name);
117
118 return 0;
119 }