]> jfr.im git - irc/rizon/znc.git/commitdiff
Add CModule::ExpandString()
authorAlexey Sokolov <redacted>
Fri, 23 Nov 2012 14:40:30 +0000 (21:40 +0700)
committerAlexey Sokolov <redacted>
Fri, 23 Nov 2012 14:40:30 +0000 (21:40 +0700)
It chooses which ExpandString() to call, of user or of network.

include/znc/Modules.h
modules/autoattach.cpp
src/Modules.cpp

index d347fb4d754ab3ccf053015bfb39c3c7acf7d1a8..ac83af3c15b3624bccbd2f83e5789b116d18d1b5 100644 (file)
@@ -875,6 +875,8 @@ public:
        bool ClearNV(bool bWriteToDisk = true);
 
        const CString& GetSavePath() const;
+       CString ExpandString(const CString& sStr) const;
+       CString& ExpandString(const CString& sStr, CString& sRet) const;
 
        // Setters
        void SetType(CModInfo::EModuleType eType) { m_eType = eType; }
index d8b68e98c177735111b2b6c0840c498396dcced1..a4c979cfa25170638e702ed3db71399dce9db84a 100644 (file)
@@ -35,7 +35,7 @@ public:
                        return false;
                if (!sChan.WildCmp(m_sChannelWildcard))
                        return false;
-               if (!sMessage.WildCmp(m_pModule->GetUser()->ExpandString(m_sSearchWildcard)))
+               if (!sMessage.WildCmp(m_pModule->ExpandString(m_sSearchWildcard)))
                        return false;
                return true;
        }
@@ -246,7 +246,8 @@ public:
                VAttachIter it = m_vMatches.begin();
                for (; it != m_vMatches.end(); ++it) {
                        if (it->GetHostMask() == attach.GetHostMask()
-                                       && it->GetChans() == attach.GetChans())
+                                       && it->GetChans() == attach.GetChans()
+                                       && it->GetSearch() == attach.GetSearch())
                                return false;
                }
 
index a91a7333ebfe7c4a9105c499e33af244f50cd9df..e39105d92bc9575c44064937e99468f4c6d7fa1e 100644 (file)
@@ -155,6 +155,25 @@ void CModule::SetUser(CUser* pUser) { m_pUser = pUser; }
 void CModule::SetNetwork(CIRCNetwork* pNetwork) { m_pNetwork = pNetwork; }
 void CModule::SetClient(CClient* pClient) { m_pClient = pClient; }
 
+CString CModule::ExpandString(const CString& sStr) const {
+       CString sRet;
+       return ExpandString(sStr, sRet);
+}
+
+CString& CModule::ExpandString(const CString& sStr, CString& sRet) const {
+       sRet = sStr;
+
+       if (m_pNetwork) {
+               return m_pNetwork->ExpandString(sRet, sRet);
+       }
+
+       if (m_pUser) {
+               return m_pUser->ExpandString(sRet, sRet);
+       }
+
+       return sRet;
+}
+
 const CString& CModule::GetSavePath() const {
        if (!CFile::Exists(m_sSavePath)) {
                CDir::MakeDir(m_sSavePath);