mirror of
https://github.com/znc/znc.git
synced 2026-08-07 01:13:25 +02:00
Make all the modules support networks
This commit is contained in:
+17
-6
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user