diff --git a/include/znc/Client.h b/include/znc/Client.h index 2feaacf0..70a31b24 100644 --- a/include/znc/Client.h +++ b/include/znc/Client.h @@ -96,6 +96,7 @@ public: m_bGotUser(false), m_bInCap(false), m_bCapNotify(false), + m_bAwayNotify(false), m_bNamesx(false), m_bUHNames(false), m_bAway(false), @@ -119,6 +120,7 @@ public: {"server-time", {false, [this](bool bVal) { m_bServerTime = bVal; }}}, {"batch", {false, [this](bool bVal) { m_bBatch = bVal; }}}, {"cap-notify", {false, [this](bool bVal) { m_bCapNotify = bVal; }}}, + {"away-notify", {true, [this](bool bVal) { m_bAwayNotify = bVal; }}}, }) { EnableReadLine(); @@ -145,6 +147,7 @@ public: CString GetNickMask() const; CString GetIdentifier() const { return m_sIdentifier; } bool HasCapNotify() const { return m_bCapNotify; } + bool HasAwayNotify() const { return m_bAwayNotify; } bool HasNamesx() const { return m_bNamesx; } bool HasUHNames() const { return m_bUHNames; } bool IsAway() const { return m_bAway; } @@ -209,6 +212,7 @@ protected: bool m_bGotUser; bool m_bInCap; bool m_bCapNotify; + bool m_bAwayNotify; bool m_bNamesx; bool m_bUHNames; bool m_bAway; diff --git a/include/znc/IRCSock.h b/include/znc/IRCSock.h index 96073f62..5ff736a5 100644 --- a/include/znc/IRCSock.h +++ b/include/znc/IRCSock.h @@ -101,6 +101,7 @@ public: CIRCNetwork* GetNetwork() const { return m_pNetwork; } bool HasNamesx() const { return m_bNamesx; } bool HasUHNames() const { return m_bUHNames; } + bool HasAwayNotify() const { return m_bAwayNotify; } const std::set& GetUserModes() const { return m_scUserModes; } // This is true if we are past raw 001 bool IsAuthed() const { return m_bAuthed; } @@ -127,6 +128,7 @@ protected: bool m_bAuthed; bool m_bNamesx; bool m_bUHNames; + bool m_bAwayNotify; CString m_sPerms; CString m_sPermModes; std::set m_scUserModes; diff --git a/src/IRCSock.cpp b/src/IRCSock.cpp index 8a571295..eae144d4 100644 --- a/src/IRCSock.cpp +++ b/src/IRCSock.cpp @@ -60,6 +60,7 @@ CIRCSock::CIRCSock(CIRCNetwork* pNetwork) m_bAuthed(false), m_bNamesx(false), m_bUHNames(false), + m_bAwayNotify(false), m_sPerms("*!@%+"), m_sPermModes("qaohv"), m_scUserModes(), @@ -809,7 +810,7 @@ void CIRCSock::ReadLine(const CString& sData) { sArgs.Split(" ", vsTokens, false); for (const CString& sCap : vsTokens) { - if (OnServerCapAvailable(sCap) || sCap == "multi-prefix" || sCap == "userhost-in-names") { + if (OnServerCapAvailable(sCap) || sCap == "multi-prefix" || sCap == "userhost-in-names" || sCap == "away-notify") { m_ssPendingCaps.insert(sCap); } } @@ -820,6 +821,8 @@ void CIRCSock::ReadLine(const CString& sData) { m_bNamesx = true; } else if ("userhost-in-names" == sArgs) { m_bUHNames = true; + } else if ("away-notify" == sArgs) { + m_bAwayNotify = true; } m_ssAcceptedCaps.insert(sArgs); } else if (sSubCmd == "NAK") { @@ -836,6 +839,14 @@ void CIRCSock::ReadLine(const CString& sData) { } else if (sCmd.Equals("INVITE")) { IRCSOCKMODULECALL(OnInvite(Nick, sLine.Token(3).TrimPrefix_n(":")), &bReturn); if (bReturn) return; + } else if (sCmd.Equals("AWAY")) { + const vector& vClients = m_pNetwork->GetClients(); + for (CClient* pClient : vClients) { + if (pClient->HasAwayNotify()) { + m_pNetwork->PutUser(sLine, pClient); + } + } + return; } }