mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-10 02:59:01 -04:00
Merge branch 'master+writeremotenotice'
This commit is contained in:
commit
78044f849b
@ -519,6 +519,11 @@ class CoreExport User : public Extensible
|
||||
*/
|
||||
void WriteNotice(const std::string& text) { this->WriteCommand("NOTICE", ":" + text); }
|
||||
|
||||
/** Send a NOTICE message from the local server to the user.
|
||||
* @param text Text to send
|
||||
*/
|
||||
virtual void WriteRemoteNotice(const std::string& text);
|
||||
|
||||
void WriteRemoteNumeric(const Numeric::Numeric& numeric);
|
||||
|
||||
template <typename T1>
|
||||
@ -847,6 +852,12 @@ class CoreExport LocalUser : public User, public insp::intrusive_list_node<Local
|
||||
void Write(const std::string& text);
|
||||
void Write(const char*, ...) CUSTOM_PRINTF(2, 3);
|
||||
|
||||
/** Send a NOTICE message from the local server to the user.
|
||||
* The message will be sent even if the user is connected to a remote server.
|
||||
* @param text Text to send
|
||||
*/
|
||||
void WriteRemoteNotice(const std::string& text) CXX11_OVERRIDE;
|
||||
|
||||
/** Returns true or false for if a user can execute a privilaged oper command.
|
||||
* This is done by looking up their oper type from User::oper, then referencing
|
||||
* this to their oper classes and checking the commands they can execute.
|
||||
|
@ -612,7 +612,7 @@ void ServerConfig::Apply(ServerConfig* old, const std::string &useruid)
|
||||
std::cout << line << std::endl;
|
||||
// If a user is rehashing, tell them directly
|
||||
if (user)
|
||||
user->SendText(":%s NOTICE %s :*** %s", ServerInstance->Config->ServerName.c_str(), user->nick.c_str(), line.c_str());
|
||||
user->WriteRemoteNotice(InspIRCd::Format("*** %s", line.c_str()));
|
||||
// Also tell opers
|
||||
ServerInstance->SNO->WriteGlobalSno('a', line);
|
||||
}
|
||||
@ -652,8 +652,7 @@ void ServerConfig::Apply(ServerConfig* old, const std::string &useruid)
|
||||
ApplyModules(user);
|
||||
|
||||
if (user)
|
||||
user->SendText(":%s NOTICE %s :*** Successfully rehashed server.",
|
||||
ServerInstance->Config->ServerName.c_str(), user->nick.c_str());
|
||||
user->WriteRemoteNotice("*** Successfully rehashed server.");
|
||||
ServerInstance->SNO->WriteGlobalSno('a', "*** Successfully rehashed server.");
|
||||
}
|
||||
|
||||
|
@ -33,9 +33,9 @@ class CommandAlltime : public Command
|
||||
{
|
||||
const std::string fmtdate = InspIRCd::TimeString(ServerInstance->Time(), "%Y-%m-%d %H:%M:%S", true);
|
||||
|
||||
std::string msg = ":" + ServerInstance->Config->ServerName + " NOTICE " + user->nick + " :System time is " + fmtdate + " (" + ConvToStr(ServerInstance->Time()) + ") on " + ServerInstance->Config->ServerName;
|
||||
std::string msg = "System time is " + fmtdate + " (" + ConvToStr(ServerInstance->Time()) + ") on " + ServerInstance->Config->ServerName;
|
||||
|
||||
user->SendText(msg);
|
||||
user->WriteRemoteNotice(msg);
|
||||
|
||||
/* we want this routed out! */
|
||||
return CMD_SUCCESS;
|
||||
|
@ -66,7 +66,7 @@ class CommandSajoin : public Command
|
||||
Channel* chan = ServerInstance->FindChan(channel);
|
||||
if ((chan) && (chan->HasUser(dest)))
|
||||
{
|
||||
user->SendText(":" + user->server->GetName() + " NOTICE " + user->nick + " :*** " + dest->nick + " is already on " + channel);
|
||||
user->WriteRemoteNotice("*** " + dest->nick + " is already on " + channel);
|
||||
return CMD_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -312,19 +312,6 @@ ModResult ModuleSpanningTree::HandleVersion(const std::vector<std::string>& para
|
||||
return MOD_RES_DENY;
|
||||
}
|
||||
|
||||
/* This method will attempt to get a message to a remote user.
|
||||
*/
|
||||
void ModuleSpanningTree::RemoteMessage(User* user, const char* format, ...)
|
||||
{
|
||||
std::string text;
|
||||
VAFORMAT(text, format, format);
|
||||
|
||||
if (IS_LOCAL(user))
|
||||
user->WriteNotice(text);
|
||||
else
|
||||
ServerInstance->PI->SendUserNotice(user, text);
|
||||
}
|
||||
|
||||
ModResult ModuleSpanningTree::HandleConnect(const std::vector<std::string>& parameters, User* user)
|
||||
{
|
||||
for (std::vector<reference<Link> >::iterator i = Utils->LinkBlocks.begin(); i < Utils->LinkBlocks.end(); i++)
|
||||
@ -334,25 +321,25 @@ ModResult ModuleSpanningTree::HandleConnect(const std::vector<std::string>& para
|
||||
{
|
||||
if (InspIRCd::Match(ServerInstance->Config->ServerName, assign(x->Name), rfc_case_insensitive_map))
|
||||
{
|
||||
RemoteMessage(user, "*** CONNECT: Server \002%s\002 is ME, not connecting.",x->Name.c_str());
|
||||
user->WriteRemoteNotice(InspIRCd::Format("*** CONNECT: Server \002%s\002 is ME, not connecting.", x->Name.c_str()));
|
||||
return MOD_RES_DENY;
|
||||
}
|
||||
|
||||
TreeServer* CheckDupe = Utils->FindServer(x->Name.c_str());
|
||||
if (!CheckDupe)
|
||||
{
|
||||
RemoteMessage(user, "*** CONNECT: Connecting to server: \002%s\002 (%s:%d)",x->Name.c_str(),(x->HiddenFromStats ? "<hidden>" : x->IPAddr.c_str()),x->Port);
|
||||
user->WriteRemoteNotice(InspIRCd::Format("*** CONNECT: Connecting to server: \002%s\002 (%s:%d)", x->Name.c_str(), (x->HiddenFromStats ? "<hidden>" : x->IPAddr.c_str()), x->Port));
|
||||
ConnectServer(x);
|
||||
return MOD_RES_DENY;
|
||||
}
|
||||
else
|
||||
{
|
||||
RemoteMessage(user, "*** CONNECT: Server \002%s\002 already exists on the network and is connected via \002%s\002", x->Name.c_str(), CheckDupe->GetParent()->GetName().c_str());
|
||||
user->WriteRemoteNotice(InspIRCd::Format("*** CONNECT: Server \002%s\002 already exists on the network and is connected via \002%s\002", x->Name.c_str(), CheckDupe->GetParent()->GetName().c_str()));
|
||||
return MOD_RES_DENY;
|
||||
}
|
||||
}
|
||||
}
|
||||
RemoteMessage(user, "*** CONNECT: No server matching \002%s\002 could be found in the config file.",parameters[0].c_str());
|
||||
user->WriteRemoteNotice(InspIRCd::Format("*** CONNECT: No server matching \002%s\002 could be found in the config file.", parameters[0].c_str()));
|
||||
return MOD_RES_DENY;
|
||||
}
|
||||
|
||||
|
@ -131,10 +131,6 @@ class ModuleSpanningTree : public Module
|
||||
*/
|
||||
ModResult HandleConnect(const std::vector<std::string>& parameters, User* user);
|
||||
|
||||
/** Attempt to send a message to a user
|
||||
*/
|
||||
void RemoteMessage(User* user, const char* format, ...) CUSTOM_PRINTF(3, 4);
|
||||
|
||||
/** Display a time as a human readable string
|
||||
*/
|
||||
static std::string TimeToStr(time_t secs);
|
||||
|
@ -36,7 +36,7 @@ CmdResult CommandRConnect::Handle (const std::vector<std::string>& parameters, U
|
||||
/* First see if the server which is being asked to connect to another server in fact exists */
|
||||
if (!Utils->FindServerMask(parameters[0]))
|
||||
{
|
||||
((ModuleSpanningTree*)(Module*)creator)->RemoteMessage(user, "*** RCONNECT: Server \002%s\002 isn't connected to the network!", parameters[0].c_str());
|
||||
user->WriteRemoteNotice(InspIRCd::Format("*** RCONNECT: Server \002%s\002 isn't connected to the network!", parameters[0].c_str()));
|
||||
return CMD_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -39,13 +39,13 @@ CmdResult CommandRSQuit::Handle (const std::vector<std::string>& parameters, Use
|
||||
server_target = Utils->FindServerMask(parameters[0]);
|
||||
if (!server_target)
|
||||
{
|
||||
((ModuleSpanningTree*)(Module*)creator)->RemoteMessage(user, "*** RSQUIT: Server \002%s\002 isn't connected to the network!", parameters[0].c_str());
|
||||
user->WriteRemoteNotice(InspIRCd::Format("*** RSQUIT: Server \002%s\002 isn't connected to the network!", parameters[0].c_str()));
|
||||
return CMD_FAILURE;
|
||||
}
|
||||
|
||||
if (server_target->IsRoot())
|
||||
{
|
||||
((ModuleSpanningTree*)(Module*)creator)->RemoteMessage(user, "*** RSQUIT: Foolish mortal, you cannot make a server SQUIT itself! (%s matches local server name)", parameters[0].c_str());
|
||||
user->WriteRemoteNotice(InspIRCd::Format("*** RSQUIT: Foolish mortal, you cannot make a server SQUIT itself! (%s matches local server name)", parameters[0].c_str()));
|
||||
return CMD_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -830,6 +830,16 @@ void User::WriteFrom(User *user, const char* text, ...)
|
||||
this->WriteFrom(user, textbuffer);
|
||||
}
|
||||
|
||||
void User::WriteRemoteNotice(const std::string& text)
|
||||
{
|
||||
ServerInstance->PI->SendUserNotice(this, text);
|
||||
}
|
||||
|
||||
void LocalUser::WriteRemoteNotice(const std::string& text)
|
||||
{
|
||||
WriteNotice(text);
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
class WriteCommonRawHandler : public User::ForEachNeighborHandler
|
||||
|
Loading…
x
Reference in New Issue
Block a user