mirror of
https://github.com/znc/znc.git
synced 2026-08-07 17:33:34 +02:00
Make all the modules support networks
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include "Client.h"
|
||||
#include "FileUtils.h"
|
||||
#include "Server.h"
|
||||
#include "IRCNetwork.h"
|
||||
#include "User.h"
|
||||
|
||||
#include <syslog.h>
|
||||
@@ -42,11 +43,11 @@ public:
|
||||
}
|
||||
|
||||
virtual void OnIRCConnected() {
|
||||
Log("[" + m_pUser->GetUserName() + "] connected to IRC: " + m_pUser->GetCurrentServer()->GetName());
|
||||
Log("[" + m_pUser->GetUserName() + "/" + m_pNetwork->GetName() + "] connected to IRC: " + m_pNetwork->GetCurrentServer()->GetName());
|
||||
}
|
||||
|
||||
virtual void OnIRCDisconnected() {
|
||||
Log("[" + m_pUser->GetUserName() + "] disconnected from IRC");
|
||||
Log("[" + m_pUser->GetUserName() + "/" + m_pNetwork->GetName() + "] disconnected from IRC");
|
||||
}
|
||||
|
||||
virtual EModRet OnRaw(CString& sLine) {
|
||||
@@ -56,8 +57,8 @@ public:
|
||||
CString sError(sLine.substr(6));
|
||||
if (sError.Left(1) == ":")
|
||||
sError.LeftChomp();
|
||||
Log("[" + m_pUser->GetUserName() + "] disconnected from IRC: " +
|
||||
m_pUser->GetCurrentServer()->GetName() + " [" + sError + "]", LOG_NOTICE);
|
||||
Log("[" + m_pUser->GetUserName() + "/" + m_pNetwork->GetName() + "] disconnected from IRC: " +
|
||||
m_pNetwork->GetCurrentServer()->GetName() + " [" + sError + "]", LOG_NOTICE);
|
||||
}
|
||||
return CONTINUE;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include "Chan.h"
|
||||
#include "User.h"
|
||||
#include "IRCNetwork.h"
|
||||
|
||||
class CAutoCycleMod : public CModule {
|
||||
public:
|
||||
@@ -125,7 +126,7 @@ protected:
|
||||
|
||||
// Is that person us and we don't have op?
|
||||
const CNick& pNick = Channel.GetNicks().begin()->second;
|
||||
if (!pNick.HasPerm(CChan::Op) && pNick.GetNick().Equals(m_pUser->GetCurNick()))
|
||||
if (!pNick.HasPerm(CChan::Op) && pNick.GetNick().Equals(m_pNetwork->GetCurNick()))
|
||||
Channel.Cycle();
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -6,8 +6,8 @@
|
||||
* by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
#include "IRCNetwork.h"
|
||||
#include "Chan.h"
|
||||
#include "User.h"
|
||||
|
||||
class CAutoOpMod;
|
||||
|
||||
@@ -345,7 +345,7 @@ public:
|
||||
|
||||
// First verify that the guy who challenged us matches a user's host
|
||||
if (pUser->HostMatches(Nick.GetHostMask())) {
|
||||
const vector<CChan*>& Chans = m_pUser->GetChans();
|
||||
const vector<CChan*>& Chans = m_pNetwork->GetChans();
|
||||
bMatchedHost = true;
|
||||
|
||||
// Also verify that they are opped in at least one of the user's chans
|
||||
@@ -440,7 +440,7 @@ public:
|
||||
}
|
||||
|
||||
void OpUser(const CNick& Nick, const CAutoOpUser& User) {
|
||||
const vector<CChan*>& Chans = m_pUser->GetChans();
|
||||
const vector<CChan*>& Chans = m_pNetwork->GetChans();
|
||||
|
||||
for (size_t a = 0; a < Chans.size(); a++) {
|
||||
const CChan& Chan = *Chans[a];
|
||||
@@ -467,4 +467,4 @@ template<> void TModInfo<CAutoOpMod>(CModInfo& Info) {
|
||||
Info.SetWikiPage("autoop");
|
||||
}
|
||||
|
||||
MODULEDEFS(CAutoOpMod, "Auto op the good guys")
|
||||
NETWORKMODULEDEFS(CAutoOpMod, "Auto op the good guys")
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
|
||||
#include "Modules.h"
|
||||
#include "IRCNetwork.h"
|
||||
#include "IRCSock.h"
|
||||
#include "User.h"
|
||||
|
||||
@@ -42,7 +43,7 @@ public:
|
||||
}
|
||||
|
||||
void Handle(const CString& sNick) {
|
||||
CIRCSock *pIRCSock = GetUser()->GetIRCSock();
|
||||
CIRCSock *pIRCSock = m_pNetwork->GetIRCSock();
|
||||
if (!pIRCSock)
|
||||
// WTF?
|
||||
return;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
// @todo handle raw 433 (nick in use)
|
||||
#include "IRCSock.h"
|
||||
#include "User.h"
|
||||
#include "IRCNetwork.h"
|
||||
|
||||
class CAwayNickMod;
|
||||
|
||||
@@ -31,10 +32,10 @@ public:
|
||||
|
||||
private:
|
||||
virtual void RunJob() {
|
||||
CUser* pUser = m_Module.GetUser();
|
||||
CIRCNetwork* pNetwork = m_Module.GetNetwork();
|
||||
|
||||
if (pUser->IsUserAttached() && pUser->IsIRCConnected()) {
|
||||
CString sConfNick = pUser->GetNick();
|
||||
if (pNetwork->IsUserAttached() && pNetwork->IsIRCConnected()) {
|
||||
CString sConfNick = pNetwork->GetUser()->GetNick();
|
||||
m_Module.PutIRC("NICK " + sConfNick);
|
||||
}
|
||||
}
|
||||
@@ -76,7 +77,7 @@ public:
|
||||
}
|
||||
|
||||
void StartBackNickTimer() {
|
||||
CIRCSock* pIRCSock = m_pUser->GetIRCSock();
|
||||
CIRCSock* pIRCSock = m_pNetwork->GetIRCSock();
|
||||
|
||||
if (pIRCSock) {
|
||||
CString sConfNick = m_pUser->GetNick();
|
||||
@@ -159,7 +160,7 @@ public:
|
||||
|
||||
CString GetAwayNick() {
|
||||
unsigned int uLen = 9;
|
||||
CIRCSock* pIRCSock = m_pUser->GetIRCSock();
|
||||
CIRCSock* pIRCSock = m_pNetwork->GetIRCSock();
|
||||
|
||||
if (pIRCSock) {
|
||||
uLen = pIRCSock->GetMaxNickLen();
|
||||
@@ -179,9 +180,9 @@ CAwayNickTimer::CAwayNickTimer(CAwayNickMod& Module)
|
||||
m_Module(Module) {}
|
||||
|
||||
void CAwayNickTimer::RunJob() {
|
||||
CUser* pUser = m_Module.GetUser();
|
||||
CIRCNetwork* pNetwork = m_Module.GetNetwork();
|
||||
|
||||
if (!pUser->IsUserAttached() && pUser->IsIRCConnected()) {
|
||||
if (!pNetwork->IsUserAttached() && pNetwork->IsIRCConnected()) {
|
||||
m_Module.PutIRC("NICK " + m_Module.GetAwayNick());
|
||||
}
|
||||
}
|
||||
@@ -190,4 +191,4 @@ template<> void TModInfo<CAwayNickMod>(CModInfo& Info) {
|
||||
Info.SetWikiPage("awaynick");
|
||||
}
|
||||
|
||||
MODULEDEFS(CAwayNickMod, "Change your nick while you are away")
|
||||
NETWORKMODULEDEFS(CAwayNickMod, "Change your nick while you are away")
|
||||
|
||||
+10
-5
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
#include "User.h"
|
||||
#include "IRCNetwork.h"
|
||||
#include "IRCSock.h"
|
||||
#include "znc.h"
|
||||
|
||||
@@ -147,17 +148,21 @@ private:
|
||||
return false;
|
||||
|
||||
// Disconnect all clients
|
||||
vector<CClient*>& vpClients = pUser->GetClients();
|
||||
vector<CClient*> vpClients = pUser->GetAllClients();
|
||||
vector<CClient*>::iterator it;
|
||||
for (it = vpClients.begin(); it != vpClients.end(); ++it) {
|
||||
(*it)->PutStatusNotice(MESSAGE);
|
||||
(*it)->Close(Csock::CLT_AFTERWRITE);
|
||||
}
|
||||
|
||||
// Disconnect from IRC...
|
||||
CIRCSock *pIRCSock = pUser->GetIRCSock();
|
||||
if (pIRCSock) {
|
||||
pIRCSock->Quit();
|
||||
// Disconnect all networks from irc
|
||||
vector<CIRCNetwork*> vNetworks = pUser->GetNetworks();
|
||||
for (vector<CIRCNetwork*>::iterator it2 = vNetworks.begin(); it2 != vNetworks.end(); ++it2) {
|
||||
CIRCNetwork *pNetwork = *it2;
|
||||
CIRCSock *pIRCSock = pNetwork->GetIRCSock();
|
||||
if (pIRCSock) {
|
||||
pIRCSock->Quit();
|
||||
}
|
||||
}
|
||||
|
||||
// ...and don't reconnect
|
||||
|
||||
+15
-13
@@ -8,25 +8,27 @@
|
||||
|
||||
#include "Chan.h"
|
||||
#include "User.h"
|
||||
#include "IRCNetwork.h"
|
||||
#include "znc.h"
|
||||
|
||||
class CChanSaverMod : public CModule {
|
||||
public:
|
||||
MODCONSTRUCTOR(CChanSaverMod) {
|
||||
const vector<CChan*>& vChans = m_pUser->GetChans();
|
||||
vector<CChan*>::const_iterator it = vChans.begin();
|
||||
vector<CChan*>::const_iterator end = vChans.end();
|
||||
|
||||
m_bWriteConf = false;
|
||||
|
||||
for (; it != end; ++it) {
|
||||
CChan *pChan = *it;
|
||||
vector<CIRCNetwork*> vNetworks = pUser->GetNetworks();
|
||||
for (vector<CIRCNetwork*>::iterator it = vNetworks.begin(); it != vNetworks.end(); ++it) {
|
||||
const vector<CChan*>& vChans = (*it)->GetChans();
|
||||
|
||||
// If that channel isn't yet in the config,
|
||||
// we'll have to add it...
|
||||
if (!pChan->InConfig()) {
|
||||
pChan->SetInConfig(true);
|
||||
m_bWriteConf = true;
|
||||
for (vector<CChan*>::const_iterator it2 = vChans.begin(); it2 != vChans.end(); ++it2) {
|
||||
CChan *pChan = *it2;
|
||||
|
||||
// If that channel isn't yet in the config,
|
||||
// we'll have to add it...
|
||||
if (!pChan->InConfig()) {
|
||||
pChan->SetInConfig(true);
|
||||
m_bWriteConf = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -55,14 +57,14 @@ public:
|
||||
}
|
||||
|
||||
virtual void OnJoin(const CNick& Nick, CChan& Channel) {
|
||||
if (Nick.GetNick() == m_pUser->GetIRCNick().GetNick()) {
|
||||
if (Nick.GetNick() == m_pNetwork->GetIRCNick().GetNick()) {
|
||||
Channel.SetInConfig(true);
|
||||
CZNC::Get().WriteConfig();
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnPart(const CNick& Nick, CChan& Channel, const CString& sMessage) {
|
||||
if (Nick.GetNick() == m_pUser->GetIRCNick().GetNick()) {
|
||||
if (Nick.GetNick() == m_pNetwork->GetIRCNick().GetNick()) {
|
||||
Channel.SetInConfig(false);
|
||||
CZNC::Get().WriteConfig();
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
if(!m_bNewOnly || m_sClientsSeen.find(m_pClient->GetRemoteIP()) == m_sClientsSeen.end()) {
|
||||
SendNotification("Another client authenticated as your user. "
|
||||
"Use the 'ListClients' command to see all " +
|
||||
CString(m_pUser->GetClients().size()) + " clients.");
|
||||
CString(m_pUser->GetAllClients().size()) + " clients.");
|
||||
|
||||
// the set<> will automatically disregard duplicates:
|
||||
m_sClientsSeen.insert(m_pClient->GetRemoteIP());
|
||||
@@ -66,7 +66,7 @@ public:
|
||||
if(m_bOnDisconnect) {
|
||||
SendNotification("A client disconnected from your user. "
|
||||
"Use the 'ListClients' command to see the " +
|
||||
CString(m_pUser->GetClients().size()) + " remaining client(s).");
|
||||
CString(m_pUser->GetAllClients().size()) + " remaining client(s).");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+5
-4
@@ -24,6 +24,7 @@
|
||||
|
||||
#include "Chan.h"
|
||||
#include "User.h"
|
||||
#include "IRCNetwork.h"
|
||||
|
||||
#define REQUIRESSL 1
|
||||
|
||||
@@ -43,11 +44,11 @@ public:
|
||||
MCString::iterator it = FindNV(sTarget.AsLower());
|
||||
|
||||
if (it != EndNV()) {
|
||||
CChan* pChan = m_pUser->FindChan(sTarget);
|
||||
CChan* pChan = m_pNetwork->FindChan(sTarget);
|
||||
if (pChan) {
|
||||
if (pChan->KeepBuffer())
|
||||
pChan->AddBuffer(":\244" + m_pUser->GetIRCNick().GetNickMask() + " PRIVMSG " + sTarget + " :" + sMessage);
|
||||
m_pUser->PutUser(":\244" + m_pUser->GetIRCNick().GetNickMask() + " PRIVMSG " + sTarget + " :" + sMessage, NULL, m_pClient);
|
||||
pChan->AddBuffer(":\244" + m_pNetwork->GetIRCNick().GetNickMask() + " PRIVMSG " + sTarget + " :" + sMessage);
|
||||
m_pUser->PutUser(":\244" + m_pNetwork->GetIRCNick().GetNickMask() + " PRIVMSG " + sTarget + " :" + sMessage, NULL, m_pClient);
|
||||
}
|
||||
|
||||
CString sMsg = MakeIvec() + sMessage;
|
||||
@@ -155,4 +156,4 @@ template<> void TModInfo<CCryptMod>(CModInfo& Info) {
|
||||
Info.SetWikiPage("crypt");
|
||||
}
|
||||
|
||||
MODULEDEFS(CCryptMod, "Encryption for channel/private messages")
|
||||
NETWORKMODULEDEFS(CCryptMod, "Encryption for channel/private messages")
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
|
||||
#include "Modules.h"
|
||||
#include "User.h"
|
||||
#include "IRCNetwork.h"
|
||||
#include "Chan.h"
|
||||
|
||||
class CKickClientOnIRCDisconnect: public CModule {
|
||||
@@ -17,12 +17,12 @@ public:
|
||||
|
||||
void OnIRCDisconnected()
|
||||
{
|
||||
const vector<CChan*>& vChans = m_pUser->GetChans();
|
||||
const vector<CChan*>& vChans = m_pNetwork->GetChans();
|
||||
|
||||
for(vector<CChan*>::const_iterator it = vChans.begin(); it != vChans.end(); ++it)
|
||||
{
|
||||
if((*it)->IsOn()) {
|
||||
PutUser(":ZNC!znc@znc.in KICK " + (*it)->GetName() + " " + m_pUser->GetIRCNick().GetNick()
|
||||
PutUser(":ZNC!znc@znc.in KICK " + (*it)->GetName() + " " + m_pNetwork->GetIRCNick().GetNick()
|
||||
+ " :You have been disconnected from the IRC server");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
#include "Nick.h"
|
||||
#include "User.h"
|
||||
#include "IRCNetwork.h"
|
||||
|
||||
class CAntiIdle;
|
||||
|
||||
@@ -65,7 +65,7 @@ public:
|
||||
|
||||
virtual EModRet OnPrivMsg(CNick &Nick, CString &sMessage)
|
||||
{
|
||||
if(Nick.GetNick() == GetUser()->GetIRCNick().GetNick()
|
||||
if(Nick.GetNick() == m_pNetwork->GetIRCNick().GetNick()
|
||||
&& sMessage == "\xAE")
|
||||
return HALT;
|
||||
|
||||
@@ -94,8 +94,8 @@ private:
|
||||
|
||||
//! This function sends a query with (r) back to the user
|
||||
void CAntiIdleJob::RunJob() {
|
||||
CString sNick = GetModule()->GetUser()->GetIRCNick().GetNick();
|
||||
CString sNick = GetModule()->GetNetwork()->GetIRCNick().GetNick();
|
||||
GetModule()->PutIRC("PRIVMSG " + sNick + " :\xAE");
|
||||
}
|
||||
|
||||
MODULEDEFS(CAntiIdle, "Hides your real idle time")
|
||||
NETWORKMODULEDEFS(CAntiIdle, "Hides your real idle time")
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
#include "Client.h"
|
||||
#include "User.h"
|
||||
#include "IRCNetwork.h"
|
||||
#include "FileUtils.h"
|
||||
#include <sys/stat.h>
|
||||
|
||||
@@ -438,7 +439,7 @@ private:
|
||||
|
||||
void AddMessage(time_t iTime, const CNick & Nick, CString & sMessage)
|
||||
{
|
||||
if (m_pUser && Nick.GetNick() == m_pUser->GetIRCNick().GetNick())
|
||||
if (Nick.GetNick() == m_pNetwork->GetIRCNick().GetNick())
|
||||
return; // ignore messages from self
|
||||
AddMessage(CString(iTime) + ":" + Nick.GetNickMask() + ":" + sMessage);
|
||||
}
|
||||
@@ -474,5 +475,5 @@ void CAwayJob::RunJob()
|
||||
}
|
||||
}
|
||||
|
||||
MODULEDEFS(CAway, "You don't need this module, ZNC works ok without it")
|
||||
NETWORKMODULEDEFS(CAway, "You don't need this module, ZNC works ok without it")
|
||||
|
||||
|
||||
@@ -6,29 +6,30 @@
|
||||
* by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
#include "IRCNetwork.h"
|
||||
#include "Chan.h"
|
||||
#include "Modules.h"
|
||||
#include "User.h"
|
||||
|
||||
class CClearBufferOnMsgMod : public CModule {
|
||||
public:
|
||||
MODCONSTRUCTOR(CClearBufferOnMsgMod) {}
|
||||
|
||||
void ClearAllBuffers() {
|
||||
const vector<CChan*>& vChans = GetUser()->GetChans();
|
||||
vector<CChan*>::const_iterator it;
|
||||
if (m_pNetwork) {
|
||||
const vector<CChan*>& vChans = m_pNetwork->GetChans();
|
||||
vector<CChan*>::const_iterator it;
|
||||
|
||||
for (it = vChans.begin(); it != vChans.end(); ++it) {
|
||||
// Skip detached channels, they weren't read yet
|
||||
if ((*it)->IsDetached())
|
||||
continue;
|
||||
for (it = vChans.begin(); it != vChans.end(); ++it) {
|
||||
// Skip detached channels, they weren't read yet
|
||||
if ((*it)->IsDetached())
|
||||
continue;
|
||||
|
||||
(*it)->ClearBuffer();
|
||||
// We force KeepBuffer on all channels since this module
|
||||
// doesnt make any sense without
|
||||
(*it)->SetKeepBuffer(true);
|
||||
(*it)->ClearBuffer();
|
||||
// We force KeepBuffer on all channels since this module
|
||||
// doesnt make any sense without
|
||||
(*it)->SetKeepBuffer(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
virtual EModRet OnUserMsg(CString& sTarget, CString& sMessage) {
|
||||
|
||||
@@ -241,7 +241,7 @@ public:
|
||||
unsigned long uLongIP = sMessage.Token(3).ToULong();
|
||||
unsigned short uPort = sMessage.Token(4).ToUShort();
|
||||
unsigned long uFileSize = sMessage.Token(5).ToULong();
|
||||
GetFile(m_pUser->GetCurNick(), CUtils::GetIP(uLongIP), uPort, sLocalFile, uFileSize);
|
||||
GetFile(m_pClient->GetNick(), CUtils::GetIP(uLongIP), uPort, sLocalFile, uFileSize);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
#include "User.h"
|
||||
#include "IRCNetwork.h"
|
||||
#include "znc.h"
|
||||
|
||||
class CFOModule : public CModule {
|
||||
@@ -45,10 +46,10 @@ public:
|
||||
// Remove the leading space
|
||||
sBNCNicks.LeftChomp();
|
||||
|
||||
if (!m_pUser->GetIRCSock()) {
|
||||
if (!m_pNetwork->GetIRCSock()) {
|
||||
// if we are not connected to any IRC server, send
|
||||
// an empty or module-nick filled response.
|
||||
PutUser(":irc.znc.in 303 " + m_pUser->GetNick() + " :" + sBNCNicks);
|
||||
PutUser(":irc.znc.in 303 " + m_pClient->GetNick() + " :" + sBNCNicks);
|
||||
} else {
|
||||
// We let the server handle this request and then act on
|
||||
// the 303 response from the IRC server.
|
||||
@@ -61,9 +62,9 @@ public:
|
||||
CString sNick = sLine.Token(1);
|
||||
|
||||
if (IsOnlineModNick(sNick)) {
|
||||
PutUser(":znc.in 311 " + m_pUser->GetCurNick() + " " + sNick + " " + sNick + " znc.in * :" + sNick);
|
||||
PutUser(":znc.in 312 " + m_pUser->GetCurNick() + " " + sNick + " *.znc.in :Bouncer");
|
||||
PutUser(":znc.in 318 " + m_pUser->GetCurNick() + " " + sNick + " :End of /WHOIS list.");
|
||||
PutUser(":znc.in 311 " + m_pNetwork->GetCurNick() + " " + sNick + " " + sNick + " znc.in * :" + sNick);
|
||||
PutUser(":znc.in 312 " + m_pNetwork->GetCurNick() + " " + sNick + " *.znc.in :Bouncer");
|
||||
PutUser(":znc.in 318 " + m_pNetwork->GetCurNick() + " " + sNick + " :End of /WHOIS list.");
|
||||
|
||||
return HALT;
|
||||
}
|
||||
@@ -96,4 +97,4 @@ private:
|
||||
VCString m_ISONRequests;
|
||||
};
|
||||
|
||||
MODULEDEFS(CFOModule, "Fakes online status of ZNC *-users.")
|
||||
NETWORKMODULEDEFS(CFOModule, "Fakes online status of ZNC *-users.")
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "Chan.h"
|
||||
#include "Modules.h"
|
||||
#include "User.h"
|
||||
#include "IRCNetwork.h"
|
||||
|
||||
class CFloodDetachMod : public CModule {
|
||||
public:
|
||||
@@ -62,7 +63,7 @@ public:
|
||||
if (it->second.first + (time_t)m_iThresholdSecs >= now)
|
||||
continue;
|
||||
|
||||
CChan *pChan = m_pUser->FindChan(it->first);
|
||||
CChan *pChan = m_pNetwork->FindChan(it->first);
|
||||
if (it->second.second >= m_iThresholdMsgs
|
||||
&& pChan && pChan->IsDetached()) {
|
||||
// The channel is detached and it is over the
|
||||
|
||||
+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;
|
||||
}
|
||||
|
||||
|
||||
+39
-38
@@ -7,16 +7,22 @@
|
||||
*/
|
||||
|
||||
#include "User.h"
|
||||
#include "IRCNetwork.h"
|
||||
#include "znc.h"
|
||||
|
||||
class CSendRaw_Mod: public CModule {
|
||||
|
||||
void SendClient(const CString& sLine) {
|
||||
CUser *pUser = CZNC::Get().FindUser(sLine.Token(1));
|
||||
|
||||
if (pUser) {
|
||||
pUser->PutUser(sLine.Token(2, true));
|
||||
PutModule("Sent [" + sLine.Token(2, true) + "] to " + pUser->GetUserName());
|
||||
CIRCNetwork *pNetwork = pUser->FindNetwork(sLine.Token(2));
|
||||
|
||||
if (pNetwork) {
|
||||
pNetwork->PutUser(sLine.Token(3, true));
|
||||
PutModule("Sent [" + sLine.Token(3, true) + "] to " + pUser->GetUserName() + "/" + pNetwork->GetName());
|
||||
} else {
|
||||
PutModule("Network [" + sLine.Token(2) + "] not found for user [" + sLine.Token(1) + "]");
|
||||
}
|
||||
} else {
|
||||
PutModule("User [" + sLine.Token(1) + "] not found");
|
||||
}
|
||||
@@ -26,16 +32,21 @@ class CSendRaw_Mod: public CModule {
|
||||
CUser *pUser = CZNC::Get().FindUser(sLine.Token(1));
|
||||
|
||||
if (pUser) {
|
||||
pUser->PutIRC(sLine.Token(2, true));
|
||||
PutModule("Sent [" + sLine.Token(2, true) + "] to IRC Server of " + pUser->GetUserName());
|
||||
CIRCNetwork *pNetwork = pUser->FindNetwork(sLine.Token(2));
|
||||
|
||||
if (pNetwork) {
|
||||
pNetwork->PutIRC(sLine.Token(3, true));
|
||||
PutModule("Sent [" + sLine.Token(3, true) + "] to IRC Server of " + pUser->GetUserName() + "/" + pNetwork->GetName());
|
||||
} else {
|
||||
PutModule("Network [" + sLine.Token(2) + "] not found for user [" + sLine.Token(1) + "]");
|
||||
}
|
||||
} else {
|
||||
PutModule("User [" + sLine.Token(1) + "] not found");
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
virtual ~CSendRaw_Mod() {
|
||||
}
|
||||
virtual ~CSendRaw_Mod() {}
|
||||
|
||||
virtual bool OnLoad(const CString& sArgs, CString& sErrorMsg) {
|
||||
if (!m_pUser->IsAdmin()) {
|
||||
@@ -52,23 +63,29 @@ public:
|
||||
virtual bool OnWebRequest(CWebSock& WebSock, const CString& sPageName, CTemplate& Tmpl) {
|
||||
if (sPageName == "index") {
|
||||
if (WebSock.IsPost()) {
|
||||
CUser *pUser = CZNC::Get().FindUser(WebSock.GetParam("user"));
|
||||
bool bToServer = WebSock.GetParam("send_to") == "server";
|
||||
const CString sLine = WebSock.GetParam("line");
|
||||
|
||||
CUser *pUser = CZNC::Get().FindUser(WebSock.GetParam("user").Token(0, false, "/"));
|
||||
if (!pUser) {
|
||||
WebSock.GetSession()->AddError("User not found");
|
||||
return true;
|
||||
}
|
||||
|
||||
CIRCNetwork *pNetwork = pUser->FindNetwork(WebSock.GetParam("user").Token(1, false, "/"));
|
||||
if (!pNetwork) {
|
||||
WebSock.GetSession()->AddError("Network not found");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool bToServer = WebSock.GetParam("send_to") == "server";
|
||||
const CString sLine = WebSock.GetParam("line");
|
||||
|
||||
Tmpl["user"] = pUser->GetUserName();
|
||||
Tmpl[bToServer ? "to_server" : "to_client"] = "true";
|
||||
Tmpl["line"] = sLine;
|
||||
|
||||
if (bToServer) {
|
||||
pUser->PutIRC(sLine);
|
||||
pNetwork->PutIRC(sLine);
|
||||
} else {
|
||||
pUser->PutUser(sLine);
|
||||
pNetwork->PutUser(sLine);
|
||||
}
|
||||
|
||||
WebSock.GetSession()->AddSuccess("Line sent");
|
||||
@@ -78,6 +95,13 @@ public:
|
||||
for (map<CString,CUser*>::const_iterator it = msUsers.begin(); it != msUsers.end(); ++it) {
|
||||
CTemplate& l = Tmpl.AddRow("UserLoop");
|
||||
l["Username"] = (*it->second).GetUserName();
|
||||
|
||||
vector<CIRCNetwork*> vNetworks = (*it->second).GetNetworks();
|
||||
for (vector<CIRCNetwork*>::const_iterator it2 = vNetworks.begin(); it2 != vNetworks.end(); ++it2) {
|
||||
CTemplate& NetworkLoop = l.AddRow("NetworkLoop");
|
||||
NetworkLoop["Username"] = (*it->second).GetUserName();
|
||||
NetworkLoop["Network"] = (*it2)->GetName();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -86,35 +110,12 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
/* This is here for backwards compatibility. We used to accept commands in this format:
|
||||
<user> [<in|out>] <line> */
|
||||
virtual void OnUnknownModCommand(const CString& sLine) {
|
||||
const CString sUser = sLine.Token(0);
|
||||
const CString sDirection = sLine.Token(1);
|
||||
CUser *pUser = CZNC::Get().FindUser(sUser);
|
||||
|
||||
if (!pUser) {
|
||||
/* Since the user doesn't exist we'll adopt the default action of this method */
|
||||
PutModule("Unknown command!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (sDirection.Equals("IN")) {
|
||||
SendClient("Client " + sUser + " " + sLine.Token(2, true));
|
||||
} else if (sDirection.Equals("OUT")) {
|
||||
SendServer("Server " + sUser + " " + sLine.Token(2, true));
|
||||
} else {
|
||||
/* No direction given -- assume it's out for compatibility */
|
||||
SendServer("Server " + sUser + " " + sLine.Token(1, true));
|
||||
}
|
||||
}
|
||||
|
||||
MODCONSTRUCTOR(CSendRaw_Mod) {
|
||||
AddHelpCommand();
|
||||
AddCommand("Client", static_cast<CModCommand::ModCmdFunc>(&CSendRaw_Mod::SendClient),
|
||||
"[user] [data to send]", "The data will be sent to the user's IRC client(s)");
|
||||
"[user] [network] [data to send]", "The data will be sent to the user's IRC client(s)");
|
||||
AddCommand("Server", static_cast<CModCommand::ModCmdFunc>(&CSendRaw_Mod::SendServer),
|
||||
"[user] [data to send]", "The data will be sent to the IRC server the user is connected to");
|
||||
"[user] [network] [data to send]", "The data will be sent to the IRC server the user is connected to");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ public:
|
||||
void PutShell(const CString& sMsg) {
|
||||
CString sPath = m_sPath.Replace_n(" ", "_");
|
||||
CString sSource = ":" + GetModNick() + "!shell@" + sPath;
|
||||
CString sLine = sSource + " PRIVMSG " + m_pUser->GetCurNick() + " :" + sMsg;
|
||||
CString sLine = sSource + " PRIVMSG " + m_pClient->GetNick() + " :" + sMsg;
|
||||
PutUser(sLine);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "FileUtils.h"
|
||||
#include "IRCSock.h"
|
||||
#include "User.h"
|
||||
#include "IRCNetwork.h"
|
||||
#include "znc.h"
|
||||
|
||||
class CIdentFileModule : public CModule {
|
||||
@@ -141,7 +142,7 @@ public:
|
||||
}
|
||||
|
||||
virtual void OnIRCConnected() {
|
||||
if (m_pIRCSock == m_pUser->GetIRCSock()) {
|
||||
if (m_pIRCSock == m_pNetwork->GetIRCSock()) {
|
||||
m_pIRCSock = NULL;
|
||||
ReleaseISpoof();
|
||||
}
|
||||
@@ -155,7 +156,7 @@ public:
|
||||
}
|
||||
|
||||
virtual void OnIRCDisconnected() {
|
||||
if (m_pIRCSock == m_pUser->GetIRCSock()) {
|
||||
if (m_pIRCSock == m_pNetwork->GetIRCSock()) {
|
||||
m_pIRCSock = NULL;
|
||||
ReleaseISpoof();
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include "Modules.h"
|
||||
#include "User.h"
|
||||
#include "IRCNetwork.h"
|
||||
#include "IRCSock.h"
|
||||
|
||||
class CKeepNickMod;
|
||||
@@ -33,7 +34,7 @@ public:
|
||||
m_pTimer = NULL;
|
||||
|
||||
// Check if we need to start the timer
|
||||
if (m_pUser->IsIRCConnected())
|
||||
if (m_pNetwork->IsIRCConnected())
|
||||
OnIRCConnected();
|
||||
|
||||
return true;
|
||||
@@ -44,7 +45,7 @@ public:
|
||||
// No timer means we are turned off
|
||||
return;
|
||||
|
||||
CIRCSock* pIRCSock = GetUser()->GetIRCSock();
|
||||
CIRCSock* pIRCSock = m_pNetwork->GetIRCSock();
|
||||
|
||||
if (!pIRCSock)
|
||||
return;
|
||||
@@ -58,7 +59,7 @@ public:
|
||||
|
||||
CString GetNick() {
|
||||
CString sConfNick = m_pUser->GetNick();
|
||||
CIRCSock* pIRCSock = GetUser()->GetIRCSock();
|
||||
CIRCSock* pIRCSock = m_pNetwork->GetIRCSock();
|
||||
|
||||
if (pIRCSock)
|
||||
sConfNick = sConfNick.Left(pIRCSock->GetMaxNickLen());
|
||||
@@ -67,7 +68,7 @@ public:
|
||||
}
|
||||
|
||||
void OnNick(const CNick& Nick, const CString& sNewNick, const vector<CChan*>& vChans) {
|
||||
if (sNewNick == GetUser()->GetIRCSock()->GetNick()) {
|
||||
if (sNewNick == m_pNetwork->GetIRCSock()->GetNick()) {
|
||||
// We are changing our own nick
|
||||
if (Nick.GetNick().Equals(GetNick())) {
|
||||
// We are changing our nick away from the conf setting.
|
||||
@@ -101,7 +102,7 @@ public:
|
||||
}
|
||||
|
||||
void OnIRCConnected() {
|
||||
if (!GetUser()->GetIRCSock()->GetNick().Equals(GetNick())) {
|
||||
if (!m_pNetwork->GetIRCSock()->GetNick().Equals(GetNick())) {
|
||||
// We don't have the nick we want, try to get it
|
||||
Enable();
|
||||
}
|
||||
@@ -126,7 +127,7 @@ public:
|
||||
|
||||
virtual EModRet OnUserRaw(CString& sLine) {
|
||||
// We dont care if we are not connected to IRC
|
||||
if (!m_pUser->IsIRCConnected())
|
||||
if (!m_pNetwork->IsIRCConnected())
|
||||
return CONTINUE;
|
||||
|
||||
// We are trying to get the config nick and this is a /nick?
|
||||
@@ -145,7 +146,7 @@ public:
|
||||
|
||||
// Indeed trying to change to this nick, generate a 433 for it.
|
||||
// This way we can *always* block incoming 433s from the server.
|
||||
PutUser(":" + m_pUser->GetIRCServer() + " 433 " + m_pUser->GetIRCNick().GetNick()
|
||||
PutUser(":" + m_pNetwork->GetIRCServer() + " 433 " + m_pNetwork->GetIRCNick().GetNick()
|
||||
+ " " + sNick + " :ZNC is already trying to get this nickname");
|
||||
return CONTINUE;
|
||||
}
|
||||
@@ -196,4 +197,4 @@ template<> void TModInfo<CKeepNickMod>(CModInfo& Info) {
|
||||
Info.SetWikiPage("keepnick");
|
||||
}
|
||||
|
||||
MODULEDEFS(CKeepNickMod, "Keep trying for your primary nick")
|
||||
NETWORKMODULEDEFS(CKeepNickMod, "Keep trying for your primary nick")
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
#include "Chan.h"
|
||||
#include "User.h"
|
||||
#include "IRCNetwork.h"
|
||||
|
||||
class CRejoinJob: public CTimer {
|
||||
public:
|
||||
@@ -26,8 +26,8 @@ public:
|
||||
|
||||
protected:
|
||||
virtual void RunJob() {
|
||||
CUser* user = m_pModule->GetUser();
|
||||
CChan* pChan = user->FindChan(GetName().Token(1, true));
|
||||
CIRCNetwork* pNetwork = m_pModule->GetNetwork();
|
||||
CChan* pChan = pNetwork->FindChan(GetName().Token(1, true));
|
||||
|
||||
if (pChan) {
|
||||
pChan->Enable();
|
||||
@@ -96,7 +96,7 @@ public:
|
||||
}
|
||||
|
||||
virtual void OnKick(const CNick& OpNick, const CString& sKickedNick, CChan& pChan, const CString& sMessage) {
|
||||
if (m_pUser->GetCurNick().Equals(sKickedNick)) {
|
||||
if (m_pNetwork->GetCurNick().Equals(sKickedNick)) {
|
||||
if (!delay) {
|
||||
PutIRC("JOIN " + pChan.GetName() + " " + pChan.GetKey());
|
||||
pChan.Enable();
|
||||
@@ -112,4 +112,4 @@ template<> void TModInfo<CRejoinMod>(CModInfo& Info) {
|
||||
Info.SetWikiPage("kickrejoin");
|
||||
}
|
||||
|
||||
MODULEDEFS(CRejoinMod, "Autorejoin on kick")
|
||||
NETWORKMODULEDEFS(CRejoinMod, "Autorejoin on kick")
|
||||
|
||||
@@ -107,25 +107,6 @@ public:
|
||||
Row["Username"] = pUser->GetUserName();
|
||||
Row["IsSelf"] = CString(pUser == WebSock.GetSession()->GetUser());
|
||||
Row["LastSeen"] = FormatLastSeen(pUser, "never");
|
||||
|
||||
Row["Info"] = CString(pUser->GetClients().size()) +
|
||||
" client" + CString(pUser->GetClients().size() == 1 ? "" : "s");
|
||||
if (!pUser->IsIRCConnected()) {
|
||||
Row["Info"] += ", not connected to IRC";
|
||||
} else {
|
||||
unsigned int uChans = 0;
|
||||
const vector<CChan*>& vChans = pUser->GetChans();
|
||||
for (unsigned int a = 0; a < vChans.size(); ++a) {
|
||||
if (vChans[a]->IsOn()) ++uChans;
|
||||
}
|
||||
unsigned int n = uChans;
|
||||
Row["Info"] += ", joined to " + CString(uChans);
|
||||
if(uChans != vChans.size()) {
|
||||
Row["Info"] += " out of " + CString(vChans.size()) + " configured";
|
||||
n = vChans.size();
|
||||
}
|
||||
Row["Info"] += " channel" + CString(n == 1 ? "" : "s");
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -17,9 +17,9 @@ class CPerlModule : public CModule {
|
||||
CString m_sPerlID;
|
||||
VWebSubPages* _GetSubPages();
|
||||
public:
|
||||
CPerlModule(CUser* pUser, const CString& sModName, const CString& sDataPath,
|
||||
CPerlModule(CUser* pUser, CIRCNetwork* pNetwork, const CString& sModName, const CString& sDataPath,
|
||||
const CString& sPerlID)
|
||||
: CModule(NULL, pUser, sModName, sDataPath) {
|
||||
: CModule(NULL, pUser, pNetwork, sModName, sDataPath) {
|
||||
m_sPerlID = sPerlID;
|
||||
}
|
||||
CString GetPerlID() { return m_sPerlID; }
|
||||
|
||||
@@ -80,4 +80,4 @@ template<> void TModInfo<CNickServ>(CModInfo& Info) {
|
||||
Info.SetWikiPage("nickserv");
|
||||
}
|
||||
|
||||
MODULEDEFS(CNickServ, "Auths you with NickServ")
|
||||
NETWORKMODULEDEFS(CNickServ, "Auths you with NickServ")
|
||||
|
||||
@@ -655,7 +655,7 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
const vector<CClient*>& vClients = pUser->GetClients();
|
||||
const vector<CClient*>& vClients = pUser->GetAllClients();
|
||||
vector<CClient*>::const_iterator it;
|
||||
for (it = vClients.begin(); it != vClients.end(); ++it) {
|
||||
(*it)->PutClient(sPre + (*it)->GetNick() + sPost);
|
||||
|
||||
+6
-5
@@ -8,6 +8,7 @@
|
||||
|
||||
#include "Modules.h"
|
||||
#include "User.h"
|
||||
#include "IRCNetwork.h"
|
||||
#include "IRCSock.h"
|
||||
#include "Nick.h"
|
||||
#include "Chan.h"
|
||||
@@ -39,7 +40,7 @@ public:
|
||||
|
||||
if (IsIRCConnected()) {
|
||||
// check for usermode +x if we are already connected
|
||||
set<unsigned char> scUserModes = GetUser()->GetIRCSock()->GetUserModes();
|
||||
set<unsigned char> scUserModes = m_pNetwork->GetIRCSock()->GetUserModes();
|
||||
if (scUserModes.find('x') != scUserModes.end())
|
||||
m_bCloaked = true;
|
||||
|
||||
@@ -254,7 +255,7 @@ private:
|
||||
return;
|
||||
|
||||
PutModule("Cloak: Trying to cloak your hostname, setting +x...");
|
||||
PutIRC("MODE " + GetUser()->GetIRCSock()->GetNick() + " +x");
|
||||
PutIRC("MODE " + m_pNetwork->GetIRCSock()->GetNick() + " +x");
|
||||
}
|
||||
|
||||
void WhoAmI() {
|
||||
@@ -404,12 +405,12 @@ private:
|
||||
|
||||
/* Utility Functions */
|
||||
bool IsIRCConnected() {
|
||||
CIRCSock* pIRCSock = GetUser()->GetIRCSock();
|
||||
CIRCSock* pIRCSock = m_pNetwork->GetIRCSock();
|
||||
return pIRCSock && pIRCSock->IsAuthed();
|
||||
}
|
||||
|
||||
bool IsSelf(const CNick& Nick) {
|
||||
return Nick.GetNick().Equals(m_pUser->GetCurNick());
|
||||
return Nick.GetNick().Equals(m_pNetwork->GetCurNick());
|
||||
}
|
||||
|
||||
bool PackHex(const CString& sHex, CString& sPackedHex) {
|
||||
@@ -487,4 +488,4 @@ template<> void TModInfo<CQModule>(CModInfo& Info) {
|
||||
Info.SetWikiPage("Q");
|
||||
}
|
||||
|
||||
MODULEDEFS(CQModule, "Auths you with QuakeNet's Q bot.")
|
||||
NETWORKMODULEDEFS(CQModule, "Auths you with QuakeNet's Q bot.")
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
#include "znc.h"
|
||||
#include "User.h"
|
||||
#include "IRCNetwork.h"
|
||||
#include "IRCSock.h"
|
||||
|
||||
struct reply {
|
||||
@@ -249,7 +249,7 @@ public:
|
||||
{
|
||||
CString sCmd = sLine.Token(0).AsUpper();
|
||||
|
||||
if (!m_pUser->GetIRCSock())
|
||||
if (!m_pNetwork->GetIRCSock())
|
||||
return CONTINUE;
|
||||
|
||||
if (sCmd.Equals("MODE")) {
|
||||
@@ -334,7 +334,7 @@ private:
|
||||
|
||||
// 353 needs special treatment due to NAMESX and UHNAMES
|
||||
if (bIsRaw353)
|
||||
GetUser()->GetIRCSock()->ForwardRaw353(sLine, m_pDoing);
|
||||
m_pNetwork->GetIRCSock()->ForwardRaw353(sLine, m_pDoing);
|
||||
else
|
||||
m_pDoing->PutClient(sLine);
|
||||
|
||||
@@ -426,4 +426,4 @@ template<> void TModInfo<CRouteRepliesMod>(CModInfo& Info) {
|
||||
Info.SetWikiPage("route_replies");
|
||||
}
|
||||
|
||||
MODULEDEFS(CRouteRepliesMod, "Send replies (e.g. to /who) to the right client only")
|
||||
NETWORKMODULEDEFS(CRouteRepliesMod, "Send replies (e.g. to /who) to the right client only")
|
||||
|
||||
+2
-1
@@ -6,6 +6,7 @@
|
||||
* by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
#include "Client.h"
|
||||
#include "Chan.h"
|
||||
#include "User.h"
|
||||
#include "Modules.h"
|
||||
@@ -183,7 +184,7 @@ public:
|
||||
}
|
||||
|
||||
virtual EModRet OnUserTopic(CString& sTarget, CString& sTopic) {
|
||||
PutModule("* " + m_pUser->GetCurNick() + " changed topic on " + sTarget + " to '" + sTopic + "'");
|
||||
PutModule("* " + m_pClient->GetNick() + " changed topic on " + sTarget + " to '" + sTopic + "'");
|
||||
|
||||
return CONTINUE;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
#include "Chan.h"
|
||||
#include "User.h"
|
||||
#include "IRCNetwork.h"
|
||||
#include "FileUtils.h"
|
||||
#include <sys/stat.h>
|
||||
|
||||
@@ -84,7 +85,7 @@ public:
|
||||
{
|
||||
m_bFirstLoad = true;
|
||||
AddTimer(new CSaveBuffJob(this, 60, 0, "SaveBuff", "Saves the current buffer to disk every 1 minute"));
|
||||
const vector<CChan *>& vChans = m_pUser->GetChans();
|
||||
const vector<CChan *>& vChans = m_pNetwork->GetChans();
|
||||
for (u_int a = 0; a < vChans.size(); a++)
|
||||
{
|
||||
if (!vChans[a]->KeepBuffer())
|
||||
@@ -130,7 +131,7 @@ public:
|
||||
{
|
||||
if (!m_sPassword.empty())
|
||||
{
|
||||
const vector<CChan *>& vChans = m_pUser->GetChans();
|
||||
const vector<CChan *>& vChans = m_pNetwork->GetChans();
|
||||
for (u_int a = 0; a < vChans.size(); a++)
|
||||
{
|
||||
CString sPath = GetPath(vChans[a]->GetName());
|
||||
@@ -246,7 +247,7 @@ public:
|
||||
void AddBuffer(CChan& chan, const CString &sLine)
|
||||
{
|
||||
// If they have keep buffer disabled, only add messages if no client is connected
|
||||
if (!chan.KeepBuffer() && m_pUser->IsUserAttached())
|
||||
if (!chan.KeepBuffer() && m_pNetwork->IsUserAttached())
|
||||
return;
|
||||
chan.AddBuffer(sLine);
|
||||
}
|
||||
@@ -339,5 +340,5 @@ template<> void TModInfo<CSaveBuff>(CModInfo& Info) {
|
||||
Info.SetWikiPage("savebuff");
|
||||
}
|
||||
|
||||
MODULEDEFS(CSaveBuff, "Stores channel buffers to disk, encrypted")
|
||||
NETWORKMODULEDEFS(CSaveBuff, "Stores channel buffers to disk, encrypted")
|
||||
|
||||
|
||||
+4
-3
@@ -13,6 +13,7 @@
|
||||
|
||||
#include "FileUtils.h"
|
||||
#include "User.h"
|
||||
#include "IRCNetwork.h"
|
||||
#include "znc.h"
|
||||
#include <sstream>
|
||||
|
||||
@@ -384,13 +385,13 @@ public:
|
||||
void SendToUser(const CString & sFrom, const CString & sText)
|
||||
{
|
||||
//:*schat!znc@znc.in PRIVMSG Jim :
|
||||
CString sSend = ":" + sFrom + " PRIVMSG " + m_pUser->GetCurNick() + " :" + sText;
|
||||
CString sSend = ":" + sFrom + " PRIVMSG " + m_pNetwork->GetCurNick() + " :" + sText;
|
||||
PutUser(sSend);
|
||||
}
|
||||
|
||||
bool IsAttached()
|
||||
{
|
||||
return(m_pUser->IsUserAttached());
|
||||
return(m_pNetwork->IsUserAttached());
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -468,5 +469,5 @@ template<> void TModInfo<CSChat>(CModInfo& Info) {
|
||||
Info.SetWikiPage("schat");
|
||||
}
|
||||
|
||||
MODULEDEFS(CSChat, "Secure cross platform (:P) chat system")
|
||||
NETWORKMODULEDEFS(CSChat, "Secure cross platform (:P) chat system")
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
#include "Chan.h"
|
||||
#include "User.h"
|
||||
#include "IRCNetwork.h"
|
||||
|
||||
class CStickyChan : public CModule
|
||||
{
|
||||
@@ -25,7 +25,7 @@ public:
|
||||
{
|
||||
if (sChannel.Equals(it->first))
|
||||
{
|
||||
CChan* pChan = m_pUser->FindChan(sChannel);
|
||||
CChan* pChan = m_pNetwork->FindChan(sChannel);
|
||||
|
||||
if (pChan)
|
||||
{
|
||||
@@ -76,17 +76,17 @@ public:
|
||||
|
||||
virtual void RunJob()
|
||||
{
|
||||
if (!m_pUser->GetIRCSock())
|
||||
if (!m_pNetwork->GetIRCSock())
|
||||
return;
|
||||
|
||||
for (MCString::iterator it = BeginNV(); it != EndNV(); ++it)
|
||||
{
|
||||
CChan *pChan = m_pUser->FindChan(it->first);
|
||||
CChan *pChan = m_pNetwork->FindChan(it->first);
|
||||
if (!pChan) {
|
||||
pChan = new CChan(it->first, m_pUser, true);
|
||||
pChan = new CChan(it->first, m_pNetwork, true);
|
||||
if (!it->second.empty())
|
||||
pChan->SetKey(it->second);
|
||||
if (!m_pUser->AddChan(pChan)) {
|
||||
if (!m_pNetwork->AddChan(pChan)) {
|
||||
/* AddChan() deleted that channel */
|
||||
PutModule("Could not join [" + it->first
|
||||
+ "] (# prefix missing?)");
|
||||
@@ -107,7 +107,7 @@ public:
|
||||
if (sPageName == "index") {
|
||||
bool bSubmitted = (WebSock.GetParam("submitted").ToInt() != 0);
|
||||
|
||||
const vector<CChan*>& Channels = m_pUser->GetChans();
|
||||
const vector<CChan*>& Channels = m_pNetwork->GetChans();
|
||||
for (unsigned int c = 0; c < Channels.size(); c++) {
|
||||
const CString sChan = Channels[c]->GetName();
|
||||
bool bStick = FindNV(sChan) != EndNV();
|
||||
|
||||
+6
-5
@@ -8,6 +8,7 @@
|
||||
|
||||
#include "Chan.h"
|
||||
#include "User.h"
|
||||
#include "IRCNetwork.h"
|
||||
#include <list>
|
||||
|
||||
using std::list;
|
||||
@@ -167,7 +168,7 @@ public:
|
||||
|
||||
virtual void OnClientLogin() {
|
||||
CString sBufLine;
|
||||
while (m_Buffer.GetNextLine(m_pUser->GetCurNick(), sBufLine)) {
|
||||
while (m_Buffer.GetNextLine(m_pNetwork->GetCurNick(), sBufLine)) {
|
||||
PutUser(sBufLine);
|
||||
}
|
||||
|
||||
@@ -287,9 +288,9 @@ private:
|
||||
CWatchEntry& WatchEntry = *it;
|
||||
|
||||
if (WatchEntry.IsMatch(Nick, sMessage, sSource, m_pUser)) {
|
||||
if (m_pUser->IsUserAttached()) {
|
||||
m_pUser->PutUser(":" + WatchEntry.GetTarget() + "!watch@znc.in PRIVMSG " +
|
||||
m_pUser->GetCurNick() + " :" + sMessage);
|
||||
if (m_pNetwork->IsUserAttached()) {
|
||||
m_pNetwork->PutUser(":" + WatchEntry.GetTarget() + "!watch@znc.in PRIVMSG " +
|
||||
m_pNetwork->GetCurNick() + " :" + sMessage);
|
||||
} else {
|
||||
m_Buffer.AddLine(":" + WatchEntry.GetTarget() + "!watch@znc.in PRIVMSG ",
|
||||
" :" + m_pUser->AddTimestamp(sMessage));
|
||||
@@ -554,4 +555,4 @@ template<> void TModInfo<CWatcherMod>(CModInfo& Info) {
|
||||
Info.SetWikiPage("watch");
|
||||
}
|
||||
|
||||
MODULEDEFS(CWatcherMod, "Copy activity from a specific user into a separate window")
|
||||
NETWORKMODULEDEFS(CWatcherMod, "Copy activity from a specific user into a separate window")
|
||||
|
||||
Reference in New Issue
Block a user