mirror of
https://github.com/znc/znc.git
synced 2026-03-28 17:42:41 +01:00
Update capability names as they are named in IRCv3.2.
Old names will be available for a while, then removed. self-message is superseded by echo-message and will be removed in future too.
This commit is contained in:
@@ -874,15 +874,24 @@ void CClient::HandleCap(const CString& sLine)
|
||||
//TODO support ~ and = modifiers
|
||||
CString sSubCmd = sLine.Token(1);
|
||||
|
||||
std::map<CString, std::function<void(bool bVal)>> mCoreCaps = {
|
||||
{"multi-prefix", [this](bool bVal) { m_bNamesx = bVal; }},
|
||||
{"userhost-in-names", [this](bool bVal) { m_bUHNames = bVal; }},
|
||||
{"echo-message", [this](bool bVal) { m_bEchoMessage = bVal; }},
|
||||
{"server-time", [this](bool bVal) { m_bServerTime = bVal; }},
|
||||
{"batch", [this](bool bVal) { m_bBatch = bVal; }},
|
||||
};
|
||||
// For compatibility with older clients
|
||||
mCoreCaps["znc.in/server-time-iso"] = mCoreCaps["server-time"];
|
||||
mCoreCaps["znc.in/batch"] = mCoreCaps["batch"];
|
||||
mCoreCaps["znc.in/self-message"] = [this](bool bVal) { m_bSelfMessage = bVal; };
|
||||
|
||||
if (sSubCmd.Equals("LS")) {
|
||||
SCString ssOfferCaps;
|
||||
for (const auto& it : mCoreCaps) {
|
||||
ssOfferCaps.insert(it.first);
|
||||
}
|
||||
GLOBALMODULECALL(OnClientCapLs(this, ssOfferCaps), NOTHING);
|
||||
ssOfferCaps.insert("userhost-in-names");
|
||||
ssOfferCaps.insert("multi-prefix");
|
||||
ssOfferCaps.insert("echo-message");
|
||||
ssOfferCaps.insert("znc.in/server-time-iso");
|
||||
ssOfferCaps.insert("znc.in/batch");
|
||||
ssOfferCaps.insert("znc.in/self-message");
|
||||
CString sRes = CString(" ").Join(ssOfferCaps.begin(), ssOfferCaps.end());
|
||||
RespondCap("LS :" + sRes);
|
||||
m_bInCap = true;
|
||||
@@ -905,7 +914,7 @@ void CClient::HandleCap(const CString& sLine)
|
||||
if (sCap.TrimPrefix("-"))
|
||||
bVal = false;
|
||||
|
||||
bool bAccepted = ("multi-prefix" == sCap) || ("userhost-in-names" == sCap) || ("echo-message" == sCap) || ("znc.in/server-time-iso" == sCap) || ("znc.in/batch" == sCap) || ("znc.in/self-message" == sCap);
|
||||
bool bAccepted = mCoreCaps.count(sCap) > 0;
|
||||
GLOBALMODULECALL(IsClientCapSupported(this, sCap, bVal), &bAccepted);
|
||||
|
||||
if (!bAccepted) {
|
||||
@@ -922,18 +931,9 @@ void CClient::HandleCap(const CString& sLine)
|
||||
if (sCap.TrimPrefix("-"))
|
||||
bVal = false;
|
||||
|
||||
if ("multi-prefix" == sCap) {
|
||||
m_bNamesx = bVal;
|
||||
} else if ("userhost-in-names" == sCap) {
|
||||
m_bUHNames = bVal;
|
||||
} else if ("echo-message" == sCap) {
|
||||
m_bEchoMessage = bVal;
|
||||
} else if ("znc.in/server-time-iso" == sCap) {
|
||||
m_bServerTime = bVal;
|
||||
} else if ("znc.in/batch" == sCap) {
|
||||
m_bBatch = bVal;
|
||||
} else if ("znc.in/self-message" == sCap) {
|
||||
m_bSelfMessage = bVal;
|
||||
auto handler_it = mCoreCaps.find(sCap);
|
||||
if (mCoreCaps.end() != handler_it) {
|
||||
handler_it->second(bVal);
|
||||
}
|
||||
GLOBALMODULECALL(OnClientCapRequest(this, sCap, bVal), NOTHING);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user