Make all the modules support networks

This commit is contained in:
Kyle Fuller
2011-08-24 14:01:34 +01:00
parent ee7a2083c8
commit 0b1627c529
33 changed files with 199 additions and 183 deletions
+17 -6
View File
@@ -9,6 +9,7 @@
#include "FileUtils.h"
#include "User.h"
#include "IRCNetwork.h"
#include "Chan.h"
#include "Server.h"
@@ -74,6 +75,7 @@ void CLogMod::PutLog(const CString& sLine, const CString& sWindow /*= "Status"*/
sPath = buffer;
// $WINDOW has to be handled last, since it can contain %
sPath.Replace("$NETWORK", (m_pNetwork ? m_pNetwork->GetName() : "znc"));
sPath.Replace("$WINDOW", sWindow.Replace_n("/", "?"));
// Check if it's allowed to write in this specific path
@@ -109,7 +111,7 @@ void CLogMod::PutLog(const CString& sLine, const CNick& Nick)
CString CLogMod::GetServer()
{
CServer* pServer = m_pUser->GetCurrentServer();
CServer* pServer = m_pNetwork->GetCurrentServer();
CString sSSL;
if (!pServer)
@@ -126,12 +128,12 @@ bool CLogMod::OnLoad(const CString& sArgs, CString& sMessage)
m_sLogPath = sArgs;
// Add default filename to path if it's a folder
if (m_sLogPath.Right(1) == "/" || m_sLogPath.find("$WINDOW")==string::npos)
if (m_sLogPath.Right(1) == "/" || m_sLogPath.find("$WINDOW") == string::npos || m_sLogPath.find("$NETWORK") == string::npos)
{
if (!m_sLogPath.empty()) {
m_sLogPath += "/";
}
m_sLogPath += "$WINDOW_%Y%m%d.log";
m_sLogPath += "$NETWORK_$WINDOW_%Y%m%d.log";
}
// Check if it's allowed to write in this path in general
@@ -204,7 +206,10 @@ CModule::EModRet CLogMod::OnTopic(CNick& Nick, CChan& Channel, CString& sTopic)
/* notices */
CModule::EModRet CLogMod::OnUserNotice(CString& sTarget, CString& sMessage)
{
PutLog("-" + GetUser()->GetCurNick() + "- " + sMessage, sTarget);
if (m_pNetwork) {
PutLog("-" + m_pNetwork->GetCurNick() + "- " + sMessage, sTarget);
}
return CONTINUE;
}
@@ -223,7 +228,10 @@ CModule::EModRet CLogMod::OnChanNotice(CNick& Nick, CChan& Channel, CString& sMe
/* actions */
CModule::EModRet CLogMod::OnUserAction(CString& sTarget, CString& sMessage)
{
PutLog("* " + GetUser()->GetCurNick() + " " + sMessage, sTarget);
if (m_pNetwork) {
PutLog("* " + m_pNetwork->GetCurNick() + " " + sMessage, sTarget);
}
return CONTINUE;
}
@@ -242,7 +250,10 @@ CModule::EModRet CLogMod::OnChanAction(CNick& Nick, CChan& Channel, CString& sMe
/* msgs */
CModule::EModRet CLogMod::OnUserMsg(CString& sTarget, CString& sMessage)
{
PutLog("<" + GetUser()->GetCurNick() + "> " + sMessage, sTarget);
if (m_pNetwork) {
PutLog("<" + m_pNetwork->GetCurNick() + "> " + sMessage, sTarget);
}
return CONTINUE;
}