]> jfr.im git - solanum.git/blame - modules/m_admin.c
m_quit: add desc string
[solanum.git] / modules / m_admin.c
CommitLineData
212380e3
AC
1/*
2 * ircd-ratbox: A slightly useful ircd.
3 * m_admin.c: Sends administrative information to a user.
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"
28#include "numeric.h"
29#include "s_conf.h"
30#include "s_serv.h"
31#include "send.h"
32#include "msg.h"
33#include "parse.h"
34#include "hook.h"
35#include "modules.h"
36
428ca87b
AC
37static int m_admin(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
38static int mr_admin(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
39static int ms_admin(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
212380e3
AC
40static void do_admin(struct Client *source_p);
41
42static void admin_spy(struct Client *);
43
44struct Message admin_msgtab = {
7baa37a9 45 "ADMIN", 0, 0, 0, 0,
212380e3
AC
46 {{mr_admin, 0}, {m_admin, 0}, {ms_admin, 0}, mg_ignore, mg_ignore, {ms_admin, 0}}
47};
48
49int doing_admin_hook;
50
51mapi_clist_av1 admin_clist[] = { &admin_msgtab, NULL };
55abcbb2 52mapi_hlist_av1 admin_hlist[] = {
212380e3
AC
53 { "doing_admin", &doing_admin_hook },
54 { NULL, NULL }
55};
56
105a4985 57DECLARE_MODULE_AV2(admin, NULL, NULL, admin_clist, admin_hlist, NULL, NULL, NULL, NULL);
212380e3
AC
58
59/*
60 * mr_admin - ADMIN command handler
55abcbb2 61 * parv[1] = servername
212380e3
AC
62 */
63static int
428ca87b 64mr_admin(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
212380e3
AC
65{
66 static time_t last_used = 0L;
67
e3354945 68 if((last_used + ConfigFileEntry.pace_wait) > rb_current_time())
212380e3 69 {
55abcbb2
KB
70 sendto_one(source_p, form_str(RPL_LOAD2HI),
71 me.name,
72 EmptyString(source_p->name) ? "*" : source_p->name,
212380e3
AC
73 "ADMIN");
74 return 0;
75 }
76 else
e3354945 77 last_used = rb_current_time();
212380e3
AC
78
79 do_admin(source_p);
80
81 return 0;
82}
83
84/*
85 * m_admin - ADMIN command handler
212380e3
AC
86 * parv[1] = servername
87 */
88static int
428ca87b 89m_admin(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
212380e3
AC
90{
91 static time_t last_used = 0L;
92
93 if(parc > 1)
94 {
e3354945 95 if((last_used + ConfigFileEntry.pace_wait) > rb_current_time())
212380e3
AC
96 {
97 sendto_one(source_p, form_str(RPL_LOAD2HI),
98 me.name, source_p->name, "ADMIN");
99 return 0;
100 }
101 else
e3354945 102 last_used = rb_current_time();
55abcbb2 103
212380e3
AC
104 if(hunt_server(client_p, source_p, ":%s ADMIN :%s", 1, parc, parv) != HUNTED_ISME)
105 return 0;
106 }
107
108 do_admin(source_p);
109
110 return 0;
111}
112
113
114/*
115 * ms_admin - ADMIN command handler, used for OPERS as well
212380e3
AC
116 * parv[1] = servername
117 */
118static int
428ca87b 119ms_admin(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
212380e3
AC
120{
121 if(hunt_server(client_p, source_p, ":%s ADMIN :%s", 1, parc, parv) != HUNTED_ISME)
122 return 0;
123
124 do_admin(source_p);
125
126 return 0;
127}
128
129
130/*
131 * do_admin
132 *
133 * inputs - pointer to client to report to
134 * output - none
135 * side effects - admin info is sent to client given
136 */
137static void
138do_admin(struct Client *source_p)
139{
212380e3
AC
140 if(IsPerson(source_p))
141 admin_spy(source_p);
142
88520303 143 sendto_one_numeric(source_p, RPL_ADMINME, form_str(RPL_ADMINME), me.name);
212380e3 144 if(AdminInfo.name != NULL)
88520303 145 sendto_one_numeric(source_p, RPL_ADMINLOC1, form_str(RPL_ADMINLOC1), AdminInfo.name);
212380e3 146 if(AdminInfo.description != NULL)
88520303 147 sendto_one_numeric(source_p, RPL_ADMINLOC2, form_str(RPL_ADMINLOC2), AdminInfo.description);
212380e3 148 if(AdminInfo.email != NULL)
88520303 149 sendto_one_numeric(source_p, RPL_ADMINEMAIL, form_str(RPL_ADMINEMAIL), AdminInfo.email);
212380e3
AC
150}
151
152/* admin_spy()
153 *
154 * input - pointer to client
155 * output - none
156 * side effects - event doing_admin is called
157 */
158static void
159admin_spy(struct Client *source_p)
160{
161 hook_data hd;
162
163 hd.client = source_p;
164 hd.arg1 = hd.arg2 = NULL;
165
166 call_hook(doing_admin_hook, &hd);
167}