Permalink
Browse files

Add CModule::ExpandString()

It chooses which ExpandString() to call, of user or of network.
  • Loading branch information...
1 parent f941ee5 commit 4036114975bcbcbbd89155fd61893bec656874b0 @DarthGandalf DarthGandalf committed Nov 23, 2012
Showing with 24 additions and 2 deletions.
  1. +2 −0 include/znc/Modules.h
  2. +3 −2 modules/autoattach.cpp
  3. +19 −0 src/Modules.cpp
View
@@ -875,6 +875,8 @@ class CModule {
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; }
View
@@ -35,7 +35,7 @@ class CAttachMatch {
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 @@ class CChanAttach : public CModule {
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;
}
View
@@ -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);

0 comments on commit 4036114

Please sign in to comment.