예제 #1
0
파일: MessageTest.cpp 프로젝트: KielBNC/znc
TEST(MessageTest, Mode) {
	CModeMessage msg;
	msg.Parse(":nick MODE #chan +k foo");
	EXPECT_EQ("nick", msg.GetNick().GetNick());
	EXPECT_EQ("MODE", msg.GetCommand());
	EXPECT_EQ("#chan", msg.GetTarget());
	EXPECT_EQ("+k foo", msg.GetModes());

	EXPECT_EQ(":nick MODE #chan +k foo", msg.ToString());
}
예제 #2
0
파일: IRCSock.cpp 프로젝트: fnordcordia/znc
bool CIRCSock::OnModeMessage(CModeMessage& Message) {
    const CNick& Nick = Message.GetNick();
    CString sTarget = Message.GetTarget();
    CString sModes = Message.GetModes();

    CChan* pChan = m_pNetwork->FindChan(sTarget);
    if (pChan) {
        pChan->ModeChange(sModes, &Nick);

        if (pChan->IsDetached()) {
            return true;
        }
    } else if (sTarget == m_Nick.GetNick()) {
        CString sModeArg = sModes.Token(0);
        bool bAdd = true;
        /* no module call defined (yet?)
                MODULECALL(OnRawUserMode(*pOpNick, *this, sModeArg, sArgs),
           m_pNetwork->GetUser(), nullptr, );
        */
        for (unsigned int a = 0; a < sModeArg.size(); a++) {
            const unsigned char& uMode = sModeArg[a];

            if (uMode == '+') {
                bAdd = true;
            } else if (uMode == '-') {
                bAdd = false;
            } else {
                if (bAdd) {
                    m_scUserModes.insert(uMode);
                } else {
                    m_scUserModes.erase(uMode);
                }
            }
        }
    }
    return false;
}