mirror of
https://github.com/znc/znc.git
synced 2026-08-08 18:03:22 +02:00
Support custom message tags
This provides a way for modules to register message tags and updates the core to send tags to clients if the relevant capabilities are enabled.
This commit is contained in:
+19
-2
@@ -124,6 +124,7 @@ class CClient : public CIRCSocket {
|
||||
m_sIdentifier(""),
|
||||
m_spAuth(),
|
||||
m_ssAcceptedCaps(),
|
||||
m_ssSupportedTags(),
|
||||
m_mCoreCaps({
|
||||
{"multi-prefix",
|
||||
{false, [this](bool bVal) { m_bNamesx = bVal; }}},
|
||||
@@ -132,8 +133,14 @@ class CClient : public CIRCSocket {
|
||||
{"echo-message",
|
||||
{false, [this](bool bVal) { m_bEchoMessage = bVal; }}},
|
||||
{"server-time",
|
||||
{false, [this](bool bVal) { m_bServerTime = bVal; }}},
|
||||
{"batch", {false, [this](bool bVal) { m_bBatch = bVal; }}},
|
||||
{false, [this](bool bVal) {
|
||||
m_bServerTime = bVal;
|
||||
SetTagSupport("time", bVal);
|
||||
}}},
|
||||
{"batch", {false, [this](bool bVal) {
|
||||
m_bBatch = bVal;
|
||||
SetTagSupport("batch", bVal);
|
||||
}}},
|
||||
{"cap-notify",
|
||||
{false, [this](bool bVal) { m_bCapNotify = bVal; }}},
|
||||
{"away-notify",
|
||||
@@ -258,6 +265,15 @@ class CClient : public CIRCSocket {
|
||||
return 1 == m_ssAcceptedCaps.count(sCap);
|
||||
}
|
||||
|
||||
bool IsTagEnabled(const CString& sTag) const {
|
||||
return 1 == m_ssSupportedTags.count(sTag);
|
||||
}
|
||||
/** Registers a tag as being supported or unsupported by a client.
|
||||
* @param sTag The tag to register.
|
||||
* @param bState Whether the client supports the tag.
|
||||
*/
|
||||
void SetTagSupport(const CString& sTag, bool bState);
|
||||
|
||||
void NotifyServerDependentCaps(const SCString& ssCaps);
|
||||
void ClearServerDependentCaps();
|
||||
|
||||
@@ -336,6 +352,7 @@ class CClient : public CIRCSocket {
|
||||
CString m_sIdentifier;
|
||||
std::shared_ptr<CAuthBase> m_spAuth;
|
||||
SCString m_ssAcceptedCaps;
|
||||
SCString m_ssSupportedTags;
|
||||
// The capabilities supported by the ZNC core - capability names mapped
|
||||
// to a pair which contains a bool describing whether the capability is
|
||||
// server-dependent, and a capability value change handler.
|
||||
|
||||
@@ -1288,9 +1288,13 @@ class CModule {
|
||||
virtual bool IsClientCapSupported(CClient* pClient, const CString& sCap,
|
||||
bool bState);
|
||||
/** Called when we actually need to turn a capability on or off for a client.
|
||||
* If implementing a custom capability, make sure to call
|
||||
* pClient->SetTagSupport("tag-name", bState) for each tag that the
|
||||
* capability provides.
|
||||
* @param pClient The client which requested the capability.
|
||||
* @param sCap name of wanted capability.
|
||||
* @param bState On or off, depending on which case client needs.
|
||||
* @see CClient::SetTagSupport()
|
||||
*/
|
||||
virtual void OnClientCapRequest(CClient* pClient, const CString& sCap,
|
||||
bool bState);
|
||||
|
||||
Reference in New Issue
Block a user