bool CIRCSock::OnQuitMessage(CQuitMessage& Message) { const CNick& Nick = Message.GetNick(); bool bIsVisible = false; if (Nick.NickEquals(GetNick())) { m_pNetwork->PutStatus("You quit [" + Message.GetReason() + "]"); // We don't call module hooks and we don't // forward this quit to clients (Some clients // disconnect if they receive such a QUIT) return true; } vector<CChan*> vFoundChans; const vector<CChan*>& vChans = m_pNetwork->GetChans(); for (CChan* pChan : vChans) { if (pChan->RemNick(Nick.GetNick())) { vFoundChans.push_back(pChan); if (!pChan->IsDetached()) { bIsVisible = true; } } } IRCSOCKMODULECALL(OnQuitMessage(Message, vFoundChans), NOTHING); return !bIsVisible; }
void OnQuitMessage(CQuitMessage& Message, const vector<CChan*>& vChans) override { const CNick& Nick = Message.GetNick(); const CString sMessage = Message.GetReason(); const CString sMsg = t_f("{1} quit: {2}")(Nick.GetNickMask(), sMessage); for (CChan* pChan : vChans) { AddBuffer(*pChan, sMsg, &Message.GetTime(), Message.GetTags()); } }
void OnQuitMessage(CQuitMessage& Message, const vector<CChan*>& vChans) override { const CNick& Nick = Message.GetNick(); const CString sMessage = Message.GetReason(); CString sMsg = Nick.GetNickMask() + " quit with message: [" + sMessage + "]"; for (CChan* pChan : vChans) { AddBuffer(*pChan, sMsg, &Message.GetTime(), Message.GetTags()); } }
TEST(MessageTest, Quit) { CQuitMessage msg; msg.Parse(":nick QUIT :reason"); EXPECT_EQ("nick", msg.GetNick().GetNick()); EXPECT_EQ("QUIT", msg.GetCommand()); EXPECT_EQ("reason", msg.GetReason()); EXPECT_EQ(CMessage::Type::Quit, msg.GetType()); msg.SetReason("test"); EXPECT_EQ("test", msg.GetReason()); EXPECT_EQ(":nick QUIT :test", msg.ToString()); }