]>
Commit | Line | Data |
---|---|---|
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 | |
23 | * | |
24 | * $Id: m_wallops.c 1377 2006-05-20 13:48:37Z jilles $ | |
25 | */ | |
26 | ||
27 | #include "stdinc.h" | |
28 | #include "client.h" | |
29 | #include "ircd.h" | |
30 | #include "irc_string.h" | |
31 | #include "numeric.h" | |
32 | #include "send.h" | |
33 | #include "s_user.h" | |
34 | #include "s_conf.h" | |
35 | #include "s_newconf.h" | |
36 | #include "msg.h" | |
37 | #include "parse.h" | |
38 | #include "modules.h" | |
39 | #include "s_serv.h" | |
40 | ||
41 | static int mo_operwall(struct Client *, struct Client *, int, const char **); | |
42 | static int ms_operwall(struct Client *, struct Client *, int, const char **); | |
43 | static int ms_wallops(struct Client *, struct Client *, int, const char **); | |
44 | ||
45 | struct Message wallops_msgtab = { | |
46 | "WALLOPS", 0, 0, 0, MFLG_SLOW, | |
47 | {mg_unreg, mg_not_oper, {ms_wallops, 2}, {ms_wallops, 2}, mg_ignore, {ms_wallops, 2}} | |
48 | }; | |
49 | struct Message operwall_msgtab = { | |
50 | "OPERWALL", 0, 0, 0, MFLG_SLOW, | |
51 | {mg_unreg, mg_not_oper, {ms_operwall, 2}, mg_ignore, mg_ignore, {mo_operwall, 2}} | |
52 | }; | |
53 | ||
54 | mapi_clist_av1 wallops_clist[] = { &wallops_msgtab, &operwall_msgtab, NULL }; | |
55 | DECLARE_MODULE_AV1(wallops, NULL, NULL, wallops_clist, NULL, NULL, "$Revision: 1377 $"); | |
56 | ||
57 | /* | |
58 | * mo_operwall (write to *all* opers currently online) | |
59 | * parv[1] = message text | |
60 | */ | |
61 | static int | |
62 | mo_operwall(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) | |
63 | { | |
64 | if(!IsOperOperwall(source_p)) | |
65 | { | |
66 | sendto_one(source_p, form_str(ERR_NOPRIVS), | |
67 | me.name, source_p->name, "operwall"); | |
68 | return 0; | |
69 | } | |
70 | ||
71 | sendto_wallops_flags(UMODE_OPERWALL, source_p, "OPERWALL - %s", parv[1]); | |
72 | sendto_server(client_p, NULL, CAP_TS6, NOCAPS, ":%s OPERWALL :%s", | |
73 | use_id(source_p), parv[1]); | |
74 | sendto_server(client_p, NULL, NOCAPS, CAP_TS6, ":%s OPERWALL :%s", | |
75 | source_p->name, parv[1]); | |
76 | ||
77 | return 0; | |
78 | } | |
79 | ||
80 | /* | |
81 | * ms_operwall - OPERWALL message handler | |
82 | * (write to *all* local opers currently online) | |
83 | * parv[0] = sender prefix | |
84 | * parv[1] = message text | |
85 | */ | |
86 | static int | |
87 | ms_operwall(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) | |
88 | { | |
89 | sendto_server(client_p, NULL, CAP_TS6, NOCAPS, ":%s OPERWALL :%s", | |
90 | use_id(source_p), parv[1]); | |
91 | sendto_server(client_p, NULL, NOCAPS, CAP_TS6, ":%s OPERWALL :%s", | |
92 | source_p->name, parv[1]); | |
93 | sendto_wallops_flags(UMODE_OPERWALL, source_p, "OPERWALL - %s", parv[1]); | |
94 | ||
95 | return 0; | |
96 | } | |
97 | ||
98 | /* | |
99 | * ms_wallops (write to *all* opers currently online) | |
100 | * parv[1] = message text | |
101 | */ | |
102 | static int | |
103 | ms_wallops(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) | |
104 | { | |
105 | const char *prefix = ""; | |
106 | ||
a6f4368b JT |
107 | if (MyClient(source_p) && !IsOperMassNotice(source_p)) |
108 | { | |
109 | sendto_one(source_p, form_str(ERR_NOPRIVS), | |
110 | me.name, source_p->name, "mass_notice"); | |
111 | return 0; | |
112 | } | |
113 | ||
212380e3 AC |
114 | if (IsPerson(source_p)) |
115 | { | |
116 | if (!strncmp(parv[1], "OPERWALL - ", 11) || | |
117 | !strncmp(parv[1], "LOCOPS - ", 9) || | |
326217c4 JT |
118 | !strncmp(parv[1], "SLOCOPS - ", 10) || |
119 | !strncmp(parv[1], "ADMINWALL - ", 12)) | |
212380e3 AC |
120 | prefix = "WALLOPS - "; |
121 | } | |
122 | ||
123 | sendto_wallops_flags(UMODE_WALLOP, source_p, "%s%s", prefix, parv[1]); | |
124 | ||
125 | sendto_server(client_p, NULL, CAP_TS6, NOCAPS, ":%s WALLOPS :%s", | |
126 | use_id(source_p), parv[1]); | |
127 | sendto_server(client_p, NULL, NOCAPS, CAP_TS6, ":%s WALLOPS :%s", | |
128 | source_p->name, parv[1]); | |
129 | ||
130 | return 0; | |
131 | } | |
132 |