コード例 #1
0
ファイル: IRCSock.cpp プロジェクト: fnordcordia/znc
bool CIRCSock::OnJoinMessage(CJoinMessage& Message) {
    const CNick& Nick = Message.GetNick();
    CString sChan = Message.GetParam(0);
    CChan* pChan = nullptr;

    if (Nick.NickEquals(GetNick())) {
        m_pNetwork->AddChan(sChan, false);
        pChan = m_pNetwork->FindChan(sChan);
        if (pChan) {
            pChan->Enable();
            pChan->SetIsOn(true);
            PutIRC("MODE " + sChan);
        }
    } else {
        pChan = m_pNetwork->FindChan(sChan);
    }

    if (pChan) {
        pChan->AddNick(Nick.GetNickMask());
        Message.SetChan(pChan);
        IRCSOCKMODULECALL(OnJoinMessage(Message), NOTHING);

        if (pChan->IsDetached()) {
            return true;
        }
    }

    return false;
}
コード例 #2
0
ファイル: Client.cpp プロジェクト: bradleysepos/znc
bool CClient::OnJoinMessage(CJoinMessage& Message) {
    CString sChans = Message.GetTarget();
    CString sKeys = Message.GetKey();

    VCString vsChans;
    sChans.Split(",", vsChans, false);
    sChans.clear();

    VCString vsKeys;
    sKeys.Split(",", vsKeys, true);
    sKeys.clear();

    for (unsigned int a = 0; a < vsChans.size(); a++) {
        Message.SetTarget(vsChans[a]);
        Message.SetKey((a < vsKeys.size()) ? vsKeys[a] : "");
        if (m_pNetwork) {
            // May be nullptr.
            Message.SetChan(m_pNetwork->FindChan(vsChans[a]));
        }
        bool bContinue = false;
        NETWORKMODULECALL(OnUserJoinMessage(Message), m_pUser, m_pNetwork, this,
                          &bContinue);
        if (bContinue) continue;

        CString sChannel = Message.GetTarget();
        CString sKey = Message.GetKey();

        if (m_pNetwork) {
            CChan* pChan = m_pNetwork->FindChan(sChannel);
            if (pChan) {
                if (pChan->IsDetached())
                    pChan->AttachUser(this);
                else
                    pChan->JoinUser(sKey);
                continue;
            } else if (!sChannel.empty()) {
                pChan = new CChan(sChannel, m_pNetwork, false);
                if (m_pNetwork->AddChan(pChan)) {
                    pChan->SetKey(sKey);
                }
            }
        }

        if (!sChannel.empty()) {
            sChans += (sChans.empty()) ? sChannel : CString("," + sChannel);

            if (!vsKeys.empty()) {
                sKeys += (sKeys.empty()) ? sKey : CString("," + sKey);
            }
        }
    }

    Message.SetTarget(sChans);
    Message.SetKey(sKeys);

    return sChans.empty();
}