]> jfr.im git - solanum.git/blame - modules/m_motd.c
Replace RPL_WHOISTEXT(337) with RPL_WHOISSPECIAL(320) (#419)
[solanum.git] / modules / m_motd.c
CommitLineData
212380e3
AC
1/*
2 * ircd-ratbox: A slightly useful ircd.
3 * m_motd.c: Shows the current message of the day.
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"
212380e3
AC
27#include "ircd.h"
28#include "send.h"
29#include "numeric.h"
30#include "hook.h"
31#include "msg.h"
32#include "s_serv.h" /* hunt_server */
33#include "parse.h"
34#include "modules.h"
35#include "s_conf.h"
36#include "cache.h"
7e132ff0 37#include "ratelimit.h"
212380e3 38
eeabf33a
EM
39static const char motd_desc[] = "Provides the MOTD command to view the Message of the Day";
40
3c7d6fcc
EM
41static void m_motd(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
42static void mo_motd(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
212380e3
AC
43
44struct Message motd_msgtab = {
7baa37a9 45 "MOTD", 0, 0, 0, 0,
212380e3
AC
46 {mg_unreg, {m_motd, 0}, {mo_motd, 0}, mg_ignore, mg_ignore, {mo_motd, 0}}
47};
48
49int doing_motd_hook;
50
51mapi_clist_av1 motd_clist[] = { &motd_msgtab, NULL };
52mapi_hlist_av1 motd_hlist[] = {
53 { "doing_motd", &doing_motd_hook },
54 { NULL, NULL }
55};
56
f5ebe640 57DECLARE_MODULE_AV2(motd, NULL, NULL, motd_clist, motd_hlist, NULL, NULL, NULL, motd_desc);
212380e3
AC
58
59static void motd_spy(struct Client *);
60
61/*
62** m_motd
212380e3
AC
63** parv[1] = servername
64*/
3c7d6fcc 65static void
428ca87b 66m_motd(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
212380e3
AC
67{
68 static time_t last_used = 0;
69
20276d40
EK
70 if (parc < 2) {
71 /* do nothing */
72 } else if ((last_used + ConfigFileEntry.pace_wait) > rb_current_time() || !ratelimit_client(source_p, 6)) {
212380e3
AC
73 /* safe enough to give this on a local connect only */
74 sendto_one(source_p, form_str(RPL_LOAD2HI),
75 me.name, source_p->name, "MOTD");
76 sendto_one(source_p, form_str(RPL_ENDOFMOTD),
77 me.name, source_p->name);
3c7d6fcc 78 return;
20276d40 79 } else {
e3354945 80 last_used = rb_current_time();
20276d40 81 }
212380e3
AC
82
83 if(hunt_server(client_p, source_p, ":%s MOTD :%s", 1, parc, parv) != HUNTED_ISME)
3c7d6fcc 84 return;
212380e3
AC
85
86 motd_spy(source_p);
87 send_user_motd(source_p);
212380e3
AC
88}
89
90/*
91** mo_motd
212380e3
AC
92** parv[1] = servername
93*/
3c7d6fcc 94static void
428ca87b 95mo_motd(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
212380e3
AC
96{
97 if(hunt_server(client_p, source_p, ":%s MOTD :%s", 1, parc, parv) != HUNTED_ISME)
3c7d6fcc 98 return;
212380e3
AC
99
100 motd_spy(source_p);
101 send_user_motd(source_p);
212380e3
AC
102}
103
104/* motd_spy()
105 *
106 * input - pointer to client
107 * output - none
108 * side effects - hook doing_motd is called
109 */
110static void
111motd_spy(struct Client *source_p)
112{
113 hook_data data;
114
115 data.client = source_p;
116 data.arg1 = data.arg2 = NULL;
117
118 call_hook(doing_motd_hook, &data);
119}