]> jfr.im git - solanum.git/blame - modules/m_wallops.c
extensions/umode_hide_idle_time: mask times for hidden sources (#373)
[solanum.git] / modules / m_wallops.c
CommitLineData
212380e3
AC
1/*
2 * ircd-ratbox: A slightly useful ircd.
3 * m_wallops.c: Sends a message to all operators.
4 *
5 * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
6 * Copyright (C) 1996-2002 Hybrid Development Team
7 * Copyright (C) 2002-2005 ircd-ratbox development team
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22 * USA
212380e3
AC
23 */
24
25#include "stdinc.h"
26#include "client.h"
27#include "ircd.h"
4562c604 28#include "match.h"
212380e3
AC
29#include "numeric.h"
30#include "send.h"
31#include "s_user.h"
32#include "s_conf.h"
33#include "s_newconf.h"
34#include "msg.h"
35#include "parse.h"
36#include "modules.h"
37#include "s_serv.h"
38
eeabf33a
EM
39static const char wallops_desc[] =
40 "Provides the WALLOPS and OPERWALL commands to message online operators";
41
3c7d6fcc
EM
42static void mo_operwall(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
43static void ms_operwall(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
44static void ms_wallops(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
212380e3
AC
45
46struct Message wallops_msgtab = {
7baa37a9 47 "WALLOPS", 0, 0, 0, 0,
212380e3
AC
48 {mg_unreg, mg_not_oper, {ms_wallops, 2}, {ms_wallops, 2}, mg_ignore, {ms_wallops, 2}}
49};
50struct Message operwall_msgtab = {
7baa37a9 51 "OPERWALL", 0, 0, 0, 0,
212380e3
AC
52 {mg_unreg, mg_not_oper, {ms_operwall, 2}, mg_ignore, mg_ignore, {mo_operwall, 2}}
53};
54
55mapi_clist_av1 wallops_clist[] = { &wallops_msgtab, &operwall_msgtab, NULL };
eeabf33a 56
3bf449fe 57DECLARE_MODULE_AV2(wallops, NULL, NULL, wallops_clist, NULL, NULL, NULL, NULL, wallops_desc);
212380e3
AC
58
59/*
60 * mo_operwall (write to *all* opers currently online)
61 * parv[1] = message text
62 */
3c7d6fcc 63static void
428ca87b 64mo_operwall(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
212380e3
AC
65{
66 if(!IsOperOperwall(source_p))
67 {
68 sendto_one(source_p, form_str(ERR_NOPRIVS),
69 me.name, source_p->name, "operwall");
3c7d6fcc 70 return;
212380e3
AC
71 }
72
73 sendto_wallops_flags(UMODE_OPERWALL, source_p, "OPERWALL - %s", parv[1]);
55abcbb2 74 sendto_server(client_p, NULL, CAP_TS6, NOCAPS, ":%s OPERWALL :%s",
212380e3 75 use_id(source_p), parv[1]);
212380e3
AC
76}
77
78/*
79 * ms_operwall - OPERWALL message handler
80 * (write to *all* local opers currently online)
212380e3
AC
81 * parv[1] = message text
82 */
3c7d6fcc 83static void
428ca87b 84ms_operwall(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
212380e3
AC
85{
86 sendto_server(client_p, NULL, CAP_TS6, NOCAPS, ":%s OPERWALL :%s",
87 use_id(source_p), parv[1]);
212380e3 88 sendto_wallops_flags(UMODE_OPERWALL, source_p, "OPERWALL - %s", parv[1]);
212380e3
AC
89}
90
91/*
92 * ms_wallops (write to *all* opers currently online)
93 * parv[1] = message text
94 */
3c7d6fcc 95static void
428ca87b 96ms_wallops(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
212380e3
AC
97{
98 const char *prefix = "";
99
d04ed5c5 100 if (MyClient(source_p) && !HasPrivilege(source_p, "oper:wallops"))
a6f4368b
JT
101 {
102 sendto_one(source_p, form_str(ERR_NOPRIVS),
d04ed5c5 103 me.name, source_p->name, "wallops");
3c7d6fcc 104 return;
a6f4368b
JT
105 }
106
212380e3
AC
107 if (IsPerson(source_p))
108 {
109 if (!strncmp(parv[1], "OPERWALL - ", 11) ||
110 !strncmp(parv[1], "LOCOPS - ", 9) ||
326217c4
JT
111 !strncmp(parv[1], "SLOCOPS - ", 10) ||
112 !strncmp(parv[1], "ADMINWALL - ", 12))
212380e3
AC
113 prefix = "WALLOPS - ";
114 }
115
116 sendto_wallops_flags(UMODE_WALLOP, source_p, "%s%s", prefix, parv[1]);
117
55abcbb2 118 sendto_server(client_p, NULL, CAP_TS6, NOCAPS, ":%s WALLOPS :%s",
212380e3 119 use_id(source_p), parv[1]);
212380e3
AC
120}
121