From 6246899c56e7b69797bd000b68eda0d503fcd73d Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 14 Jul 2015 18:29:33 +0200 Subject: [PATCH] Add support for extended-join (#316) --- include/znc/Client.h | 4 ++++ include/znc/IRCSock.h | 2 ++ src/IRCSock.cpp | 17 +++++++++++++++++ 3 files changed, 23 insertions(+) diff --git a/include/znc/Client.h b/include/znc/Client.h index f58f3f9a..f9ae87c2 100644 --- a/include/znc/Client.h +++ b/include/znc/Client.h @@ -98,6 +98,7 @@ public: m_bCapNotify(false), m_bAwayNotify(false), m_bAccountNotify(false), + m_bExtendedJoin(false), m_bNamesx(false), m_bUHNames(false), m_bAway(false), @@ -123,6 +124,7 @@ public: {"cap-notify", {false, [this](bool bVal) { m_bCapNotify = bVal; }}}, {"away-notify", {true, [this](bool bVal) { m_bAwayNotify = bVal; }}}, {"account-notify", {true, [this](bool bVal) { m_bAccountNotify = bVal; }}}, + {"extended-join", {true, [this](bool bVal) { m_bExtendedJoin = bVal; }}}, }) { EnableReadLine(); @@ -151,6 +153,7 @@ public: bool HasCapNotify() const { return m_bCapNotify; } bool HasAwayNotify() const { return m_bAwayNotify; } bool HasAccountNotify() const { return m_bAccountNotify; } + bool HasExtendedJoin() const { return m_bExtendedJoin; } bool HasNamesx() const { return m_bNamesx; } bool HasUHNames() const { return m_bUHNames; } bool IsAway() const { return m_bAway; } @@ -217,6 +220,7 @@ protected: bool m_bCapNotify; bool m_bAwayNotify; bool m_bAccountNotify; + bool m_bExtendedJoin; bool m_bNamesx; bool m_bUHNames; bool m_bAway; diff --git a/include/znc/IRCSock.h b/include/znc/IRCSock.h index db197b1d..a6949529 100644 --- a/include/znc/IRCSock.h +++ b/include/znc/IRCSock.h @@ -103,6 +103,7 @@ public: bool HasUHNames() const { return m_bUHNames; } bool HasAwayNotify() const { return m_bAwayNotify; } bool HasAccountNotify() const { return m_bAccountNotify; } + bool HasExtendedJoin() const { return m_bExtendedJoin; } const std::set& GetUserModes() const { return m_scUserModes; } // This is true if we are past raw 001 bool IsAuthed() const { return m_bAuthed; } @@ -131,6 +132,7 @@ protected: bool m_bUHNames; bool m_bAwayNotify; bool m_bAccountNotify; + bool m_bExtendedJoin; CString m_sPerms; CString m_sPermModes; std::set m_scUserModes; diff --git a/src/IRCSock.cpp b/src/IRCSock.cpp index 2e6ab49c..64fd091f 100644 --- a/src/IRCSock.cpp +++ b/src/IRCSock.cpp @@ -62,6 +62,7 @@ CIRCSock::CIRCSock(CIRCNetwork* pNetwork) m_bUHNames(false), m_bAwayNotify(false), m_bAccountNotify(false), + m_bExtendedJoin(false), m_sPerms("*!@%+"), m_sPermModes("qaohv"), m_scUserModes(), @@ -591,6 +592,21 @@ void CIRCSock::ReadLine(const CString& sData) { if (pChan->IsDetached()) { return; } + + if (HasExtendedJoin()) { + CString sExtendedLine = sLine; + sLine = ":" + Nick.GetNickMask() + " JOIN " + pChan->GetName(); + + const vector& vClients = m_pNetwork->GetClients(); + for (CClient* pClient : vClients) { + if (pClient->HasExtendedJoin()) { + m_pNetwork->PutUser(sExtendedLine, pClient); + } else { + m_pNetwork->PutUser(sLine, pClient); + } + } + return; + } } } else if (sCmd.Equals("PART")) { CString sChan = sRest.Token(0).TrimPrefix_n(); @@ -811,6 +827,7 @@ void CIRCSock::ReadLine(const CString& sData) { {"userhost-in-names", [this](bool bVal) { m_bUHNames = bVal; }}, {"away-notify", [this](bool bVal) { m_bAwayNotify = bVal; }}, {"account-notify", [this](bool bVal) { m_bAccountNotify = bVal; }}, + {"extended-join", [this](bool bVal) { m_bExtendedJoin = bVal; }}, }; if (sSubCmd == "LS") {