示例#1
0
bool CIRCSock::OnActionMessage(CActionMessage& Message) {
    bool bResult = false;
    CChan* pChan = nullptr;
    CString sTarget = Message.GetTarget();
    if (sTarget.Equals(GetNick())) {
        IRCSOCKMODULECALL(OnPrivCTCPMessage(Message), &bResult);
        if (bResult) return true;
        IRCSOCKMODULECALL(OnPrivActionMessage(Message), &bResult);
        if (bResult) return true;

        if (!m_pNetwork->IsUserOnline() ||
                !m_pNetwork->GetUser()->AutoClearQueryBuffer()) {
            const CNick& Nick = Message.GetNick();
            CQuery* pQuery = m_pNetwork->AddQuery(Nick.GetNick());
            if (pQuery) {
                CActionMessage Format;
                Format.Clone(Message);
                Format.SetNick(_NAMEDFMT(Nick.GetNickMask()));
                Format.SetTarget("{target}");
                Format.SetText("{text}");
                pQuery->AddBuffer(Format, Message.GetText());
            }
        }
    } else {
        pChan = m_pNetwork->FindChan(sTarget);
        if (pChan) {
            Message.SetChan(pChan);
            FixupChanNick(Message.GetNick(), pChan);
            IRCSOCKMODULECALL(OnChanCTCPMessage(Message), &bResult);
            if (bResult) return true;
            IRCSOCKMODULECALL(OnChanActionMessage(Message), &bResult);
            if (bResult) return true;

            if (!pChan->AutoClearChanBuffer() || !m_pNetwork->IsUserOnline() ||
                    pChan->IsDetached()) {
                CActionMessage Format;
                Format.Clone(Message);
                Format.SetNick(_NAMEDFMT(Message.GetNick().GetNickMask()));
                Format.SetTarget(_NAMEDFMT(Message.GetTarget()));
                Format.SetText("{text}");
                pChan->AddBuffer(Format, Message.GetText());
            }
        }
    }

    return (pChan && pChan->IsDetached());
}
示例#2
0
TEST(MessageTest, PrivAction) {
	CActionMessage msg;
	msg.Parse(":sender PRIVMSG receiver :\001ACTION ACTS\001");
	EXPECT_EQ("sender", msg.GetNick().GetNick());
	EXPECT_EQ("PRIVMSG", msg.GetCommand());
	EXPECT_EQ("receiver", msg.GetTarget());
	EXPECT_EQ("ACTS", msg.GetText());
	EXPECT_EQ(CMessage::Type::Action, msg.GetType());

	msg.SetText("foo bar");
	EXPECT_EQ("foo bar", msg.GetText());
	EXPECT_EQ(":sender PRIVMSG receiver :\001ACTION foo bar\001", msg.ToString());
}