From 08320949762374d8fb5cec1677f7b7bb3e89ec40 Mon Sep 17 00:00:00 2001 From: RealKindOne Date: Sun, 23 Aug 2026 15:18:13 -0400 Subject: [PATCH] autoreply: Modernize and add test. --- modules/autoreply.cpp | 4 ++-- test/integration/tests/modules.cpp | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/modules/autoreply.cpp b/modules/autoreply.cpp index ad42d4d6..e400b218 100644 --- a/modules/autoreply.cpp +++ b/modules/autoreply.cpp @@ -65,8 +65,8 @@ class CAutoReplyMod : public CModule { PutIRC("NOTICE " + sNick + " :" + GetReply()); } - EModRet OnPrivMsg(CNick& Nick, CString& sMessage) override { - Handle(Nick.GetNick()); + EModRet OnPrivTextMessage(CTextMessage& Message) override { + Handle(Message.GetNick().GetNick()); return CONTINUE; } diff --git a/test/integration/tests/modules.cpp b/test/integration/tests/modules.cpp index a14c07f9..bc023ed4 100644 --- a/test/integration/tests/modules.cpp +++ b/test/integration/tests/modules.cpp @@ -628,5 +628,29 @@ TEST_F(ZNCTest, StripControlsModule) { } +TEST_F(ZNCTest, AutoReplyModule) { + auto znc = Run(); + auto ircd = ConnectIRCd(); + auto client = LoginClient(); + + client.Write("znc loadmod autoreply I'm currently away"); + client.ReadUntil("Loaded module"); + + ircd.Write(":server 001 nick :Hello"); + + client.Write("QUIT :Going away"); + client.Close(); + + ircd.Write(":testuser!test@host PRIVMSG nick :Hello there"); + ircd.ReadUntil("NOTICE testuser :I'm currently away"); + + ircd.Write(":testuser!test@host PRIVMSG nick :Another message"); + ircd.Write(":otheruser!other@host PRIVMSG nick :Hi nick"); + ircd.ReadUntil("NOTICE otheruser :I'm currently away"); + + auto client2 = LoginClient(); + ircd.Write(":thirduser!third@host PRIVMSG nick :Are you there?"); +} + } // namespace } // namespace znc_inttest