mirror of
https://github.com/znc/znc.git
synced 2026-07-30 21:43:49 +02:00
Add CIRCNetwork::ExpandString
This commit is contained in:
+5
-1
@@ -568,7 +568,11 @@ bool CClient::SendMotd() {
|
||||
}
|
||||
|
||||
for (unsigned int a = 0; a < vsMotd.size(); a++) {
|
||||
PutStatusNotice(m_pUser->ExpandString(vsMotd[a]));
|
||||
if (m_pNetwork) {
|
||||
PutStatusNotice(m_pNetwork->ExpandString(vsMotd[a]));
|
||||
} else {
|
||||
PutStatusNotice(m_pUser->ExpandString(vsMotd[a]));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -896,3 +896,17 @@ void CIRCNetwork::SetRealName(const CString& s) {
|
||||
}
|
||||
}
|
||||
|
||||
CString CIRCNetwork::ExpandString(const CString& sStr) const {
|
||||
CString sRet;
|
||||
return ExpandString(sStr, sRet);
|
||||
}
|
||||
|
||||
CString& CIRCNetwork::ExpandString(const CString& sStr, CString& sRet) const {
|
||||
sRet.Replace("%defnick%", GetNick());
|
||||
sRet.Replace("%nick%", GetCurNick());
|
||||
sRet.Replace("%altnick%", GetAltNick());
|
||||
sRet.Replace("%ident%", GetIdent());
|
||||
sRet.Replace("%realname%", GetRealName());
|
||||
|
||||
return m_pUser->ExpandString(sRet, sRet);
|
||||
}
|
||||
|
||||
@@ -128,6 +128,9 @@ public:
|
||||
void SetAltNick(const CString& s);
|
||||
void SetIdent(const CString& s);
|
||||
void SetRealName(const CString& s);
|
||||
|
||||
CString ExpandString(const CString& sStr) const;
|
||||
CString& ExpandString(const CString& sStr, CString& sRet) const;
|
||||
private:
|
||||
bool JoinChan(CChan* pChan);
|
||||
void JoinChans(set<CChan*>& sChans);
|
||||
|
||||
+2
-2
@@ -80,7 +80,7 @@ void CIRCSock::Quit(const CString& sQuitMsg) {
|
||||
if (!sQuitMsg.empty()) {
|
||||
PutIRC("QUIT :" + sQuitMsg);
|
||||
} else {
|
||||
PutIRC("QUIT :" + m_pNetwork->GetUser()->ExpandString(m_pNetwork->GetUser()->GetQuitMsg()));
|
||||
PutIRC("QUIT :" + m_pNetwork->ExpandString(m_pNetwork->GetUser()->GetQuitMsg()));
|
||||
}
|
||||
Close(CLT_AFTERWRITE);
|
||||
}
|
||||
@@ -789,7 +789,7 @@ bool CIRCSock::OnGeneralCTCP(CNick& Nick, CString& sMessage) {
|
||||
CString sReply;
|
||||
|
||||
if (it != mssCTCPReplies.end()) {
|
||||
sReply = m_pNetwork->GetUser()->ExpandString(it->second);
|
||||
sReply = m_pNetwork->ExpandString(it->second);
|
||||
bHaveReply = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,10 @@ public:
|
||||
SetReply(sReply);
|
||||
}
|
||||
|
||||
if (m_pNetwork) {
|
||||
return m_pNetwork->ExpandString(sReply);
|
||||
}
|
||||
|
||||
return m_pUser->ExpandString(sReply);
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ public:
|
||||
|
||||
// We don't limit this to NICKLEN, because we dont know
|
||||
// NICKLEN yet.
|
||||
sNick = m_sAwayNick = m_pUser->ExpandString(m_sAwayNick);
|
||||
sNick = m_sAwayNick = m_pNetwork->ExpandString(m_sAwayNick);
|
||||
}
|
||||
return CONTINUE;
|
||||
}
|
||||
@@ -166,7 +166,7 @@ public:
|
||||
uLen = pIRCSock->GetMaxNickLen();
|
||||
}
|
||||
|
||||
m_sAwayNick = m_pUser->ExpandString(m_sFormat).Left(uLen);
|
||||
m_sAwayNick = m_pNetwork->ExpandString(m_sFormat).Left(uLen);
|
||||
return m_sAwayNick;
|
||||
}
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
CString sData = m_pUser->ExpandString(GetNV("Format"));
|
||||
CString sData = m_pNetwork->ExpandString(GetNV("Format"));
|
||||
|
||||
// If the format doesn't contain anything expandable, we'll
|
||||
// assume this is an "old"-style format string.
|
||||
|
||||
+8
-2
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
#include "User.h"
|
||||
#include "IRCNetwork.h"
|
||||
#include <algorithm>
|
||||
|
||||
class CPerform : public CModule {
|
||||
@@ -50,7 +51,12 @@ class CPerform : public CModule {
|
||||
Table.SetCell("Id", CString(index));
|
||||
Table.SetCell("Perform", *it);
|
||||
|
||||
sExpanded = GetUser()->ExpandString(*it);
|
||||
if (m_pNetwork) {
|
||||
sExpanded = m_pNetwork->ExpandString(*it);
|
||||
} else {
|
||||
sExpanded = GetUser()->ExpandString(*it);
|
||||
}
|
||||
|
||||
if (sExpanded != *it) {
|
||||
Table.SetCell("Expanded", sExpanded);
|
||||
}
|
||||
@@ -122,7 +128,7 @@ public:
|
||||
|
||||
virtual void OnIRCConnected() {
|
||||
for (VCString::const_iterator it = m_vPerform.begin(); it != m_vPerform.end(); ++it) {
|
||||
PutIRC(GetUser()->ExpandString(*it));
|
||||
PutIRC(m_pNetwork->ExpandString(*it));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -58,7 +58,7 @@ public:
|
||||
}
|
||||
virtual ~CWatchEntry() {}
|
||||
|
||||
bool IsMatch(const CNick& Nick, const CString& sText, const CString& sSource, const CUser* pUser) {
|
||||
bool IsMatch(const CNick& Nick, const CString& sText, const CString& sSource, const CIRCNetwork* pNetwork) {
|
||||
if (IsDisabled()) {
|
||||
return false;
|
||||
}
|
||||
@@ -85,7 +85,7 @@ public:
|
||||
return false;
|
||||
if (!Nick.GetHostMask().AsLower().WildCmp(m_sHostMask.AsLower()))
|
||||
return false;
|
||||
return (sText.AsLower().WildCmp(pUser->ExpandString(m_sPattern).AsLower()));
|
||||
return (sText.AsLower().WildCmp(pNetwork->ExpandString(m_sPattern).AsLower()));
|
||||
}
|
||||
|
||||
bool operator ==(const CWatchEntry& WatchEntry) {
|
||||
@@ -287,7 +287,7 @@ private:
|
||||
for (list<CWatchEntry>::iterator it = m_lsWatchers.begin(); it != m_lsWatchers.end(); ++it) {
|
||||
CWatchEntry& WatchEntry = *it;
|
||||
|
||||
if (WatchEntry.IsMatch(Nick, sMessage, sSource, m_pUser)) {
|
||||
if (WatchEntry.IsMatch(Nick, sMessage, sSource, m_pNetwork)) {
|
||||
if (m_pNetwork->IsUserAttached()) {
|
||||
m_pNetwork->PutUser(":" + WatchEntry.GetTarget() + "!watch@znc.in PRIVMSG " +
|
||||
m_pNetwork->GetCurNick() + " :" + sMessage);
|
||||
|
||||
Reference in New Issue
Block a user