PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: exlepra on 22 July, 2004, 14:32:29

Title: req: client type and min version script
Post by: exlepra on 22 July, 2004, 14:32:29
Hi guys, Im looking for a script which would allow users only with dc++ .0401 and higher or dcgui 0.3.2 and higher ( I know this is theres no higher version yet :) ) to enter the hub.

thx in advance
Title:
Post by: nErBoS on 22 July, 2004, 15:50:31
Hi,

Hope it helps...

--## Simple Version Checker
--## Made by nErBoS
--## Requested by exlepra
 
sBot = "Version Checker"

arrVersion = {
["DC++"] = "0.401",
["DCGUI"] = "0.3.2",
}

function Main()
frmHub:RegBot(sBot)
end

function NewUserConnected(user)
local s,e,client,version = strfind(user.sMyInfoString, "<(%S+)%s+V:(%S+),M:")
if (client ~= nil and version ~= nil) then
if (client == "++" and tonumber(arrVersion["DC++"]) > tonumber(version)) then
user:SendPM(sBot, "This Hub only accepts version of DC++ higher then "..arrVersion["DC++"])
user:Disconnect()
elseif (client == "DCGUI" and tonumber(strsub(arrVersion["DCGUI"],3,strlen(arrVersion["DCGUI"]))) > tonumber(strsub(version,3,strlen(version)))) then
user:SendPM(sBot, "This Hub only accepts version of DCGUI higher then "..arrVersion["DCGUI"])
user:Disconnect()
end
end
end

Best regards, nErBoS
Title:
Post by: Cp6uja on 22 July, 2004, 16:11:07
exlepra try Client Checker Version: 3.1 by NightLitch
This script is best client check script
Enjoy

Client Checker ver.3.1 (http://board.univ-angers.fr/thread.php?threadid=1133&boardid=12&sid=49da78e55a370303f466edded4b4210c&page=2)

Quote-- Client Checker
-- Version: 3.1
-- By: NightLitch
-- Date: 2004/02/10
---------------------------------------------------------------------
kb = 1024
gb = kb*kb*kb
tb = kb*kb*kb*kb
---------------------------------------------------------------------
Bot = "Z-LeZ"

--Level Checks / 1:on/0:off

LC = {
  • = 0,   -- Check Masters
  • [1] = 0,   -- Check Operators
    [2] = 1,   -- Check VIPs
    [3] = 1,   -- Check REGs
    [-1] = 1,   -- Check Users
    }

    -- Client Settings
    -------------------------------------------------
    -- Allow Clients / 1:on/0:off
    AllowDCPP = 1      -- DC++
    AllowODC = 1         -- oDC
    AllowNMDC2 = 1      -- Neo Modus DC 2
    AllowDCGUI = 1      -- DCGUI
    AllowDCPRO = 1      -- DC:PRO
    AllowBCDC = 1      -- BCDC++
    AllowCZDC = 1      -- CZDC++
    AllowPDC = 1         -- Phantom DC++
    AllowIDC = 1         -- Italian DC++
    AllowNOTAG = 0      -- No Tag Client ex: Neo Modus DC 1
    AllowFAKE = 0         -- Fake Client (Fake Taging)

    -- Client Settings
    MinSlots = 2      -- Min Slots
    MaxSlots = 15      -- Max Slots
    MaxHubs = 8      -- Max Hubs for users
    LockBW = 10      -- Min Bandwidh Lock

    -- Version Checks
    DCPPver = "0.201"         -- DC++ Min. Version
    ODCver = "5.2"         -- oDC Min. Version
    NMDC2ver = "2.02"      -- Neo Modus DC 2 Min. Version
    DCPROver = "0.2.2.10"      -- DC:PRO Min. Version
    DCGUIver = "0.2.20"      -- DCGUI Min. Version
    IDCver = "1.03"         -- Italian DC++ Min. Version
    nDCver = "0.300"         -- nDC++ Min. Version

    ---------------------------------------------------------------------

    ClientTAG = {
    { "<%+%+","oDC" },
    { "{ "<%+%+","DC++" },
    { "{ "{ "http://dc.ketelhot.de","DCGUI" },
    { "{ "{ "zDC++[","zDC++" },
    { "","MS++V" },
    { "","MS++V" },
    { "{ "<.P>","Phantom DC++" },
    }

    function NewUserConnected(curUser)
             local vClient, vTag, vSpeed, vShare = ParseMyInfo(curUser.sMyInfoString)
             local Msg = "\r\n\r\n"
             Msg = Msg .. "\r\n   Welcome "..curUser.sName.." !"
             Msg = Msg .. "\r\n------------------------------------------------------------------------------------"
             Msg = Msg .. "\r\n "
             Msg = Msg .. "\r\n You are using "..vClient.." Version: "..vTag["V"].."."
             Msg = Msg .. "\r\n You are Sharing "..format("%.2f",vShare/gb).." Gb and "..vTag["S"].." Slot(s)."
             Msg = Msg .. "\r\n You are in "..vTag["H"].." Hub(s) as user."
             Msg = Msg .. "\r\n You are in "..vTag["RH"].." Hub(s) as registered user."
             Msg = Msg .. "\r\n You are in "..vTag["OH"].." Hub(s) as operator."
             Msg = Msg .. "\r\n Your Bandwidh Limiter is "..vTag["B"].." kB/s"
             Msg = Msg .. "\r\n You are in "..vTag["M"].." Mode."
             Msg = Msg .. "\r\n "
             Msg = Msg .. "\r\n------------------------------------------------------------------------------------"
             curUser:SendData(BotName,Msg)
    end

    function DataArrival(curUser,data)
       if (strsub(data,1,7) == "$MyINFO") then
          local vClient, vTag, vSpeed, vShare = ParseMyInfo(data)
          AllowClients(curUser,vClient,vTag)
       end
    end

    function ParseMyInfo(MyInfo)
       local vClient = "Unknown"
       local Bwidh = ""
       local _,_,vSpeed,sShare = strfind( MyInfo, "^%$MyINFO %$ALL [^ ]+ [^$]*%$ $([^$]+)[^$]%$[^$]*%$%s*(%d+)%$" )
       local vShare = tonumber(sShare)
          
       for i = 1,getn(ClientTAG) do
          if strfind(MyInfo,ClientTAG
[1]) then
         vClient = ClientTAG[2]
      end
   end
   
   local Version = ""
   local _,_,Slots = strfind( MyInfo, "S:(%d+)")
   local _,_,Mode = strfind( MyInfo, "M:([S,A,P])")
   local _,_, DcVer = strfind(MyInfo,"V:(%x+.%x+)")
   Version = DcVer
   if strfind(MyInfo,"      local _,_,oDCVer = strfind(MyInfo,"")
      Version = oDCVer
      vClient = "oDC"
   elseif vClient=="Italian DC++" then
      local _,_,IDCVer = strfind(MyInfo,"")
      Version = IDCVer
   end

   local Hubs = ""
   local Regged = ""
   local Opped = ""
   local _,_, gethub = strfind(MyInfo,"H:(%x+)/")
   if gethub == nil then
      _,_, Hubs = strfind(MyInfo,"H:(%x+)")
      Regged = 0
      Opped = 0
   else
      Hubs = gethub
      _,_, Regged = strfind(MyInfo,"H:%x+/(%x+)/")
      _,_, Opped = strfind(MyInfo,"H:%x+/%x+/(%x+)")
   end
   
   if strfind(MyInfo,"H:\"%d+/%d+/%d+\",S") then
      vClient = "Fake Client"
      _,_,Hubs,Regged,Opped = strfind(MyInfo,"H:\"(%x+)/(%x+)/(%x+)\"")
   end

   if strfind( MyInfo,"V:%S+(k),M") then vClient = "DC++k" end

   
   if strfind(MyInfo, "L:") then
      local _,_,Ls = strfind(MyInfo , "L:(%d+)")
      Bwidh = Ls
      vClient = "CZDC++"
   elseif strfind(MyInfo, "B:") then
      local _,_,Bs = strfind(MyInfo , "B:(%d+)")
      Bwidh = Bs
      if not vClient=="Phantom DC++" then
         vClient = "BCDC++"
      end
   elseif strfind(MyInfo, "F:") then
      local _,_,Fs = strfind(MyInfo , "F:%d+/(%d+)")
      Bwidh = Fs
   else
      Bwidh = "unlimited"
   end

   if Version == nil then Version = "0" end
   if Mode == nil then Mode = "0" end
   if Hubs == nil then Hubs = "0" end
   if Slots == nil then Slots = "0" end

   tMode = {
   ["S"] = "Socks",
   ["A"] = "Active",
   ["P"] = "Passive",
   ["0"] = "N/A",
   }
   vTag = { ["H"] = Hubs, ["S"] = Slots, ["B"] = Bwidh,["V"] = Version, ["M"] = tMode[Mode], ["RH"] = Regged,  ["OH"] = Opped}
   return vClient, vTag, vSpeed, vShare
end

function AllowClients(curUser,vClient,vTag)
   if (LC[curUser.iProfile]==1) then
      if (vClient =="oDC" and AllowODC==1) then
         CheckSlotsHubs(curUser,vTag)
         VersionCheck(curUser,vClient,vTag,ODCver,"http://gempond.com/odc")
         BandwidhCheck(curUser,vTag)
      elseif (vClient =="DC++" and AllowDCPP==1) then
         CheckSlotsHubs(curUser,vTag)
         VersionCheck(curUser,vClient,vTag,DCPPver,"http://dcplusplus.sourceforge.net")
         BandwidhCheck(curUser,vTag)
      elseif (vClient =="DC:PRO" and AllowDCPRO==1) then
         CheckSlotsHubs(curUser,vTag)
         VersionCheck(curUser,vClient,vTag,DCPROver,"http://btpro.altervista.org/index.php")
         BandwidhCheck(curUser,vTag)
      elseif (vClient =="DCGUI" and AllowDCGUI==1) then
         CheckSlotsHubs(curUser,vTag)
         VersionCheck(curUser,vClient,vTag,DCGUIver,"http://dc.ketelhot.de")
         BandwidhCheck(curUser,vTag)
      elseif (vClient =="NeoModus 2" and AllowNMDC2==1) then
         CheckSlotsHubs(curUser,vTag)
         VersionCheck(curUser,vClient,vTag,NMDC2ver,"http://neo-modus.com")
         BandwidhCheck(curUser,vTag)
      elseif (vClient =="BCDC++" and AllowBCDC==1)  then
         CheckSlotsHubs(curUser,vTag)
         VersionCheck(curUser,vClient,vTag,DCPPver,"http://utrum.dyndns.org:8000/index.html")
         BandwidhCheck(curUser,vTag)
      elseif (vClient =="CZDC++" and AllowCZDC==1) then
         CheckSlotsHubs(curUser,vTag)
         VersionCheck(curUser,vClient,vTag,DCPPver,"http://www.czdcplusplus.tk/")
         BandwidhCheck(curUser,vTag)
      elseif (vClient =="Phantom DC++" and AllowPDC==1) then
         CheckSlotsHubs(curUser,vTag)
         VersionCheck(curUser,vClient,vTag,DCPPver,"http://pdc.recoil.net.nz/index.php")
         BandwidhCheck(curUser,vTag)
      elseif (vClient =="Italian DC++" and AllowIDC==1) then
         CheckSlotsHubs(curUser,vTag)
         VersionCheck(curUser,vClient,vTag,IDCver,"http://www.p2pitalia.com/")
         BandwidhCheck(curUser,vTag)

      elseif (vClient =="Fake Client" and AllowFAKE==1) then
         CheckSlotsHubs(curUser,vTag)
         VersionCheck(curUser,vClient,vTag,DCPPver,"http://dcplusplus.sourceforge.net")
         BandwidhCheck(curUser,vTag)
      elseif (vClient =="Unknown" and AllowNOTAG==1) then

      elseif (vClient =="Fake Client" and AllowFAKE==0) then
         curUser:SendData(BotName,curUser.sName.." you are using a fake tag or client!")
         curUser:Disconnect()
      elseif (vClient =="Unknown" and AllowNOTAG==0) then
         curUser:SendData(BotName,curUser.sName.." you are using a client with no tag!")
         curUser:Disconnect()
      else
         curUser:SendData(BotName,curUser.sName..", "..vClient.." is not allowed here!")
         curUser:Disconnect()
      end
   end
end

function CheckSlotsHubs(curUser,vTag)
   if (vTag["S"] == "N/A" or vTag["H"] == "N/A") then
   elseif (tonumber(vTag["S"]) < MinSlots) then
      curUser:SendData(BotName,"You have too litle slots open ( "..vTag["S"].." ) Minimum slots is ( "..MinSlots.." ). ")
      curUser:Disconnect()
   elseif (tonumber(vTag["S"]) > MaxSlots) then
      curUser:SendData(BotName,"You have too many slots open ( "..vTag["S"].." ) Maximum slots is ( "..MaxSlots.." ). ")
      curUser:Disconnect()
   elseif (tonumber(vTag["H"]) > MaxHubs) then
      curUser:SendData(BotName,"You are in too many hubs ( "..vTag["H"].." ) Max Hubs is ( "..MaxHubs.." ). ")
      curUser:Disconnect()
   end
end

function VersionCheck(curUser,vClient,vTag,Version,Download)
   if (vClient == "DCGUI" or vClient == "DC:PRO") then
      if (vTag["V"] == "N/A") then
      elseif (vTag["V"] < Version) then
         curUser:SendData(BotName,"You are using "..vClient.." version [ "..vTag["V"].." ]")
         curUser:SendData(BotName,"The oldest version allowed is "..vClient.." [ "..Version.." ], you may download the latest "..vClient.." at "..Download)
         curUser:Disconnect()
      end
   else
      if (vTag["V"] == "N/A") then
      elseif (vTag["V"] < Version) then
         curUser:SendData(BotName,"You are using "..vClient.." version [ "..vTag["V"].." ]")
         curUser:SendData(BotName,"The oldest version allowed is "..vClient.." [ "..Version.." ], you may download the latest "..vClient.." at "..Download)
         curUser:Disconnect()
      end
   end
end

function BandwidhCheck(curUser,vTag)
   if vTag["B"] == "unlimited" then
   elseif (tonumber(vTag["B"]) < LockBW) then
      curUser:SendData(BotName,"You are using a Bandwidh Locker, locked to ( "..vTag["B"].."  kB/s  ), Minimum is ( "..LockBW.." kB/s ).")
      curUser:Disconnect()
   end
end

/Cp6uja
Title:
Post by: exlepra on 22 July, 2004, 17:29:28
thx, nErBoS I was looking for exactly that kinda small script :)
Title:
Post by: exlepra on 12 August, 2004, 12:54:15
Nerbos, how can I add a little delay before the disconnect?

It looks sometimes users dont receive the PM before the connection reset.

thx
Title:
Post by: nErBoS on 12 August, 2004, 17:57:33
Hi,

They should recive because the phrase is sent first them the disconnect command, the disconnect could be from another thing.

Best regards, nErBoS

Back to my vacations :)