1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2010 InspIRCd Development Team
6 * See: http://wiki.inspircd.org/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
16 /** Handle /MOTD. These command handlers can be reloaded by the core,
17 * and handle basic RFC1459 commands. Commands within modules work
18 * the same way, however, they can be fully unloaded, where these
21 class CommandMotd : public Command
24 /** Constructor for motd.
26 CommandMotd ( Module* parent) : Command(parent,"MOTD",0,1) { syntax = "[<servername>]"; }
28 * @param parameters The parameters to the comamnd
29 * @param pcnt The number of parameters passed to teh command
30 * @param user The user issuing the command
31 * @return A value from CmdResult to indicate command success or failure.
33 CmdResult Handle(const std::vector<std::string>& parameters, User *user);
34 RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
36 if (parameters.size() > 0)
37 return ROUTE_UNICAST(parameters[0]);
38 return ROUTE_LOCALONLY;
44 CmdResult CommandMotd::Handle (const std::vector<std::string>& parameters, User *user)
46 if (parameters.size() > 0 && parameters[0] != ServerInstance->Config->ServerName)
49 ConfigTag* tag = NULL;
51 tag = user->GetClass()->config;
52 std::string motd_name = tag->getString("motd", "motd");
53 ConfigFileCache::iterator motd = ServerInstance->Config->Files.find(motd_name);
54 if (motd == ServerInstance->Config->Files.end())
56 user->SendText(":%s %03d %s :Message of the day file is missing.",
57 ServerInstance->Config->ServerName.c_str(), ERR_NOMOTD, user->nick.c_str());
61 user->SendText(":%s %03d %s :%s message of the day", ServerInstance->Config->ServerName.c_str(),
62 RPL_MOTDSTART, user->nick.c_str(), ServerInstance->Config->ServerName.c_str());
64 for (file_cache::iterator i = motd->second.begin(); i != motd->second.end(); i++)
65 user->SendText(":%s %03d %s :- %s", ServerInstance->Config->ServerName.c_str(), RPL_MOTD, user->nick.c_str(),i->c_str());
67 user->SendText(":%s %03d %s :End of message of the day.", ServerInstance->Config->ServerName.c_str(), RPL_ENDOFMOTD, user->nick.c_str());
72 COMMAND_INIT(CommandMotd)