mirror of
https://github.com/znc/znc.git
synced 2026-07-05 01:11:53 +02:00
Improve the handling of module load messages
Instead of doing ugly stuff to shorten the "Loaded Module [foo]" message, we now just always generate the shorter version of that message. The code paths which didn't do this shortening now prepend that message themselves. The result is that every message looks the same as it did before, but the code for generating these is a little nicer. Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
+2
-4
@@ -731,10 +731,8 @@ void CClient::UserCommand(CString& sLine) {
|
||||
b = m_pUser->GetModules().LoadModule(sMod, sArgs, m_pUser, sModRet);
|
||||
}
|
||||
|
||||
if (!b) {
|
||||
PutStatus(sModRet);
|
||||
return;
|
||||
}
|
||||
if (b)
|
||||
sModRet = "Loaded module [" + sMod + "] " + sModRet;
|
||||
|
||||
PutStatus(sModRet);
|
||||
return;
|
||||
|
||||
+2
-3
@@ -886,10 +886,9 @@ bool CModules::LoadModule(const CString& sModule, const CString& sArgs, CUser* p
|
||||
}
|
||||
|
||||
if (!sRetMsg.empty()) {
|
||||
sRetMsg = "Loaded module [" + sModule + "] [" + sRetMsg + "] [" + sModPath + "]";
|
||||
} else {
|
||||
sRetMsg = "Loaded module [" + sModule + "] [" + sModPath + "]";
|
||||
sRetMsg += "[" + sRetMsg + "] ";
|
||||
}
|
||||
sRetMsg += "[" + sModPath + "]";
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -307,11 +307,6 @@ bool CUser::ParseConfig(CConfig* pConfig, CString& sError) {
|
||||
|
||||
bool bModRet = GetModules().LoadModule(sModName, sArgs, this, sModRet);
|
||||
|
||||
// If the module was loaded, sModRet contains
|
||||
// "Loaded Module [name] ..." and we strip away this beginning.
|
||||
if (bModRet)
|
||||
sModRet = sModRet.Token(1, true, sModName + "] ");
|
||||
|
||||
CUtils::PrintStatus(bModRet, sModRet);
|
||||
if (!bModRet) {
|
||||
sError = sModRet;
|
||||
|
||||
@@ -139,9 +139,9 @@ sub LoadModule {
|
||||
return ($ZNC::Perl_LoadError, "Module [$modname] aborted.");
|
||||
}
|
||||
if ($x) {
|
||||
return ($ZNC::Perl_Loaded, "Loaded module [$modname] [$x] [$modpath]");
|
||||
return ($ZNC::Perl_Loaded, "[$x] [$modpath]");
|
||||
}
|
||||
return ($ZNC::Perl_Loaded, "Loaded module [$modname] [$modpath]")
|
||||
return ($ZNC::Perl_Loaded, "[$modpath]")
|
||||
}
|
||||
|
||||
sub GetModInfo {
|
||||
|
||||
@@ -288,9 +288,9 @@ def load_module(modname, args, user, retmsg, modpython):
|
||||
|
||||
if loaded:
|
||||
if retmsg.s == '':
|
||||
retmsg.s = "Loaded module [{0}] [{1}]".format(modname, pymodule.__file__)
|
||||
retmsg.s = "[{0}]".format(pymodule.__file__)
|
||||
else:
|
||||
retmsg.s = "Loaded module [{0}] [{2}] [{1}]".format(modname, pymodule.__file__, retmsg.s)
|
||||
retmsg.s = "[{1}] [{0}]".format(pymodule.__file__, retmsg.s)
|
||||
return 2
|
||||
print(retmsg.s)
|
||||
|
||||
|
||||
@@ -1065,11 +1065,6 @@ bool CZNC::DoRehash(CString& sError)
|
||||
|
||||
bool bModRet = GetModules().LoadModule(sModName, sArgs, NULL, sModRet);
|
||||
|
||||
// If the module was loaded, sModRet contains
|
||||
// "Loaded Module [name] ..." and we strip away this beginning.
|
||||
if (bModRet)
|
||||
sModRet = sModRet.Token(1, true, sModName + "] ");
|
||||
|
||||
CUtils::PrintStatus(bModRet, sModRet);
|
||||
if (!bModRet) {
|
||||
sError = sModRet;
|
||||
@@ -1080,11 +1075,6 @@ bool CZNC::DoRehash(CString& sError)
|
||||
|
||||
bool bModRet = GetModules().ReloadModule(sModName, sArgs, NULL, sModRet);
|
||||
|
||||
// If the module was loaded, sModRet contains
|
||||
// "Loaded Module [name] ..." and we strip away this beginning.
|
||||
if (bModRet)
|
||||
sModRet = sModRet.Token(1, true, sModName + "] ");
|
||||
|
||||
CUtils::PrintStatus(bModRet, sModRet);
|
||||
if (!bModRet) {
|
||||
sError = sModRet;
|
||||
@@ -1107,10 +1097,6 @@ bool CZNC::DoRehash(CString& sError)
|
||||
CString sModRet;
|
||||
bool bModRet = GetModules().LoadModule("identfile", "", NULL, sModRet);
|
||||
|
||||
if (bModRet) {
|
||||
sModRet = sModRet.Token(1, true, "identfile] ");
|
||||
}
|
||||
|
||||
CUtils::PrintStatus(bModRet, sModRet);
|
||||
if (!bModRet) {
|
||||
sError = sModRet;
|
||||
|
||||
Reference in New Issue
Block a user