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