summaryrefslogtreecommitdiff
path: root/src/usermanager.cpp
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2018-08-13 20:17:46 +0100
committerPeter Powell <petpow@saberuk.com>2018-08-13 21:51:11 +0100
commit58a0a7e01422e62de1565a8eb0a1febdc463d04d (patch)
tree8861789deefe9df3524690de8ccd11e5366f1f2e /src/usermanager.cpp
parente2a820cce21342478653a34cf8ce2b593128d035 (diff)
Implement IRCv3 message tag support.
Co-authored-by: Attila Molnar <attilamolnar@hush.com>
Diffstat (limited to 'src/usermanager.cpp')
-rw-r--r--src/usermanager.cpp34
1 files changed, 21 insertions, 13 deletions
diff --git a/src/usermanager.cpp b/src/usermanager.cpp
index 02c030a42..7466f385b 100644
--- a/src/usermanager.cpp
+++ b/src/usermanager.cpp
@@ -28,21 +28,23 @@ namespace
{
class WriteCommonQuit : public User::ForEachNeighborHandler
{
- std::string line;
- std::string operline;
+ ClientProtocol::Messages::Quit quitmsg;
+ ClientProtocol::Event quitevent;
+ ClientProtocol::Messages::Quit operquitmsg;
+ ClientProtocol::Event operquitevent;
void Execute(LocalUser* user) CXX11_OVERRIDE
{
- user->Write(user->IsOper() ? operline : line);
+ user->Send(user->IsOper() ? operquitevent : quitevent);
}
public:
WriteCommonQuit(User* user, const std::string& msg, const std::string& opermsg)
- : line(":" + user->GetFullHost() + " QUIT :")
- , operline(line)
+ : quitmsg(user, msg)
+ , quitevent(ServerInstance->GetRFCEvents().quit, quitmsg)
+ , operquitmsg(user, opermsg)
+ , operquitevent(ServerInstance->GetRFCEvents().quit, operquitmsg)
{
- line += msg;
- operline += opermsg;
user->ForEachNeighbor(*this, false);
}
};
@@ -177,7 +179,12 @@ void UserManager::QuitUser(User* user, const std::string& quitreason, const std:
user->quitting = true;
ServerInstance->Logs->Log("USERS", LOG_DEBUG, "QuitUser: %s=%s '%s'", user->uuid.c_str(), user->nick.c_str(), quitreason.c_str());
- user->Write("ERROR :Closing link: (%s@%s) [%s]", user->ident.c_str(), user->GetRealHost().c_str(), operreason ? operreason->c_str() : quitreason.c_str());
+ LocalUser* const localuser = IS_LOCAL(user);
+ if (localuser)
+ {
+ ClientProtocol::Messages::Error errormsg(InspIRCd::Format("Closing link: (%s@%s) [%s]", user->ident.c_str(), user->GetRealHost().c_str(), operreason ? operreason->c_str() : quitreason.c_str()));
+ localuser->Send(ServerInstance->GetRFCEvents().error, errormsg);
+ }
std::string reason;
reason.assign(quitreason, 0, ServerInstance->Config->Limits.MaxQuit);
@@ -264,12 +271,13 @@ void UserManager::ServerNoticeAll(const char* text, ...)
{
std::string message;
VAFORMAT(message, text, text);
- message = "NOTICE $" + ServerInstance->Config->ServerName + " :" + message;
+ ClientProtocol::Messages::Privmsg msg(ClientProtocol::Messages::Privmsg::nocopy, ServerInstance->FakeClient, ServerInstance->Config->ServerName, message, MSG_NOTICE);
+ ClientProtocol::Event msgevent(ServerInstance->GetRFCEvents().privmsg, msg);
for (LocalList::const_iterator i = local_users.begin(); i != local_users.end(); ++i)
{
- User* t = *i;
- t->WriteServ(message);
+ LocalUser* user = *i;
+ user->Send(msgevent);
}
}
@@ -320,8 +328,8 @@ void UserManager::DoBackgroundUserStuff()
this->QuitUser(curr, message);
continue;
}
-
- curr->Write("PING :" + ServerInstance->Config->ServerName);
+ ClientProtocol::Messages::Ping ping;
+ curr->Send(ServerInstance->GetRFCEvents().ping, ping);
curr->lastping = 0;
curr->nping = ServerInstance->Time() + curr->MyClass->GetPingTime();
}