Logo Search packages:      
Sourcecode: verlihub version File versions

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

Treat the DC message in a appropriate way

Definition at line 1188 of file cdcproto.cpp.

References nDirectConnect::cConnDC::CloseNice(), nDirectConnect::cServerDC::ConnCloseMsg(), nDirectConnect::cServerDC::DCPrivateHS(), nDirectConnect::cServerDC::DCPublicHS(), cObj::Log(), cObj::LogStream(), nDirectConnect::cServerDC::mC, nDirectConnect::cUserBase::mClass, nDirectConnect::nTables::cDCConf::min_class_redir, nDirectConnect::cUserBase::mInList, nDirectConnect::cUserBase::mNick, nDirectConnect::cUser::mProtectFrom, nDirectConnect::cConnDC::mpUser, nDirectConnect::cServerDC::mUserList, nDirectConnect::cUser::mxConn, nDirectConnect::cConnDC::Send(), and nDirectConnect::nProtocol::cMessageDC::SplitChunks().

     : <victimNick> From: <senderNick> $<<senderNick>> You are being re-directed to <newHub> because: <reasonMsg>
{
      if(msg->SplitChunks()) return -1;
      if(!conn->mpUser || !conn->mpUser->mInList) return -2;
      ostringstream ostr;

      string &str = msg->ChunkString(eCH_FM_NICK);

      // check rights
      if(!conn->mpUser || conn->mpUser->mClass < mS->mC.min_class_redir)
      {
            if(conn->Log(1)) conn->LogStream() << "Tries to force move " << str  << endl;
            ostr << "You are not an operator, though you can't force move.";
            mS->ConnCloseMsg(conn,ostr.str(),2000, eCR_SYNTAX);
            return -1;
      }

      cUser *other = mS->mUserList.GetUserByNick ( str );

      // check the nick
      if(!other)
      {
            ostr << "User " << str << "not found.";
            mS->DCPublicHS(ostr.str(),conn);
            return -2;
      }

      // check the priviledges
      if(other->mClass >= conn->mpUser->mClass || other->mProtectFrom >= conn->mpUser->mClass)
      {
            ostr << "User " << str << "is too high for redir (or protected).";
            mS->DCPublicHS(ostr.str(),conn);
            return -3;
      }

      // create the message
      string omsg("$ForceMove ");
      omsg += msg->ChunkString(eCH_FM_DEST);
      omsg += "|";

      string redReason("You are being re-directed to: ");
      redReason += msg->ChunkString(eCH_FM_DEST);
      redReason += " because: ";
      redReason += msg->ChunkString(eCH_FM_REASON);

      Create_PM(omsg,conn->mpUser->mNick, msg->ChunkString(eCH_FM_NICK), conn->mpUser->mNick, redReason);

      if(other->mxConn)
      {
            // send it
            other->mxConn->Send(omsg);
            // close it
            other->mxConn->CloseNice(3000, eCR_FORCEMOVE);
            if(conn->Log(2)) conn->LogStream() << "ForceMove " << str  << " to: " << msg->ChunkString(eCH_FM_DEST)<< " because : " << msg->ChunkString(eCH_FM_REASON) << endl;
      }
      else
      {
            mS->DCPrivateHS("You can't move Hub-security.",conn);
      }
      return 0;
}


Generated by  Doxygen 1.6.0   Back to index