]> jfr.im git - irc/rqf/shadowircd.git/blame - modules/m_motd.c
mkpasswd: Default to MD5-based crypt instead of SHA-based.
[irc/rqf/shadowircd.git] / modules / m_motd.c
CommitLineData
212380e3 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
23 *
212380e3 24 */
25
26#include "stdinc.h"
27#include "client.h"
212380e3 28#include "ircd.h"
29#include "send.h"
30#include "numeric.h"
31#include "hook.h"
32#include "msg.h"
33#include "s_serv.h" /* hunt_server */
34#include "parse.h"
35#include "modules.h"
36#include "s_conf.h"
37#include "cache.h"
38
39static int m_motd(struct Client *, struct Client *, int, const char **);
40static int mo_motd(struct Client *, struct Client *, int, const char **);
41
42struct Message motd_msgtab = {
43 "MOTD", 0, 0, 0, MFLG_SLOW,
44 {mg_unreg, {m_motd, 0}, {mo_motd, 0}, mg_ignore, mg_ignore, {mo_motd, 0}}
45};
46
47int doing_motd_hook;
48
49mapi_clist_av1 motd_clist[] = { &motd_msgtab, NULL };
50mapi_hlist_av1 motd_hlist[] = {
51 { "doing_motd", &doing_motd_hook },
52 { NULL, NULL }
53};
54
55DECLARE_MODULE_AV1(motd, NULL, NULL, motd_clist, motd_hlist, NULL, "$Revision: 254 $");
56
57static void motd_spy(struct Client *);
58
59/*
60** m_motd
212380e3 61** parv[1] = servername
62*/
63static int
64m_motd(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
65{
66 static time_t last_used = 0;
67
9f6bbe3c 68 if((last_used + ConfigFileEntry.pace_wait) > rb_current_time())
212380e3 69 {
70 /* safe enough to give this on a local connect only */
71 sendto_one(source_p, form_str(RPL_LOAD2HI),
72 me.name, source_p->name, "MOTD");
73 sendto_one(source_p, form_str(RPL_ENDOFMOTD),
74 me.name, source_p->name);
75 return 0;
76 }
77 else
9f6bbe3c 78 last_used = rb_current_time();
212380e3 79
80 if(hunt_server(client_p, source_p, ":%s MOTD :%s", 1, parc, parv) != HUNTED_ISME)
81 return 0;
82
83 motd_spy(source_p);
84 send_user_motd(source_p);
85
86 return 0;
87}
88
89/*
90** mo_motd
212380e3 91** parv[1] = servername
92*/
93static int
94mo_motd(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
95{
96 if(hunt_server(client_p, source_p, ":%s MOTD :%s", 1, parc, parv) != HUNTED_ISME)
97 return 0;
98
99 motd_spy(source_p);
100 send_user_motd(source_p);
101
102 return 0;
103}
104
105/* motd_spy()
106 *
107 * input - pointer to client
108 * output - none
109 * side effects - hook doing_motd is called
110 */
111static void
112motd_spy(struct Client *source_p)
113{
114 hook_data data;
115
116 data.client = source_p;
117 data.arg1 = data.arg2 = NULL;
118
119 call_hook(doing_motd_hook, &data);
120}