Exemple #1
0
bool CClient::OnModeMessage(CModeMessage& Message)
{
	CString sTarget = Message.GetTarget();
	CString sModes = Message.GetModes();

	bool bReturn = false;
	NETWORKMODULECALL(OnUserModeMessage(Message), m_pUser, m_pNetwork, this, &bReturn);
	if (bReturn) return true;

	if (m_pNetwork && m_pNetwork->IsChan(sTarget) && sModes.empty()) {
		// If we are on that channel and already received a
		// /mode reply from the server, we can answer this
		// request ourself.

		CChan *pChan = m_pNetwork->FindChan(sTarget);
		if (pChan && pChan->IsOn() && !pChan->GetModeString().empty()) {
			PutClient(":" + m_pNetwork->GetIRCServer() + " 324 " + GetNick() + " " + sTarget + " " + pChan->GetModeString());
			if (pChan->GetCreationDate() > 0) {
				PutClient(":" + m_pNetwork->GetIRCServer() + " 329 " + GetNick() + " " + sTarget + " " + CString(pChan->GetCreationDate()));
			}
			return true;
		}
	}

	return false;
}
Exemple #2
0
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());
}
Exemple #3
0
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;
}