mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-10 11:09:04 -04:00
Fix MOTD and RULES to work remotely (remove the old hacks for MOTD)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@12301 e03df62e-2008-0410-955e-edbf42e46eb7
This commit is contained in:
parent
0429d86a7a
commit
aeded4708c
@ -704,14 +704,6 @@ class CoreExport User : public Extensible
|
||||
*/
|
||||
virtual ConnectClass* GetClass();
|
||||
|
||||
/** Show the message of the day to this user
|
||||
*/
|
||||
void ShowMOTD();
|
||||
|
||||
/** Show the server RULES file to this user
|
||||
*/
|
||||
void ShowRULES();
|
||||
|
||||
/** Default destructor
|
||||
*/
|
||||
virtual ~User();
|
||||
|
@ -13,17 +13,6 @@
|
||||
|
||||
#include "inspircd.h"
|
||||
|
||||
#ifndef __CMD_MOTD_H__
|
||||
#define __CMD_MOTD_H__
|
||||
|
||||
// include the common header files
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "inspircd.h"
|
||||
#include "users.h"
|
||||
#include "channels.h"
|
||||
|
||||
/** Handle /MOTD. These command handlers can be reloaded by the core,
|
||||
* and handle basic RFC1459 commands. Commands within modules work
|
||||
* the same way, however, they can be fully unloaded, where these
|
||||
@ -42,16 +31,34 @@ class CommandMotd : public Command
|
||||
* @return A value from CmdResult to indicate command success or failure.
|
||||
*/
|
||||
CmdResult Handle(const std::vector<std::string>& parameters, User *user);
|
||||
RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
|
||||
{
|
||||
if (parameters.size() > 0)
|
||||
return ROUTE_UNICAST(parameters[0]);
|
||||
return ROUTE_LOCALONLY;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/** Handle /MOTD
|
||||
*/
|
||||
CmdResult CommandMotd::Handle (const std::vector<std::string>&, User *user)
|
||||
CmdResult CommandMotd::Handle (const std::vector<std::string>& parameters, User *user)
|
||||
{
|
||||
user->ShowMOTD();
|
||||
if (parameters.size() > 0 && parameters[0] != ServerInstance->Config->ServerName)
|
||||
return CMD_SUCCESS;
|
||||
if (!ServerInstance->Config->MOTD.size())
|
||||
{
|
||||
user->SendText(":%s %03d %s :Message of the day file is missing.",
|
||||
ServerInstance->Config->ServerName.c_str(), ERR_NOMOTD, user->nick.c_str());
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
user->SendText(":%s %03d %s :%s message of the day", ServerInstance->Config->ServerName.c_str(),
|
||||
RPL_MOTDSTART, user->nick.c_str(), ServerInstance->Config->ServerName.c_str());
|
||||
|
||||
for (file_cache::iterator i = ServerInstance->Config->MOTD.begin(); i != ServerInstance->Config->MOTD.end(); i++)
|
||||
user->SendText(":%s %03d %s :- %s", ServerInstance->Config->ServerName.c_str(), RPL_MOTD, user->nick.c_str(),i->c_str());
|
||||
|
||||
user->SendText(":%s %03d %s :End of message of the day.", ServerInstance->Config->ServerName.c_str(), RPL_ENDOFMOTD, user->nick.c_str());
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -13,17 +13,6 @@
|
||||
|
||||
#include "inspircd.h"
|
||||
|
||||
#ifndef __CMD_RULES_H__
|
||||
#define __CMD_RULES_H__
|
||||
|
||||
// include the common header files
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "inspircd.h"
|
||||
#include "users.h"
|
||||
#include "channels.h"
|
||||
|
||||
/** Handle /RULES. These command handlers can be reloaded by the core,
|
||||
* and handle basic RFC1459 commands. Commands within modules work
|
||||
* the same way, however, they can be fully unloaded, where these
|
||||
@ -42,14 +31,33 @@ class CommandRules : public Command
|
||||
* @return A value from CmdResult to indicate command success or failure.
|
||||
*/
|
||||
CmdResult Handle(const std::vector<std::string>& parameters, User *user);
|
||||
RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
|
||||
{
|
||||
if (parameters.size() > 0)
|
||||
return ROUTE_UNICAST(parameters[0]);
|
||||
return ROUTE_LOCALONLY;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
CmdResult CommandRules::Handle (const std::vector<std::string>& parameters, User *user)
|
||||
{
|
||||
user->ShowRULES();
|
||||
if (parameters.size() > 0 && parameters[0] != ServerInstance->Config->ServerName)
|
||||
return CMD_SUCCESS;
|
||||
|
||||
if (!ServerInstance->Config->RULES.size())
|
||||
{
|
||||
user->SendText(":%s %03d %s :RULES file is missing.",
|
||||
ServerInstance->Config->ServerName.c_str(), ERR_NORULES, user->nick.c_str());
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
user->SendText(":%s %03d %s :%s server rules:", ServerInstance->Config->ServerName.c_str(),
|
||||
RPL_RULESTART, user->nick.c_str(), ServerInstance->Config->ServerName.c_str());
|
||||
|
||||
for (file_cache::iterator i = ServerInstance->Config->RULES.begin(); i != ServerInstance->Config->RULES.end(); i++)
|
||||
user->SendText(":%s %03d %s :- %s", ServerInstance->Config->ServerName.c_str(), RPL_RULES, user->nick.c_str(),i->c_str());
|
||||
|
||||
user->SendText(":%s %03d %s :End of RULES command.", ServerInstance->Config->ServerName.c_str(), RPL_RULESEND, user->nick.c_str());
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -75,10 +75,6 @@ class ModuleSpanningTree : public Module
|
||||
*/
|
||||
void ShowMap(TreeServer* Current, User* user, int depth, int &line, char* names, int &maxnamew, char* stats);
|
||||
|
||||
/** Handle remote MOTD
|
||||
*/
|
||||
ModResult HandleMotd(const std::vector<std::string>& parameters, User* user);
|
||||
|
||||
/** Handle remote ADMIN
|
||||
*/
|
||||
ModResult HandleAdmin(const std::vector<std::string>& parameters, User* user);
|
||||
|
@ -1,72 +0,0 @@
|
||||
/* +------------------------------------+
|
||||
* | Inspire Internet Relay Chat Daemon |
|
||||
* +------------------------------------+
|
||||
*
|
||||
* InspIRCd: (C) 2002-2010 InspIRCd Development Team
|
||||
* See: http://wiki.inspircd.org/Credits
|
||||
*
|
||||
* This program is free but copyrighted software; see
|
||||
* the file COPYING for details.
|
||||
*
|
||||
* ---------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "inspircd.h"
|
||||
#include "xline.h"
|
||||
|
||||
#include "treesocket.h"
|
||||
#include "treeserver.h"
|
||||
#include "utils.h"
|
||||
|
||||
/* $ModDep: m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/treesocket.h */
|
||||
|
||||
|
||||
|
||||
/** remote MOTD. leet, huh? */
|
||||
bool TreeSocket::Motd(const std::string &prefix, parameterlist ¶ms)
|
||||
{
|
||||
if (params.size() > 0)
|
||||
{
|
||||
if (InspIRCd::Match(ServerInstance->Config->ServerName, params[0]))
|
||||
{
|
||||
/* It's for our server */
|
||||
string_list results;
|
||||
User* source = ServerInstance->FindNick(prefix);
|
||||
|
||||
if (source)
|
||||
{
|
||||
parameterlist par;
|
||||
par.push_back(prefix);
|
||||
par.push_back("");
|
||||
|
||||
if (!ServerInstance->Config->MOTD.size())
|
||||
{
|
||||
par[1] = std::string("::")+ServerInstance->Config->ServerName+" 422 "+source->nick+" :Message of the day file is missing.";
|
||||
Utils->DoOneToOne(ServerInstance->Config->GetSID(), "PUSH",par, source->server);
|
||||
return true;
|
||||
}
|
||||
|
||||
par[1] = std::string("::")+ServerInstance->Config->ServerName+" 375 "+source->nick+" :"+ServerInstance->Config->ServerName+" message of the day";
|
||||
Utils->DoOneToOne(ServerInstance->Config->GetSID(), "PUSH",par, source->server);
|
||||
|
||||
for (unsigned int i = 0; i < ServerInstance->Config->MOTD.size(); i++)
|
||||
{
|
||||
par[1] = std::string("::")+ServerInstance->Config->ServerName+" 372 "+source->nick+" :- "+ServerInstance->Config->MOTD[i];
|
||||
Utils->DoOneToOne(ServerInstance->Config->GetSID(), "PUSH",par, source->server);
|
||||
}
|
||||
|
||||
par[1] = std::string("::")+ServerInstance->Config->ServerName+" 376 "+source->nick+" :End of message of the day.";
|
||||
Utils->DoOneToOne(ServerInstance->Config->GetSID(), "PUSH",par, source->server);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Pass it on */
|
||||
User* source = ServerInstance->FindNick(prefix);
|
||||
if (source)
|
||||
Utils->DoOneToOne(prefix, "MOTD", params, params[0]);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1,50 +0,0 @@
|
||||
/* +------------------------------------+
|
||||
* | Inspire Internet Relay Chat Daemon |
|
||||
* +------------------------------------+
|
||||
*
|
||||
* InspIRCd: (C) 2002-2010 InspIRCd Development Team
|
||||
* See: http://wiki.inspircd.org/Credits
|
||||
*
|
||||
* This program is free but copyrighted software; see
|
||||
* the file COPYING for details.
|
||||
*
|
||||
* ---------------------------------------------------
|
||||
*/
|
||||
|
||||
/* $ModDesc: Provides a spanning tree server link protocol */
|
||||
|
||||
#include "inspircd.h"
|
||||
#include "socket.h"
|
||||
#include "xline.h"
|
||||
|
||||
#include "main.h"
|
||||
#include "utils.h"
|
||||
#include "treeserver.h"
|
||||
#include "treesocket.h"
|
||||
|
||||
/* $ModDep: m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/treesocket.h */
|
||||
|
||||
ModResult ModuleSpanningTree::HandleMotd(const std::vector<std::string>& parameters, User* user)
|
||||
{
|
||||
if (parameters.size() > 0)
|
||||
{
|
||||
if (InspIRCd::Match(ServerInstance->Config->ServerName, parameters[0]))
|
||||
return MOD_RES_PASSTHRU;
|
||||
|
||||
/* Remote MOTD, the server is within the 1st parameter */
|
||||
parameterlist params;
|
||||
params.push_back(parameters[0]);
|
||||
/* Send it out remotely, generate no reply yet */
|
||||
TreeServer* s = Utils->FindServerMask(parameters[0]);
|
||||
if (s)
|
||||
{
|
||||
params[0] = s->GetName();
|
||||
Utils->DoOneToOne(user->uuid, "MOTD", params, s->GetName());
|
||||
}
|
||||
else
|
||||
user->WriteNumeric(ERR_NOSUCHSERVER, "%s %s :No such server", user->nick.c_str(), parameters[0].c_str());
|
||||
return MOD_RES_DENY;
|
||||
}
|
||||
return MOD_RES_PASSTHRU;
|
||||
}
|
||||
|
@ -38,10 +38,6 @@ ModResult ModuleSpanningTree::OnPreCommand(std::string &command, std::vector<std
|
||||
{
|
||||
return this->HandleStats(parameters,user);
|
||||
}
|
||||
else if (command == "MOTD")
|
||||
{
|
||||
return this->HandleMotd(parameters,user);
|
||||
}
|
||||
else if (command == "ADMIN")
|
||||
{
|
||||
return this->HandleAdmin(parameters,user);
|
||||
|
@ -251,9 +251,6 @@ class TreeSocket : public BufferedSocket
|
||||
/** Handle ERROR command */
|
||||
void Error(parameterlist ¶ms);
|
||||
|
||||
/** remote MOTD. */
|
||||
bool Motd(const std::string &prefix, parameterlist ¶ms);
|
||||
|
||||
/** remote ADMIN. */
|
||||
bool Admin(const std::string &prefix, parameterlist ¶ms);
|
||||
|
||||
|
@ -294,10 +294,6 @@ void TreeSocket::ProcessConnectedLine(std::string& prefix, std::string& command,
|
||||
{
|
||||
this->Stats(prefix, params);
|
||||
}
|
||||
else if (command == "MOTD")
|
||||
{
|
||||
this->Motd(prefix, params);
|
||||
}
|
||||
else if (command == "ADMIN")
|
||||
{
|
||||
this->Admin(prefix, params);
|
||||
|
@ -829,18 +829,21 @@ void LocalUser::FullConnect()
|
||||
ServerInstance->Config->Send005(this);
|
||||
this->WriteNumeric(RPL_YOURUUID, "%s %s :your unique ID", this->nick.c_str(), this->uuid.c_str());
|
||||
|
||||
|
||||
this->ShowMOTD();
|
||||
|
||||
/* Now registered */
|
||||
if (ServerInstance->Users->unregistered_count)
|
||||
ServerInstance->Users->unregistered_count--;
|
||||
|
||||
/* Trigger LUSERS output, give modules a chance too */
|
||||
/* Trigger MOTD and LUSERS output, give modules a chance too */
|
||||
ModResult MOD_RESULT;
|
||||
std::string command("LUSERS");
|
||||
std::string command("MOTD");
|
||||
std::vector<std::string> parameters;
|
||||
FIRST_MOD_RESULT(OnPreCommand, MOD_RESULT, (command, parameters, this, true, "LUSERS"));
|
||||
FIRST_MOD_RESULT(OnPreCommand, MOD_RESULT, (command, parameters, this, true, command));
|
||||
if (!MOD_RESULT)
|
||||
ServerInstance->CallCommandHandler(command, parameters, this);
|
||||
|
||||
MOD_RESULT = MOD_RES_PASSTHRU;
|
||||
command = "LUSERS";
|
||||
FIRST_MOD_RESULT(OnPreCommand, MOD_RESULT, (command, parameters, this, true, command));
|
||||
if (!MOD_RESULT)
|
||||
ServerInstance->CallCommandHandler(command, parameters, this);
|
||||
|
||||
@ -1626,37 +1629,6 @@ void User::PurgeEmptyChannels()
|
||||
this->UnOper();
|
||||
}
|
||||
|
||||
void User::ShowMOTD()
|
||||
{
|
||||
if (!ServerInstance->Config->MOTD.size())
|
||||
{
|
||||
this->WriteNumeric(ERR_NOMOTD, "%s :Message of the day file is missing.",this->nick.c_str());
|
||||
return;
|
||||
}
|
||||
this->WriteNumeric(RPL_MOTDSTART, "%s :%s message of the day", this->nick.c_str(), ServerInstance->Config->ServerName.c_str());
|
||||
|
||||
for (file_cache::iterator i = ServerInstance->Config->MOTD.begin(); i != ServerInstance->Config->MOTD.end(); i++)
|
||||
this->WriteNumeric(RPL_MOTD, "%s :- %s",this->nick.c_str(),i->c_str());
|
||||
|
||||
this->WriteNumeric(RPL_ENDOFMOTD, "%s :End of message of the day.", this->nick.c_str());
|
||||
}
|
||||
|
||||
void User::ShowRULES()
|
||||
{
|
||||
if (!ServerInstance->Config->RULES.size())
|
||||
{
|
||||
this->WriteNumeric(ERR_NORULES, "%s :RULES File is missing",this->nick.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
this->WriteNumeric(RPL_RULESTART, "%s :- %s Server Rules -",this->nick.c_str(),ServerInstance->Config->ServerName.c_str());
|
||||
|
||||
for (file_cache::iterator i = ServerInstance->Config->RULES.begin(); i != ServerInstance->Config->RULES.end(); i++)
|
||||
this->WriteNumeric(RPL_RULES, "%s :- %s",this->nick.c_str(),i->c_str());
|
||||
|
||||
this->WriteNumeric(RPL_RULESEND, "%s :End of RULES command.",this->nick.c_str());
|
||||
}
|
||||
|
||||
const std::string& FakeUser::GetFullHost()
|
||||
{
|
||||
if (!ServerInstance->Config->HideWhoisServer.empty())
|
||||
|
Loading…
x
Reference in New Issue
Block a user