summaryrefslogtreecommitdiff
path: root/src/modules/m_cap.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/m_cap.cpp')
-rw-r--r--src/modules/m_cap.cpp38
1 files changed, 9 insertions, 29 deletions
diff --git a/src/modules/m_cap.cpp b/src/modules/m_cap.cpp
index e9f4dae90..605423ae0 100644
--- a/src/modules/m_cap.cpp
+++ b/src/modules/m_cap.cpp
@@ -19,9 +19,7 @@
#include "inspircd.h"
-#include "m_cap.h"
-
-/* $ModDesc: Provides the CAP negotiation mechanism seen in ratbox-derived ircds */
+#include "modules/cap.h"
/*
CAP LS
@@ -66,6 +64,7 @@ class CommandCAP : public Command
while (cap_stream.GetToken(cap_))
{
+ std::transform(cap_.begin(), cap_.end(), cap_.begin(), ::tolower);
Data.wanted.push_back(cap_);
}
@@ -74,13 +73,13 @@ class CommandCAP : public Command
if (Data.ack.size() > 0)
{
- std::string AckResult = irc::stringjoiner(" ", Data.ack, 0, Data.ack.size() - 1).GetJoined();
+ std::string AckResult = irc::stringjoiner(Data.ack).GetJoined();
user->WriteServ("CAP %s ACK :%s", user->nick.c_str(), AckResult.c_str());
}
if (Data.wanted.size() > 0)
{
- std::string NakResult = irc::stringjoiner(" ", Data.wanted, 0, Data.wanted.size() - 1).GetJoined();
+ std::string NakResult = irc::stringjoiner(Data.wanted).GetJoined();
user->WriteServ("CAP %s NAK :%s", user->nick.c_str(), NakResult.c_str());
}
}
@@ -95,10 +94,7 @@ class CommandCAP : public Command
reghold.set(user, 1);
Data.Send();
- std::string Result;
- if (Data.wanted.size() > 0)
- Result = irc::stringjoiner(" ", Data.wanted, 0, Data.wanted.size() - 1).GetJoined();
-
+ std::string Result = irc::stringjoiner(Data.wanted).GetJoined();
user->WriteServ("CAP %s %s :%s", user->nick.c_str(), subcommand.c_str(), Result.c_str());
}
else if (subcommand == "CLEAR")
@@ -108,14 +104,12 @@ class CommandCAP : public Command
reghold.set(user, 1);
Data.Send();
- std::string Result;
- if (!Data.ack.empty())
- Result = irc::stringjoiner(" ", Data.ack, 0, Data.ack.size() - 1).GetJoined();
+ std::string Result = irc::stringjoiner(Data.ack).GetJoined();
user->WriteServ("CAP %s ACK :%s", user->nick.c_str(), Result.c_str());
}
else
{
- user->WriteNumeric(ERR_INVALIDCAPSUBCOMMAND, "%s %s :Invalid CAP subcommand", user->nick.c_str(), subcommand.c_str());
+ user->WriteNumeric(ERR_INVALIDCAPSUBCOMMAND, "%s :Invalid CAP subcommand", subcommand.c_str());
return CMD_FAILURE;
}
@@ -132,16 +126,7 @@ class ModuleCAP : public Module
{
}
- void init()
- {
- ServerInstance->Modules->AddService(cmd);
- ServerInstance->Modules->AddService(cmd.reghold);
-
- Implementation eventlist[] = { I_OnCheckReady };
- ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
- }
-
- ModResult OnCheckReady(LocalUser* user)
+ ModResult OnCheckReady(LocalUser* user) CXX11_OVERRIDE
{
/* Users in CAP state get held until CAP END */
if (cmd.reghold.get(user))
@@ -150,15 +135,10 @@ class ModuleCAP : public Module
return MOD_RES_PASSTHRU;
}
- ~ModuleCAP()
- {
- }
-
- Version GetVersion()
+ Version GetVersion() CXX11_OVERRIDE
{
return Version("Client CAP extension support", VF_VENDOR);
}
};
MODULE_INIT(ModuleCAP)
-