mirror of
https://github.com/znc/znc.git
synced 2026-08-06 17:03:14 +02:00
sync from my branch rev 983 and 993:
- module api change, if module fails to load it can give back an useful error message - give a message when client doesnt supply a password when connecting - some minor cleanup git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@803 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
@@ -83,6 +83,8 @@ void CClient::ReadLine(const CString& sData) {
|
||||
|
||||
if ((m_bGotPass) && (m_bGotNick)) {
|
||||
AuthUser();
|
||||
} else if (!m_bGotPass) {
|
||||
PutClient(":irc.znc.com NOTICE AUTH :*** You need to send your password. Try /quote PASS <username>:<password>");
|
||||
}
|
||||
|
||||
return; // Don't forward this msg. ZNC has already registered us.
|
||||
@@ -428,6 +430,7 @@ void CClient::ReadLine(const CString& sData) {
|
||||
if (sCTCP.Token(0).CaseCmp("ACTION") == 0) {
|
||||
CString sMessage = sCTCP.Token(1, true);
|
||||
MODULECALL(OnUserAction(sTarget, sMessage), m_pUser, this, return);
|
||||
sCTCP = "ACTION " + sMessage;
|
||||
|
||||
if (pChan && pChan->KeepBuffer()) {
|
||||
pChan->AddBuffer(":" + GetNickMask() + " PRIVMSG " + sTarget + " :\001ACTION " + m_pUser->AddTimestamp(sMessage) + "\001");
|
||||
|
||||
+7
-4
@@ -469,7 +469,7 @@ void CModule::ListSockets() {
|
||||
const CString& CModule::GetModName() const { return m_sModName; }
|
||||
CString CModule::GetModNick() const { return ((m_pUser) ? m_pUser->GetStatusPrefix() : "*") + m_sModName; }
|
||||
|
||||
bool CModule::OnLoad(const CString& sArgs) { return true; }
|
||||
bool CModule::OnLoad(const CString& sArgs, CString& sErrorMsg) { sErrorMsg = ""; return true; }
|
||||
bool CModule::OnBoot() { return true; }
|
||||
void CModule::OnIRCDisconnected() {}
|
||||
void CModule::OnIRCConnected() {}
|
||||
@@ -771,9 +771,12 @@ bool CModules::LoadModule(const CString& sModule, const CString& sArgs, CUser* p
|
||||
pModule->SetDescription(GetDesc());
|
||||
push_back(pModule);
|
||||
|
||||
if (!pModule->OnLoad(sArgs)) {
|
||||
UnloadModule(sModule, sRetMsg);
|
||||
sRetMsg = "Module [" + sModule + "] aborted.";
|
||||
if (!pModule->OnLoad(sArgs, sRetMsg)) {
|
||||
UnloadModule(sModule, sModPath);
|
||||
if (!sRetMsg.empty())
|
||||
sRetMsg = "Module [" + sModule + "] aborted: " + sRetMsg;
|
||||
else
|
||||
sRetMsg = "Module [" + sModule + "] aborted.";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -200,7 +200,7 @@ public:
|
||||
void SetClient(CClient* pClient);
|
||||
void Unload();
|
||||
|
||||
virtual bool OnLoad(const CString& sArgs);
|
||||
virtual bool OnLoad(const CString& sArgsi, CString& sErrorMsg);
|
||||
virtual bool OnBoot();
|
||||
virtual void OnIRCDisconnected();
|
||||
virtual void OnIRCConnected();
|
||||
|
||||
@@ -13,7 +13,7 @@ public:
|
||||
virtual ~CChanAttach() {
|
||||
}
|
||||
|
||||
virtual bool OnLoad(const CString& sArgs) {
|
||||
virtual bool OnLoad(const CString& sArgs, CString& sErrorMsg) {
|
||||
unsigned int a = 0;
|
||||
CString sChan = sArgs.Token(a++);
|
||||
|
||||
|
||||
+1
-1
@@ -126,7 +126,7 @@ class CAutoOpMod : public CModule {
|
||||
public:
|
||||
MODCONSTRUCTOR(CAutoOpMod) {}
|
||||
|
||||
virtual bool OnLoad(const CString& sArgs) {
|
||||
virtual bool OnLoad(const CString& sArgs, CString& sErrorMsg) {
|
||||
AddTimer(new CAutoOpTimer(this));
|
||||
|
||||
// Load the users
|
||||
|
||||
+1
-1
@@ -127,7 +127,7 @@ public:
|
||||
SaveBufferToDisk();
|
||||
}
|
||||
|
||||
virtual bool OnLoad(const CString& sArgs)
|
||||
virtual bool OnLoad(const CString& sArgs, CString& sErrorMsg)
|
||||
{
|
||||
CString sMyArgs = sArgs;
|
||||
if (sMyArgs.Token(0) == "-notimer")
|
||||
|
||||
@@ -45,7 +45,7 @@ class CAwayNickMod : public CModule {
|
||||
public:
|
||||
MODCONSTRUCTOR(CAwayNickMod) {}
|
||||
|
||||
virtual bool OnLoad(const CString& sArgs) {
|
||||
virtual bool OnLoad(const CString& sArgs, CString& sErrorMsg) {
|
||||
m_sFormat = sArgs;
|
||||
|
||||
if (m_sFormat.empty()) {
|
||||
|
||||
@@ -13,10 +13,6 @@ public:
|
||||
m_bWriteConf = false;
|
||||
}
|
||||
|
||||
virtual bool OnLoad(const CString& sArgs) {
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual ~CChanSaverMod() {
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -93,7 +93,7 @@ public:
|
||||
m_pManager->DelSockByAddr( vSocks[a] );
|
||||
}
|
||||
|
||||
virtual bool OnLoad(const CString & sArgs) {
|
||||
virtual bool OnLoad(const CString & sArgs, CString& sErrorMsg) {
|
||||
m_sMailPath = sArgs;
|
||||
|
||||
StartParser();
|
||||
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual bool OnLoad(const CString& sArgs) {
|
||||
virtual bool OnLoad(const CString& sArgs, CString& sErrorMsg) {
|
||||
if (sArgs.Trim_n().empty()) {
|
||||
return true; // use defaults
|
||||
}
|
||||
@@ -152,4 +152,4 @@ void CIMAPSock::ReadLine(const CString& sLine) {
|
||||
}
|
||||
}
|
||||
|
||||
GLOBALMODULEDEFS(CIMAPAuthMod, "Allow users to authenticate via imap");
|
||||
GLOBALMODULEDEFS(CIMAPAuthMod, "Allow users to authenticate via imap")
|
||||
|
||||
+2
-2
@@ -287,7 +287,7 @@ public:
|
||||
}
|
||||
void UnSetUser() { m_pUser = NULL; }
|
||||
|
||||
virtual bool OnLoad( const CString & sArgs );
|
||||
virtual bool OnLoad( const CString & sArgs, CString & sErrorMsg );
|
||||
virtual void OnUserAttached() { CBNone( "OnUserAttached" ); }
|
||||
virtual void OnUserDetached() { CBNone( "OnUserDetached" ); }
|
||||
virtual void OnIRCDisconnected() { CBNone( "OnIRCDisconnected" ); }
|
||||
@@ -968,7 +968,7 @@ CModPerl::EModRet CModPerl::CallBack( const PString & sHookName, const VPString
|
||||
// special case this, required for perl modules that are dynamic
|
||||
EXTERN_C void boot_DynaLoader (pTHX_ CV* cv);
|
||||
|
||||
bool CModPerl::OnLoad( const CString & sArgs )
|
||||
bool CModPerl::OnLoad( const CString & sArgs, CString & sErrorMsg )
|
||||
{
|
||||
m_pPerl = perl_alloc();
|
||||
perl_construct( m_pPerl );
|
||||
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual bool OnLoad(const CString& sArgs) {
|
||||
virtual bool OnLoad(const CString& sArgs, CString& sErrorMsg) {
|
||||
const map<CString, CUser*>& msUsers = CZNC::Get().GetUserMap();
|
||||
|
||||
for (map<CString, CUser*>::const_iterator it = msUsers.begin(); it != msUsers.end(); it++) {
|
||||
@@ -587,4 +587,4 @@ private:
|
||||
set<CString> m_ssDefaultChans;
|
||||
};
|
||||
|
||||
GLOBALMODULEDEFS(CPartylineMod, "Internal channels and queries for users connected to znc");
|
||||
GLOBALMODULEDEFS(CPartylineMod, "Internal channels and queries for users connected to znc")
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
virtual bool OnLoad(const CString& sArgs)
|
||||
virtual bool OnLoad(const CString& sArgs, CString& sErrorMsg)
|
||||
{
|
||||
GetNV("Perform").Split("\n", m_vPerform, false);
|
||||
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ class CSampleMod : public CModule {
|
||||
public:
|
||||
MODCONSTRUCTOR(CSampleMod) {}
|
||||
|
||||
virtual bool OnLoad(const CString& sArgs) {
|
||||
virtual bool OnLoad(const CString& sArgs, CString& sErrorMsg) {
|
||||
PutModule("I'm being loaded with the arguments: [" + sArgs + "]");
|
||||
//AddTimer(new CSampleTimer(this, 300, 0, "Sample", "Sample timer for sample things."));
|
||||
//AddTimer(new CSampleTimer(this, 5, 20, "Another", "Another sample timer."));
|
||||
|
||||
@@ -154,7 +154,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
virtual bool OnLoad(const CString& sArgs)
|
||||
virtual bool OnLoad(const CString& sArgs, CString& sErrorMsg)
|
||||
{
|
||||
if (!sArgs.empty())
|
||||
{
|
||||
|
||||
+2
-2
@@ -201,7 +201,7 @@ public:
|
||||
MODCONSTRUCTOR(CSChat) {}
|
||||
virtual ~CSChat() { CleanSocks(); }
|
||||
|
||||
virtual bool OnLoad( const CString & sArgs )
|
||||
virtual bool OnLoad( const CString & sArgs, CString & sErrorMsg )
|
||||
{
|
||||
m_sPemFile = sArgs;
|
||||
|
||||
@@ -211,7 +211,7 @@ public:
|
||||
}
|
||||
|
||||
if (!CFile::Exists(m_sPemFile)) {
|
||||
PutModule("Unable to load pem file [" + m_sPemFile + "]");
|
||||
sErrorMsg = "Unable to load pem file [" + m_sPemFile + "]";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
virtual bool OnLoad( const CString& sArgs );
|
||||
virtual bool OnLoad( const CString& sArgs, CString& sErrorMsg );
|
||||
|
||||
virtual EModRet OnUserPart( CString& sChannel, CString& sMessage )
|
||||
{
|
||||
@@ -88,7 +88,7 @@ static void RunTimer( CModule * pModule, CFPTimer *pTimer )
|
||||
((CStickyChan *)pModule)->RunJob();
|
||||
}
|
||||
|
||||
bool CStickyChan::OnLoad(const CString& sArgs)
|
||||
bool CStickyChan::OnLoad(const CString& sArgs, CString& sErrorMsg)
|
||||
{
|
||||
AddTimer( RunTimer, "StickyChanTimer", 15 );
|
||||
return( true );
|
||||
|
||||
@@ -155,10 +155,6 @@ public:
|
||||
m_Buffer.SetLineCount(500);
|
||||
}
|
||||
|
||||
virtual bool OnLoad(const CString& sArgs) {
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual ~CWatcherMod() {
|
||||
}
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual bool OnLoad(const CString& sArgStr) {
|
||||
virtual bool OnLoad(const CString& sArgStr, CString& sErrorMsg) {
|
||||
bool bSSL = false;
|
||||
bool bIPv6 = false;
|
||||
CString sArgs(sArgStr);
|
||||
@@ -165,8 +165,7 @@ public:
|
||||
|
||||
bool b = m_pManager->ListenHost(m_uPort, "WebAdmin::Listener", m_sListenHost, bSSL, SOMAXCONN, pListenSock, 0, bIPv6);
|
||||
if (!b) {
|
||||
printf("\n"); // dont mix it up with the 'loading module' message
|
||||
CUtils::PrintMessage("Error: " + CString(strerror(errno)), true);
|
||||
sErrorMsg = "Could not bind to port " + CString(m_uPort) + ": " + CString(strerror(errno));
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user