TEST(MessageTest, Topic) { CTopicMessage msg; msg.Parse(":nick TOPIC #chan :topic"); EXPECT_EQ("nick", msg.GetNick().GetNick()); EXPECT_EQ("TOPIC", msg.GetCommand()); EXPECT_EQ("#chan", msg.GetTarget()); EXPECT_EQ("topic", msg.GetTopic()); EXPECT_EQ(CMessage::Type::Topic, msg.GetType()); msg.SetTopic("test"); EXPECT_EQ("test", msg.GetTopic()); EXPECT_EQ(":nick TOPIC #chan :test", msg.ToString()); }
EModRet OnTopicMessage(CTopicMessage& Message) override { const CNick& Nick = Message.GetNick(); CChan& Channel = *Message.GetChan(); const CString sTopic = Message.GetTopic(); AddBuffer(Channel, Nick.GetNickMask() + " changed the topic to: " + sTopic, &Message.GetTime(), Message.GetTags()); return CONTINUE; }
bool CClient::OnTopicMessage(CTopicMessage& Message) { bool bReturn = false; CString sChan = Message.GetTarget(); CString sTopic = Message.GetTopic(); if (!sTopic.empty()) { NETWORKMODULECALL(OnUserTopicMessage(Message), m_pUser, m_pNetwork, this, &bReturn); } else { NETWORKMODULECALL(OnUserTopicRequest(sChan), m_pUser, m_pNetwork, this, &bReturn); Message.SetTarget(sChan); } return bReturn; }
bool CIRCSock::OnTopicMessage(CTopicMessage& Message) { const CNick& Nick = Message.GetNick(); CChan* pChan = m_pNetwork->FindChan(Message.GetParam(0)); if (pChan) { Message.SetChan(pChan); bool bReturn = false; IRCSOCKMODULECALL(OnTopicMessage(Message), &bReturn); if (bReturn) return true; pChan->SetTopicOwner(Nick.GetNick()); pChan->SetTopicDate((unsigned long)time(nullptr)); pChan->SetTopic(Message.GetTopic()); } return (pChan && pChan->IsDetached()); }