Add options for log module to hide joins, quits and nick changes.

Fix #601
Close #613
This commit is contained in:
Toon Schoenmakers
2014-07-28 22:27:12 +02:00
committed by Alexey Sokolov
parent 1a574f95ae
commit 03e3920ced
2 changed files with 23 additions and 5 deletions

View File

@@ -51,6 +51,16 @@ private:
};
class CLogMod: public CModule {
void Set(const CString& sLine) {
const CString sVar = sLine.Token(1).AsLower();
bool b = sLine.Token(2).ToBool();
if (sVar == "joins" || sVar == "quits" || sVar == "nickchanges") {
SetNV(sVar, CString(b));
PutModule("Set " + sVar + " to " + CString(b));
} else
PutModule(sVar + " is invalid.");
}
public:
MODCONSTRUCTOR(CLogMod)
{
@@ -62,6 +72,8 @@ public:
"", "Clear all logging rules");
AddCommand("ListRules", static_cast<CModCommand::ModCmdFunc>(&CLogMod::ListRulesCmd),
"", "List all logging rules");
AddCommand("Set", static_cast<CModCommand::ModCmdFunc>(&CLogMod::Set),
"boolean", "Set one of the following booleans, joins, quits, nickchanges");
}
void SetRulesCmd(const CString& sLine);
@@ -368,13 +380,16 @@ void CLogMod::OnKick(const CNick& OpNick, const CString& sKickedNick, CChan& Cha
void CLogMod::OnQuit(const CNick& Nick, const CString& sMessage, const vector<CChan*>& vChans)
{
for (CChan* pChan : vChans)
PutLog("*** Quits: " + Nick.GetNick() + " (" + Nick.GetIdent() + "@" + Nick.GetHost() + ") (" + sMessage + ")", *pChan);
if (!HasNV("quits") || GetNV("quits").ToBool()) {
for (CChan* pChan : vChans)
PutLog("*** Quits: " + Nick.GetNick() + " (" + Nick.GetIdent() + "@" + Nick.GetHost() + ") (" + sMessage + ")", *pChan);
}
}
void CLogMod::OnJoin(const CNick& Nick, CChan& Channel)
{
PutLog("*** Joins: " + Nick.GetNick() + " (" + Nick.GetIdent() + "@" + Nick.GetHost() + ")", Channel);
if (!HasNV("joins") || GetNV("joins").ToBool())
PutLog("*** Joins: " + Nick.GetNick() + " (" + Nick.GetIdent() + "@" + Nick.GetHost() + ")", Channel);
}
void CLogMod::OnPart(const CNick& Nick, CChan& Channel, const CString& sMessage)
@@ -384,8 +399,10 @@ void CLogMod::OnPart(const CNick& Nick, CChan& Channel, const CString& sMessage)
void CLogMod::OnNick(const CNick& OldNick, const CString& sNewNick, const vector<CChan*>& vChans)
{
for (CChan* pChan : vChans)
PutLog("*** " + OldNick.GetNick() + " is now known as " + sNewNick, *pChan);
if (!HasNV("nickchanges") || GetNV("nickchanges").ToBool()) {
for (CChan* pChan : vChans)
PutLog("*** " + OldNick.GetNick() + " is now known as " + sNewNick, *pChan);
}
}
CModule::EModRet CLogMod::OnTopic(CNick& Nick, CChan& Channel, CString& sTopic)