From facec8d4a384cf4a2f400ce81f3dd494e18e0db2 Mon Sep 17 00:00:00 2001 From: Oleh Prypin Date: Thu, 26 Nov 2015 17:00:30 +0200 Subject: [PATCH] Show client identification in notify_connect module --- modules/notify_connect.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/modules/notify_connect.cpp b/modules/notify_connect.cpp index b05177ff..c080e3ee 100644 --- a/modules/notify_connect.cpp +++ b/modules/notify_connect.cpp @@ -22,17 +22,28 @@ public: MODCONSTRUCTOR(CNotifyConnectMod) {} void OnClientLogin() override { - SendAdmins(GetUser()->GetUserName() + " attached (from " + GetClient()->GetRemoteIP() + ")"); + NotifyAdmins("attached"); } void OnClientDisconnect() override { - SendAdmins(GetUser()->GetUserName() + " detached (from " + GetClient()->GetRemoteIP() + ")"); + NotifyAdmins("detached"); } private: void SendAdmins(const CString &msg) { CZNC::Get().Broadcast(msg, true, nullptr, GetClient()); } + + void NotifyAdmins(const CString &event) { + CString client = GetUser()->GetUserName(); + if (GetClient()->GetIdentifier() != "") { + client += "@"; + client += GetClient()->GetIdentifier(); + } + CString ip = GetClient()->GetRemoteIP(); + + SendAdmins(client + " " + event + " (from " + ip + ")"); + } }; template<> void TModInfo(CModInfo& Info) {