]> jfr.im git - irc/rqf/shadowircd.git/blob - extensions/m_opme.c
make all extensions libratbox-clean.
[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 3554 2007-08-10 22:31:14Z jilles $
20 */
21 #include "stdinc.h"
22 #include "tools.h"
23 #include "channel.h"
24 #include "client.h"
25 #include "ircd.h"
26 #include "numeric.h"
27 #include "s_log.h"
28 #include "s_serv.h"
29 #include "send.h"
30 #include "whowas.h"
31 #include "irc_string.h"
32 #include "hash.h"
33 #include "msg.h"
34 #include "parse.h"
35 #include "modules.h"
36 #include "s_conf.h"
37 #include "s_newconf.h"
38
39 static int mo_opme(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
40
41 struct Message opme_msgtab = {
42 "OPME", 0, 0, 0, MFLG_SLOW,
43 {mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_opme, 2}}
44 };
45
46 mapi_clist_av1 opme_clist[] = { &opme_msgtab, NULL };
47
48 DECLARE_MODULE_AV1(opme, NULL, NULL, opme_clist, NULL, NULL, "$Revision: 3554 $");
49
50
51 /*
52 ** mo_opme
53 ** parv[0] = sender prefix
54 ** parv[1] = channel
55 */
56 static int
57 mo_opme(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
58 {
59 struct Channel *chptr;
60 struct membership *msptr;
61 rb_dlink_node *ptr;
62
63 /* admins only */
64 if(!IsOperAdmin(source_p))
65 {
66 sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "admin");
67 return 0;
68 }
69
70 if((chptr = find_channel(parv[1])) == NULL)
71 {
72 sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL,
73 form_str(ERR_NOSUCHCHANNEL), parv[1]);
74 return 0;
75 }
76
77 RB_DLINK_FOREACH(ptr, chptr->members.head)
78 {
79 msptr = ptr->data;
80
81 if(is_chanop(msptr))
82 {
83 sendto_one_notice(source_p, ":%s Channel is not opless", parv[1]);
84 return 0;
85 }
86 }
87
88 msptr = find_channel_membership(chptr, source_p);
89
90 if(msptr == NULL)
91 return 0;
92
93 msptr->flags |= CHFL_CHANOP;
94
95 sendto_wallops_flags(UMODE_WALLOP, &me,
96 "OPME called for [%s] by %s!%s@%s",
97 parv[1], source_p->name, source_p->username, source_p->host);
98 ilog(L_MAIN, "OPME called for [%s] by %s",
99 parv[1], get_oper_name(source_p));
100
101 /* dont send stuff for local channels remotely. */
102 if(*chptr->chname != '&')
103 {
104 sendto_server(NULL, NULL, NOCAPS, NOCAPS,
105 ":%s WALLOPS :OPME called for [%s] by %s!%s@%s",
106 me.name, parv[1], source_p->name, source_p->username, source_p->host);
107 sendto_server(NULL, chptr, CAP_TS6, NOCAPS, ":%s PART %s", source_p->id, parv[1]);
108 sendto_server(NULL, chptr, NOCAPS, CAP_TS6, ":%s PART %s", source_p->name, parv[1]);
109 sendto_server(NULL, chptr, CAP_TS6, NOCAPS,
110 ":%s SJOIN %ld %s + :@%s",
111 me.id, (long) chptr->channelts, parv[1], source_p->id);
112 sendto_server(NULL, chptr, NOCAPS, CAP_TS6,
113 ":%s SJOIN %ld %s + :@%s",
114 me.name, (long) chptr->channelts, parv[1], source_p->name);
115 }
116
117 sendto_channel_local(ALL_MEMBERS, chptr,
118 ":%s MODE %s +o %s", me.name, parv[1], source_p->name);
119
120 return 0;
121 }