From 47b815ae5b8a8caf04e67597524afe7a51e88b9c Mon Sep 17 00:00:00 2001 From: Peter Ajamian Date: Wed, 9 Aug 2023 19:13:54 +1200 Subject: [PATCH 1/3] Add account to joins for the log module. This commit adds the account name for identified users to "Joins" lines in logs generated by the log module. It can get the account name from either the account tag (if the account-tag capability is requested) or the extended-join info (if the extended-join capability is requested). The current version of ZNC requests both, but this feature will still work if the IRC server only supports one or the other. --- modules/log.cpp | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/modules/log.cpp b/modules/log.cpp index 2099d14e..3ad6db31 100644 --- a/modules/log.cpp +++ b/modules/log.cpp @@ -99,7 +99,7 @@ class CLogMod : public CModule { const CString& sMessage) override; void OnQuit(const CNick& Nick, const CString& sMessage, const vector& vChans) override; - void OnJoin(const CNick& Nick, CChan& Channel) override; + void OnJoinMessage(CJoinMessage& Message) override; void OnPart(const CNick& Nick, CChan& Channel, const CString& sMessage) override; void OnNick(const CNick& OldNick, const CString& sNewNick, @@ -457,12 +457,26 @@ CModule::EModRet CLogMod::OnSendToIRCMessage(CMessage& Message) { return CONTINUE; } -void CLogMod::OnJoin(const CNick& Nick, CChan& Channel) { - if (NeedJoins()) { - PutLog("*** Joins: " + Nick.GetNick() + " (" + Nick.GetIdent() + "@" + - Nick.GetHost() + ")", - Channel); +void CLogMod::OnJoinMessage(CJoinMessage& Message) { + if (!NeedJoins()) + return; + + const CNick& Nick = Message.GetNick(); + CChan& Channel = *Message.GetChan(); + CString Account = Message.GetTag("account"); + const char* s = " "; + + if (Account.empty()) + Account = Message.GetParam(1); + + if (Account.empty() || Account == "*") { + Account = ""; + s = ""; } + + PutLog("*** Joins: " + Nick.GetNick() + " (" + Nick.GetIdent() + "@" + + Nick.GetHost() + ")" + s + Account, + Channel); } void CLogMod::OnPart(const CNick& Nick, CChan& Channel, From 0a0ce543fa9605209b2438cd2ff5a891f7db250e Mon Sep 17 00:00:00 2001 From: Peter Ajamian Date: Sat, 12 Aug 2023 21:55:09 +1200 Subject: [PATCH 2/3] sAccount for consistency All CString variables should start with the letter s. --- modules/log.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/log.cpp b/modules/log.cpp index 3ad6db31..f81f1e7e 100644 --- a/modules/log.cpp +++ b/modules/log.cpp @@ -463,19 +463,19 @@ void CLogMod::OnJoinMessage(CJoinMessage& Message) { const CNick& Nick = Message.GetNick(); CChan& Channel = *Message.GetChan(); - CString Account = Message.GetTag("account"); + CString sAccount = Message.GetTag("account"); const char* s = " "; - if (Account.empty()) - Account = Message.GetParam(1); + if (sAccount.empty()) + sAccount = Message.GetParam(1); - if (Account.empty() || Account == "*") { - Account = ""; + if (sAccount.empty() || sAccount == "*") { + sAccount = ""; s = ""; } PutLog("*** Joins: " + Nick.GetNick() + " (" + Nick.GetIdent() + "@" + - Nick.GetHost() + ")" + s + Account, + Nick.GetHost() + ")" + s + sAccount, Channel); } From 1240ddc6934b909945556d7da71fa702c97dd3ad Mon Sep 17 00:00:00 2001 From: Peter Ajamian Date: Sun, 13 Aug 2023 22:29:48 +1200 Subject: [PATCH 3/3] Add TODO entry to move account logic to a separate method. --- modules/log.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/log.cpp b/modules/log.cpp index f81f1e7e..2098521b 100644 --- a/modules/log.cpp +++ b/modules/log.cpp @@ -463,6 +463,8 @@ void CLogMod::OnJoinMessage(CJoinMessage& Message) { const CNick& Nick = Message.GetNick(); CChan& Channel = *Message.GetChan(); + + // TODO: Move account logic to a separate Message method. CString sAccount = Message.GetTag("account"); const char* s = " ";