1 |
adx |
30 |
/* |
2 |
michael |
2820 |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
3 |
adx |
30 |
* |
4 |
michael |
9101 |
* Copyright (c) 1997-2020 ircd-hybrid development team |
5 |
adx |
30 |
* |
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 |
michael |
4565 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 |
19 |
adx |
30 |
* USA |
20 |
|
|
*/ |
21 |
|
|
|
22 |
michael |
2820 |
/*! \file m_motd.c |
23 |
|
|
* \brief Includes required functions for processing the MOTD command. |
24 |
|
|
* \version $Id$ |
25 |
|
|
*/ |
26 |
|
|
|
27 |
adx |
30 |
#include "stdinc.h" |
28 |
michael |
1011 |
#include "list.h" |
29 |
adx |
30 |
#include "client.h" |
30 |
|
|
#include "motd.h" |
31 |
|
|
#include "ircd.h" |
32 |
|
|
#include "send.h" |
33 |
|
|
#include "numeric.h" |
34 |
michael |
3347 |
#include "server.h" |
35 |
adx |
30 |
#include "parse.h" |
36 |
|
|
#include "modules.h" |
37 |
michael |
1309 |
#include "conf.h" |
38 |
adx |
30 |
|
39 |
|
|
|
40 |
michael |
3344 |
/*! \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 |
michael |
2967 |
static void |
46 |
michael |
1144 |
do_motd(struct Client *source_p) |
47 |
adx |
30 |
{ |
48 |
michael |
1618 |
sendto_realops_flags(UMODE_SPY, L_ALL, SEND_NOTICE, |
49 |
michael |
1144 |
"MOTD requested by %s (%s@%s) [%s]", |
50 |
|
|
source_p->name, source_p->username, |
51 |
|
|
source_p->host, source_p->servptr->name); |
52 |
michael |
2150 |
motd_send(source_p); |
53 |
adx |
30 |
} |
54 |
|
|
|
55 |
michael |
3294 |
/*! \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 |
michael |
9077 |
static void |
67 |
michael |
3156 |
m_motd(struct Client *source_p, int parc, char *parv[]) |
68 |
adx |
30 |
{ |
69 |
michael |
7330 |
static uintmax_t last_used = 0; |
70 |
adx |
30 |
|
71 |
michael |
8903 |
if ((last_used + ConfigGeneral.pace_wait) > event_base->time.sec_monotonic) |
72 |
adx |
30 |
{ |
73 |
michael |
4759 |
sendto_one_numeric(source_p, &me, RPL_LOAD2HI, "MOTD"); |
74 |
michael |
9077 |
return; |
75 |
adx |
30 |
} |
76 |
|
|
|
77 |
michael |
8903 |
last_used = event_base->time.sec_monotonic; |
78 |
michael |
589 |
|
79 |
michael |
8603 |
if (ConfigServerHide.disable_remote_commands == 0) |
80 |
michael |
9397 |
if (server_hunt(source_p, ":%s MOTD :%s", 1, parv)->ret != HUNTED_ISME) |
81 |
michael |
9077 |
return; |
82 |
adx |
30 |
|
83 |
michael |
2964 |
do_motd(source_p); |
84 |
adx |
30 |
} |
85 |
|
|
|
86 |
michael |
3294 |
/*! \brief MOTD command handler |
87 |
|
|
* |
88 |
|
|
* \param source_p Pointer to allocated Client struct from which the message |
89 |
|
|
* originally comes from. This can be a local or remote client. |
90 |
|
|
* \param parc Integer holding the number of supplied arguments. |
91 |
|
|
* \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL |
92 |
|
|
* pointers. |
93 |
|
|
* \note Valid arguments for this command are: |
94 |
|
|
* - parv[0] = command |
95 |
|
|
* - parv[1] = nickname/servername |
96 |
michael |
1230 |
*/ |
97 |
michael |
9077 |
static void |
98 |
michael |
3337 |
ms_motd(struct Client *source_p, int parc, char *parv[]) |
99 |
adx |
30 |
{ |
100 |
michael |
9397 |
if (server_hunt(source_p, ":%s MOTD :%s", 1, parv)->ret != HUNTED_ISME) |
101 |
michael |
9077 |
return; |
102 |
adx |
30 |
|
103 |
michael |
2964 |
do_motd(source_p); |
104 |
adx |
30 |
} |
105 |
michael |
1230 |
|
106 |
michael |
2820 |
static struct Message motd_msgtab = |
107 |
|
|
{ |
108 |
michael |
5881 |
.cmd = "MOTD", |
109 |
michael |
9374 |
.handlers[UNREGISTERED_HANDLER] = { .handler = m_unregistered }, |
110 |
|
|
.handlers[CLIENT_HANDLER] = { .handler = m_motd }, |
111 |
|
|
.handlers[SERVER_HANDLER] = { .handler = ms_motd }, |
112 |
|
|
.handlers[ENCAP_HANDLER] = { .handler = m_ignore }, |
113 |
|
|
.handlers[OPER_HANDLER] = { .handler = ms_motd } |
114 |
michael |
1230 |
}; |
115 |
|
|
|
116 |
|
|
static void |
117 |
|
|
module_init(void) |
118 |
|
|
{ |
119 |
|
|
mod_add_cmd(&motd_msgtab); |
120 |
|
|
} |
121 |
|
|
|
122 |
|
|
static void |
123 |
|
|
module_exit(void) |
124 |
|
|
{ |
125 |
|
|
mod_del_cmd(&motd_msgtab); |
126 |
|
|
} |
127 |
|
|
|
128 |
michael |
2820 |
struct module module_entry = |
129 |
|
|
{ |
130 |
michael |
1230 |
.version = "$Revision$", |
131 |
|
|
.modinit = module_init, |
132 |
|
|
.modexit = module_exit, |
133 |
|
|
}; |