diff --git a/include/znc/Message.h b/include/znc/Message.h index 40a64d68..019710b7 100644 --- a/include/znc/Message.h +++ b/include/znc/Message.h @@ -89,13 +89,13 @@ private: class CChanAction : public CMessage { public: - CString GetText() const { return GetParam(1).TrimLeft_n("\001ACTION ").TrimRight_n("\001"); } + CString GetText() const { return GetParam(1).TrimPrefix_n("\001ACTION ").TrimSuffix_n("\001"); } void SetText(const CString& sText) { SetParam(1, "\001ACTION " + sText + "\001"); } }; class CChanCTCP : public CMessage { public: - CString GetText() const { return GetParam(1).TrimLeft_n("\001").TrimRight_n("\001"); } + CString GetText() const { return GetParam(1).TrimPrefix_n("\001").TrimSuffix_n("\001"); } void SetText(const CString& sText) { SetParam(1, "\001" + sText + "\001"); } }; @@ -138,13 +138,13 @@ public: class CPrivAction : public CMessage { public: - CString GetText() const { return GetParam(1).TrimLeft_n("\001ACTION ").TrimRight_n("\001"); } + CString GetText() const { return GetParam(1).TrimPrefix_n("\001ACTION ").TrimSuffix_n("\001"); } void SetText(const CString& sText) { SetParam(1, "\001ACTION " + sText + "\001"); } }; class CPrivCTCP : public CMessage { public: - CString GetText() const { return GetParam(1).TrimLeft_n("\001").TrimRight_n("\001"); } + CString GetText() const { return GetParam(1).TrimPrefix_n("\001").TrimSuffix_n("\001"); } void SetText(const CString& sText) { SetParam(1, "\001" + sText + "\001"); } }; diff --git a/test/MessageTest.cpp b/test/MessageTest.cpp index b50886ed..c799dabb 100644 --- a/test/MessageTest.cpp +++ b/test/MessageTest.cpp @@ -56,11 +56,11 @@ TEST(MessageTest, FormatFlags) { } TEST(MessageTest, ChanAction) { - CMessage msg(":sender PRIVMSG #chan :\001ACTION text\001"); + CMessage msg(":sender PRIVMSG #chan :\001ACTION ACTS\001"); CChanAction& chan = static_cast(msg); EXPECT_EQ("sender", chan.GetNick().GetNick()); EXPECT_EQ("PRIVMSG", chan.GetCommand()); - EXPECT_EQ("text", chan.GetText()); + EXPECT_EQ("ACTS", chan.GetText()); chan.SetText("foo bar"); EXPECT_EQ("foo bar", chan.GetText()); @@ -139,11 +139,11 @@ TEST(MessageTest, Part) { } TEST(MessageTest, PrivAction) { - CMessage msg(":sender PRIVMSG receiver :\001ACTION text\001"); + CMessage msg(":sender PRIVMSG receiver :\001ACTION ACTS\001"); CPrivAction& priv = static_cast(msg); EXPECT_EQ("sender", priv.GetNick().GetNick()); EXPECT_EQ("PRIVMSG", priv.GetCommand()); - EXPECT_EQ("text", priv.GetText()); + EXPECT_EQ("ACTS", priv.GetText()); priv.SetText("foo bar"); EXPECT_EQ("foo bar", priv.GetText());