Logo Search packages:      
Sourcecode: verlihub version File versions

int nDirectConnect::nProtocol::cDCProto::DCO_TempBan ( cMessageDC msg,
cConnDC conn 
) [protected]

operator ban

Definition at line 1284 of file cdcproto.cpp.

References nDirectConnect::nTables::cBanList::AddBan(), nDirectConnect::cConnDC::CloseNice(), nDirectConnect::cServerDC::DCKickNick(), nDirectConnect::cServerDC::DCPrivateHS(), nDirectConnect::cServerDC::DCPublicHS(), nDirectConnect::nTables::cBan::DisplayKick(), nDirectConnect::cServerDC::mBanList, nDirectConnect::cUserBase::mClass, cObj::mEmpty, nDirectConnect::cUserBase::mInList, nDirectConnect::cUserBase::mNick, nDirectConnect::cUser::mProtectFrom, nDirectConnect::cConnDC::mpUser, nDirectConnect::cServerDC::mUserList, nDirectConnect::cUser::mxConn, nDirectConnect::nTables::cBanList::NewBan(), nDirectConnect::nProtocol::cMessageDC::SplitChunks(), and nDirectConnect::cServerDC::Str2Period().

{
      if(!conn || !conn->mpUser || !conn->mpUser->mInList || conn->mpUser->mClass < eUC_OPERATOR) return -1;
      if(msg->SplitChunks()) return -1;

      ostringstream os;
      long period = 0;
      // calculate time
      if(msg->ChunkString(eCH_NB_TIME).size())
      {
      //@todo DCO_TempBan still to test and fix bugs
            mS->Str2Period(msg->ChunkString(eCH_NB_TIME),os);
            if(!period)
            {
                  mS->DCPublicHS(os.str(),conn);
                  return -1;
            }
      }

      cUser *other = mS->mUserList.GetUserByNick(msg->ChunkString(eCH_NB_NICK));
      if(!other)
      {
            os << "User " << msg->ChunkString(eCH_NB_NICK) << " not found.";
            mS->DCPublicHS(os.str(),conn);
            return -1;
      }

      if(msg->mType == eDCO_TBAN  && !msg->ChunkString(eCH_NB_REASON).size())
      {
            os << "I don't ban without a reason!";
            mS->DCPublicHS(os.str(),conn);
            return -1;
      }

      if(other->mClass >= conn->mpUser->mClass || other->mProtectFrom >= conn->mpUser->mClass)
      {
            os << "You can't ban your superior or user is protected";
            mS->DCPublicHS(os.str(),conn);
            return -1;
      }

      if(!other->mxConn)
      {
            os << "You can't ban a special user: " << msg->ChunkString(eCH_NB_NICK);
            mS->DCPublicHS(os.str(),conn);
            return -1;
      }

      if(period)
            os << "You are being temporary banned for: " << msg->ChunkString(eCH_NB_TIME);
      else
            os << "You are banned";
      os << " because: " << msg->ChunkString(eCH_NB_REASON);

      mS->DCPrivateHS(os.str(), other->mxConn, &conn->mpUser->mNick);
      os.str(mS->mEmpty);

      cBan ban(mS);
      mS->mBanList->NewBan(ban, other->mxConn, conn->mpUser->mNick, msg->ChunkString(eCH_NB_REASON), period, cBan::eBF_NICKIP);
      mS->mBanList->AddBan(ban);

      mS->DCKickNick(NULL, conn->mpUser, msg->ChunkString(eCH_NB_NICK), mS->mEmpty, cServerDC::eKCK_Drop);

      ban.DisplayKick(os);
      mS->DCPublicHS(os.str(),conn);
      other->mxConn->CloseNice(1000, eCR_KICKED);
      return 0;
}


Generated by  Doxygen 1.6.0   Back to index