ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/branches/8.2.x/modules/m_motd.c
Revision: 7007
Committed: Fri Jan 1 00:09:08 2016 UTC (8 years, 3 months ago) by michael
Content type: text/x-csrc
File size: 3823 byte(s)
Log Message:
- Update copyright years

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 *
4 * Copyright (c) 1997-2016 ircd-hybrid development team
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 * USA
20 */
21
22 /*! \file m_motd.c
23 * \brief Includes required functions for processing the MOTD command.
24 * \version $Id$
25 */
26
27 #include "stdinc.h"
28 #include "list.h"
29 #include "client.h"
30 #include "motd.h"
31 #include "ircd.h"
32 #include "send.h"
33 #include "numeric.h"
34 #include "server.h"
35 #include "parse.h"
36 #include "modules.h"
37 #include "conf.h"
38
39
40 /*! \brief Sends the "message of the day" and notifies irc-operators
41 * about the MOTD request
42 *
43 * \param source_p Pointer to client to report to
44 */
45 static void
46 do_motd(struct Client *source_p)
47 {
48 sendto_realops_flags(UMODE_SPY, L_ALL, SEND_NOTICE,
49 "MOTD requested by %s (%s@%s) [%s]",
50 source_p->name, source_p->username,
51 source_p->host, source_p->servptr->name);
52 motd_send(source_p);
53 }
54
55 /*! \brief MOTD command handler
56 *
57 * \param source_p Pointer to allocated Client struct from which the message
58 * originally comes from. This can be a local or remote client.
59 * \param parc Integer holding the number of supplied arguments.
60 * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
61 * pointers.
62 * \note Valid arguments for this command are:
63 * - parv[0] = command
64 * - parv[1] = nickname/servername
65 */
66 static int
67 m_motd(struct Client *source_p, int parc, char *parv[])
68 {
69 static time_t last_used = 0;
70
71 if ((last_used + ConfigGeneral.pace_wait) > CurrentTime)
72 {
73 sendto_one_numeric(source_p, &me, RPL_LOAD2HI, "MOTD");
74 return 0;
75 }
76
77 last_used = CurrentTime;
78
79 if (!ConfigServerHide.disable_remote_commands)
80 if (hunt_server(source_p, ":%s MOTD :%s", 1, parc, parv) != HUNTED_ISME)
81 return 0;
82
83 do_motd(source_p);
84 return 0;
85 }
86
87 /*! \brief MOTD command handler
88 *
89 * \param source_p Pointer to allocated Client struct from which the message
90 * originally comes from. This can be a local or remote client.
91 * \param parc Integer holding the number of supplied arguments.
92 * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
93 * pointers.
94 * \note Valid arguments for this command are:
95 * - parv[0] = command
96 * - parv[1] = nickname/servername
97 */
98 static int
99 ms_motd(struct Client *source_p, int parc, char *parv[])
100 {
101 if (hunt_server(source_p, ":%s MOTD :%s", 1, parc, parv) != HUNTED_ISME)
102 return 0;
103
104 do_motd(source_p);
105 return 0;
106 }
107
108 static struct Message motd_msgtab =
109 {
110 .cmd = "MOTD",
111 .args_max = MAXPARA,
112 .handlers[UNREGISTERED_HANDLER] = m_unregistered,
113 .handlers[CLIENT_HANDLER] = m_motd,
114 .handlers[SERVER_HANDLER] = ms_motd,
115 .handlers[ENCAP_HANDLER] = m_ignore,
116 .handlers[OPER_HANDLER] = ms_motd
117 };
118
119 static void
120 module_init(void)
121 {
122 mod_add_cmd(&motd_msgtab);
123 }
124
125 static void
126 module_exit(void)
127 {
128 mod_del_cmd(&motd_msgtab);
129 }
130
131 struct module module_entry =
132 {
133 .version = "$Revision$",
134 .modinit = module_init,
135 .modexit = module_exit,
136 };

Properties

Name Value
svn:eol-style native
svn:keywords Id Revision