unrealircd

- supernets unrealircd source & configuration
git clone git://git.acid.vegas/unrealircd.git
Log | Files | Refs | Archive | README | LICENSE

motd.c (2711B)

      1 /*
      2  *   IRC - Internet Relay Chat, src/modules/motd.c
      3  *   (C) 2005 The UnrealIRCd Team
      4  *
      5  *   See file AUTHORS in IRC package for additional names of
      6  *   the programmers.
      7  *
      8  *   This program is free software; you can redistribute it and/or modify
      9  *   it under the terms of the GNU General Public License as published by
     10  *   the Free Software Foundation; either version 1, or (at your option)
     11  *   any later version.
     12  *
     13  *   This program is distributed in the hope that it will be useful,
     14  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     15  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16  *   GNU General Public License for more details.
     17  *
     18  *   You should have received a copy of the GNU General Public License
     19  *   along with this program; if not, write to the Free Software
     20  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     21  */
     22 
     23 #include "unrealircd.h"
     24 
     25 CMD_FUNC(cmd_motd);
     26 
     27 #define MSG_MOTD 	"MOTD"	
     28 
     29 ModuleHeader MOD_HEADER
     30   = {
     31 	"motd",
     32 	"5.0",
     33 	"command /motd", 
     34 	"UnrealIRCd Team",
     35 	"unrealircd-6",
     36     };
     37 
     38 MOD_INIT()
     39 {
     40 	CommandAdd(modinfo->handle, MSG_MOTD, cmd_motd, MAXPARA, CMD_USER|CMD_SERVER);
     41 	MARK_AS_OFFICIAL_MODULE(modinfo);
     42 	return MOD_SUCCESS;
     43 }
     44 
     45 MOD_LOAD()
     46 {
     47 	return MOD_SUCCESS;
     48 }
     49 
     50 MOD_UNLOAD()
     51 {
     52 	return MOD_SUCCESS;
     53 }
     54 
     55 /*
     56  * Heavily modified from the ircu cmd_motd by codemastr
     57  * Also svsmotd support added
     58  */
     59 CMD_FUNC(cmd_motd)
     60 {
     61 	ConfigItem_tld *tld;
     62 	MOTDFile *themotd;
     63 	MOTDLine *motdline;
     64 	int  svsnofile = 0;
     65 
     66 	if (IsServer(client))
     67 		return;
     68 
     69 	if (hunt_server(client, recv_mtags, "MOTD", 1, parc, parv) != HUNTED_ISME)
     70 	{
     71 		if (MyUser(client))
     72 			add_fake_lag(client, 15000);
     73 		return;
     74 	}
     75 
     76 	tld = find_tld(client);
     77 
     78 	if (tld && tld->motd.lines)
     79 		themotd = &tld->motd;
     80 	else
     81 		themotd = &motd;
     82 
     83 	if (themotd == NULL || themotd->lines == NULL)
     84 	{
     85 		sendnumeric(client, ERR_NOMOTD);
     86 		svsnofile = 1;
     87 		goto svsmotd;
     88 	}
     89 
     90 	sendnumeric(client, RPL_MOTDSTART, me.name);
     91 
     92 	/* tm_year should be zero only if the struct is zero-ed */
     93 	if (themotd && themotd->lines && themotd->last_modified.tm_year)
     94 	{
     95 		sendnumericfmt(client, RPL_MOTD, ":- %.04d-%.02d-%.02d %.02d:%02d",
     96 			themotd->last_modified.tm_year + 1900,
     97 			themotd->last_modified.tm_mon + 1,
     98 			themotd->last_modified.tm_mday,
     99 			themotd->last_modified.tm_hour,
    100 			themotd->last_modified.tm_min);
    101 	}
    102 
    103 	motdline = NULL;
    104 	if (themotd)
    105 		motdline = themotd->lines;
    106 	while (motdline)
    107 	{
    108 		sendnumeric(client, RPL_MOTD,
    109 			motdline->line);
    110 		motdline = motdline->next;
    111 	}
    112 	svsmotd:
    113 
    114 	motdline = svsmotd.lines;
    115 	while (motdline)
    116 	{
    117 		sendnumeric(client, RPL_MOTD,
    118 			motdline->line);
    119 		motdline = motdline->next;
    120 	}
    121 	if (svsnofile == 0)
    122 		sendnumeric(client, RPL_ENDOFMOTD);
    123 }