From 47b815ae5b8a8caf04e67597524afe7a51e88b9c Mon Sep 17 00:00:00 2001 From: Peter Ajamian Date: Wed, 9 Aug 2023 19:13:54 +1200 Subject: [PATCH] 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,