void CIRCSock::Disconnected() {
    IRCSOCKMODULECALL(OnIRCDisconnected(), NOTHING);

    DEBUG(GetSockName() << " == Disconnected()");
    if (!m_pNetwork->GetUser()->IsBeingDeleted() &&
        m_pNetwork->GetIRCConnectEnabled() &&
        m_pNetwork->GetServers().size() != 0) {
        m_pNetwork->PutStatus(t_s("Disconnected from IRC. Reconnecting..."));
    }
    m_pNetwork->ClearRawBuffer();
    m_pNetwork->ClearMotdBuffer();

    ResetChans();

    // send a "reset user modes" cmd to the client.
    // otherwise, on reconnect, it might think it still
    // had user modes that it actually doesn't have.
    CString sUserMode;
    for (char cMode : m_scUserModes) {
        sUserMode += cMode;
    }
    if (!sUserMode.empty()) {
        m_pNetwork->PutUser(":" + m_pNetwork->GetIRCNick().GetNickMask() +
                            " MODE " + m_pNetwork->GetIRCNick().GetNick() +
                            " :-" + sUserMode);
    }

    // also clear the user modes in our space:
    m_scUserModes.clear();
}
void CIRCSock::Disconnected() {
    IRCSOCKMODULECALL(OnIRCDisconnected(), NOTHING);

    DEBUG(GetSockName() << " == Disconnected()");
    if (!m_pNetwork->GetUser()->IsBeingDeleted() &&
        m_pNetwork->GetIRCConnectEnabled() &&
        m_pNetwork->GetServers().size() != 0) {
        m_pNetwork->PutStatus(t_s("Disconnected from IRC. Reconnecting..."));
    }
    m_pNetwork->ClearRawBuffer();
    m_pNetwork->ClearMotdBuffer();

    ResetChans();

     
     
     
    CString sUserMode;
    for (char cMode : m_scUserModes) {
        sUserMode += cMode;
    }
    if (!sUserMode.empty()) {
        m_pNetwork->PutUser(":" + m_pNetwork->GetIRCNick().GetNickMask() +
                            " MODE " + m_pNetwork->GetIRCNick().GetNick() +
                            " :-" + sUserMode);
    }

     
    m_scUserModes.clear();
}