]> jfr.im git - solanum.git/blame - extensions/m_opme.c
explicitly show IP in SNO_BANNED snotes
[solanum.git] / extensions / m_opme.c
CommitLineData
212380e3
AC
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.
212380e3
AC
18 */
19#include "stdinc.h"
212380e3
AC
20#include "channel.h"
21#include "client.h"
22#include "ircd.h"
23#include "numeric.h"
4016731b 24#include "logger.h"
212380e3
AC
25#include "s_serv.h"
26#include "send.h"
27#include "whowas.h"
4562c604 28#include "match.h"
212380e3
AC
29#include "hash.h"
30#include "msg.h"
31#include "parse.h"
32#include "modules.h"
33#include "s_conf.h"
34#include "s_newconf.h"
bd0d352f 35#include "messages.h"
212380e3 36
eeabf33a
EM
37static const char opme_desc[] = "Allow admins to op themselves on opless channels";
38
3c7d6fcc 39static void mo_opme(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
212380e3
AC
40
41struct Message opme_msgtab = {
7baa37a9 42 "OPME", 0, 0, 0, 0,
212380e3
AC
43 {mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_opme, 2}}
44};
45
46mapi_clist_av1 opme_clist[] = { &opme_msgtab, NULL };
47
02369fa7 48DECLARE_MODULE_AV2(opme, NULL, NULL, opme_clist, NULL, NULL, NULL, NULL, opme_desc);
212380e3
AC
49
50/*
51** mo_opme
212380e3
AC
52** parv[1] = channel
53*/
3c7d6fcc 54static void
760bafda 55mo_opme(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
212380e3
AC
56{
57 struct Channel *chptr;
58 struct membership *msptr;
036a10a9 59 rb_dlink_node *ptr;
212380e3
AC
60
61 /* admins only */
62 if(!IsOperAdmin(source_p))
63 {
a5ea0e0d 64 sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "admin");
3c7d6fcc 65 return;
212380e3
AC
66 }
67
68 if((chptr = find_channel(parv[1])) == NULL)
69 {
70 sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL,
71 form_str(ERR_NOSUCHCHANNEL), parv[1]);
3c7d6fcc 72 return;
212380e3
AC
73 }
74
036a10a9 75 RB_DLINK_FOREACH(ptr, chptr->members.head)
212380e3
AC
76 {
77 msptr = ptr->data;
78
79 if(is_chanop(msptr))
80 {
5366977b 81 sendto_one_notice(source_p, ":%s Channel is not opless", parv[1]);
3c7d6fcc 82 return;
212380e3
AC
83 }
84 }
85
86 msptr = find_channel_membership(chptr, source_p);
87
88 if(msptr == NULL)
3c7d6fcc 89 return;
212380e3
AC
90
91 msptr->flags |= CHFL_CHANOP;
92
93 sendto_wallops_flags(UMODE_WALLOP, &me,
94 "OPME called for [%s] by %s!%s@%s",
95 parv[1], source_p->name, source_p->username, source_p->host);
96 ilog(L_MAIN, "OPME called for [%s] by %s",
97 parv[1], get_oper_name(source_p));
98
99 /* dont send stuff for local channels remotely. */
100 if(*chptr->chname != '&')
101 {
102 sendto_server(NULL, NULL, NOCAPS, NOCAPS,
103 ":%s WALLOPS :OPME called for [%s] by %s!%s@%s",
104 me.name, parv[1], source_p->name, source_p->username, source_p->host);
8e8f4ffc 105 sendto_server(NULL, chptr, CAP_TS6, NOCAPS, ":%s PART %s", source_p->id, parv[1]);
8e8f4ffc
JT
106 sendto_server(NULL, chptr, CAP_TS6, NOCAPS,
107 ":%s SJOIN %ld %s + :@%s",
108 me.id, (long) chptr->channelts, parv[1], source_p->id);
212380e3
AC
109 }
110
4b1cce65 111 sendto_channel_local(&me, ALL_MEMBERS, chptr,
212380e3 112 ":%s MODE %s +o %s", me.name, parv[1], source_p->name);
212380e3 113}