2 * IRC - Internet Relay Chat, ircd/motd.c
3 * Copyright (C) 1990 Jarkko Oikarinen and
4 * University of Oulu, Computing Center
5 * Copyright (C) 2000 Kevin L. Mitchell <klmitch@mit.edu>
7 * See file AUTHORS in IRC package for additional names of
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 1, or (at your option)
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 #include "ircd_reply.h"
30 #include "ircd_string.h"
43 /* This routine returns the TRecord structure for a user, or 0 if there
44 * is no matching T-line--in which case, we should use the standard
48 motd_find(struct Client* cptr)
56 class = get_client_class(cptr);
58 for (ptr = tdata; ptr; ptr = ptr->next) {
59 if (class >= 0 && IsDigit(*ptr->hostmask)) {
60 if (atoi(ptr->hostmask) == class)
62 } else if (!match(ptr->hostmask, cptr->sockhost))
69 /* This routine is used to send the MOTD off to a user. */
71 motd_send(struct Client* cptr, struct TRecord* trec)
73 struct MotdItem *t_motd;
79 if (!MyUser(cptr)) { /* not our user, send the remote MOTD */
82 } else if (trec) { /* We were given a TRecord */
84 t_tm = &trec->tmotd_tm;
85 } else { /* use the basic MOTD */
90 if (!t_motd) /* No motd to send */
91 return send_reply(cptr, ERR_NOMOTD);
93 /* this is a change; we now always send the start numeric */
94 send_reply(cptr, RPL_MOTDSTART, me.name);
96 if (t_tm) { /* We should probably go for ISO dates here: yyyy-mm-dd. */
97 send_reply(cptr, SND_EXPLICIT | RPL_MOTD, ":- %d/%d/%d %d:%02d",
98 t_tm->tm_mday, t_tm->tm_mon + 1, 1900 + t_tm->tm_year,
99 t_tm->tm_hour, t_tm->tm_min);
104 for (; t_motd; t_motd = t_motd->next) { /* send along the MOTD */
105 send_reply(cptr, RPL_MOTD, t_motd->line);
110 send_reply(cptr, RPL_ENDOFMOTD); /* end */
112 return 0; /* Convenience return */
115 /* This routine sends the MOTD or something to newly-registered users. */
117 motd_signon(struct Client* cptr)
119 struct TRecord *trec;
120 struct tm *t_tm = &motd_tm;
122 if ((trec = motd_find(cptr)))
123 t_tm = &trec->tmotd_tm;
126 send_reply(cptr, RPL_MOTDSTART, me.name);
127 send_reply(cptr, SND_EXPLICIT | RPL_MOTD, ":\002Type /MOTD to read the AUP "
128 "before continuing using this service.\002");
129 /* Perhaps we should switch to an ISO date here? */
130 send_reply(cptr, SND_EXPLICIT | RPL_MOTD, ":The message of the day was last "
131 "changed: %d/%d/%d", t_tm->tm_mday, t_tm->tm_mon + 1,
132 1900 + t_tm->tm_year);
133 send_reply(cptr, RPL_ENDOFMOTD);
135 motd_send(cptr, trec);