diff --git a/modules/autoattach.cpp b/modules/autoattach.cpp index 3b6f2291..0b65d8da 100644 --- a/modules/autoattach.cpp +++ b/modules/autoattach.cpp @@ -209,20 +209,24 @@ class CChanAttach : public CModule { } } - EModRet OnChanNotice(CNick& Nick, CChan& Channel, - CString& sMessage) override { - TryAttach(Nick, Channel, sMessage); + EModRet OnChanNoticeMessage(CNoticeMessage& Message) override { + CString sText = Message.GetText(); + TryAttach(Message.GetNick(), *Message.GetChan(), sText); + Message.SetText(sText); return CONTINUE; } - EModRet OnChanMsg(CNick& Nick, CChan& Channel, CString& sMessage) override { - TryAttach(Nick, Channel, sMessage); + EModRet OnChanTextMessage(CTextMessage& Message) override { + CString sText = Message.GetText(); + TryAttach(Message.GetNick(), *Message.GetChan(), sText); + Message.SetText(sText); return CONTINUE; } - EModRet OnChanAction(CNick& Nick, CChan& Channel, - CString& sMessage) override { - TryAttach(Nick, Channel, sMessage); + EModRet OnChanActionMessage(CActionMessage& Message) override { + CString sText = Message.GetText(); + TryAttach(Message.GetNick(), *Message.GetChan(), sText); + Message.SetText(sText); return CONTINUE; } diff --git a/test/integration/tests/modules.cpp b/test/integration/tests/modules.cpp index 8da63d6e..a14c07f9 100644 --- a/test/integration/tests/modules.cpp +++ b/test/integration/tests/modules.cpp @@ -291,6 +291,8 @@ TEST_F(ZNCTest, AutoAttachModule) { ircd.Write(":nick JOIN :#znc"); ircd.Write(":server 353 nick #znc :nick"); ircd.Write(":server 366 nick #znc :End of /NAMES list"); + + // OnChanTextMessage ircd.Write(":foo PRIVMSG #znc :hi"); client.ReadUntil(":foo PRIVMSG"); client.Write("detach #znc"); @@ -298,6 +300,24 @@ TEST_F(ZNCTest, AutoAttachModule) { ircd.Write(":foo PRIVMSG #znc :hello"); ircd.ReadUntil("TEST"); client.ReadUntil("hello"); + + // OnChanActionMessage + ircd.Write(":foo PRIVMSG #znc :hi"); + client.ReadUntil(":foo PRIVMSG"); + client.Write("detach #znc"); + client.ReadUntil("Detached"); + ircd.Write(":foo PRIVMSG #znc :\001ACTION hello\001"); + ircd.ReadUntil("TEST"); + client.ReadUntil("\001ACTION hello\001"); + + // OnChanNoticeMessage + ircd.Write(":foo NOTICE #znc :hi"); + client.ReadUntil(":foo NOTICE"); + client.Write("detach #znc"); + client.ReadUntil("Detached"); + ircd.Write(":foo NOTICE #znc :hello NOTICE"); + ircd.ReadUntil("TEST"); + client.ReadUntil("hello NOTICE"); } TEST_F(ZNCTest, KeepNickModule) {