PtokaX forum

Archive => Archived 5.1 boards => Conversion Requests => Topic started by: ?[-?Genius?-]? on 08 March, 2007, 20:16:07

Title: Convert IP BOT
Post by: ?[-?Genius?-]? on 08 March, 2007, 20:16:07
Hi ppl

I need this IpBot script converted too Lua 5.1 If is Possible.

Tankx

--=[ DvdRip.sytes.net ]=--
--=[ Script Ip-Bot Por Genius ]=--
--=[ Adaptado e actualizado para DvdRip em Junho 2006 ]=--

--=[ Nome do Bot ]=--

sBot = "![ PT??w?s ]"
OpChatName = "![ PT??w?s ]"

--=[ Exep??es / Deixar entrar um internacional atrav?z do nick ]=--

excepcoes = {
[" xxxx"] = 1,
["  xxxx"] = 2,
["   xxxx"] = 3,
}


--=[ Ranges permitidas no Hub ]=--

arrIP = {
  ["xxxxxxx"] = "xxxxxx", -- xxxxx
}

--=[ Codigo do script ]=-

function Main()
  frmHub:RegBot(sBot)
end

--=[ Mensagem ao user n?o constante na Range ]=-

function NewUserConnected(user)
  if (excepcoes[user.sName] == nil) and (isGoodIP(user.sIP) == nil) then
user:SendData(sBot, " --=[ Este Servidor apenas permite Ips Nacionais. Se ?s de Portugal contacta-nos: RicardoFVTavaresHotmail.com [EMAIL]ou abre pvt com [PT]?Genius??, a tua ajuda ? preciosa. ]=-- ")
     user:SendData("$ForceMove PtDowns.sytes.net:8888")
user:Disconnect()
  end
end

OpConnected = NewUserConnected

function isGoodIP(sIP)
  sIP = ipToNumber(sIP)
  local iFirst,iLast
  for iFirst, iLast in arrIP do
     if (sIP >= ipToNumber(iFirst) and sIP <= ipToNumber(iLast)) then
        return 1
     end
  end
  return nil
end

function ipToNumber(sIP)
  iAux = ""
  string.gsub(sIP,"(%d+)", function(w)
     w = tonumber(w)
     if (w < 10) then
        iAux = iAux.."00"..w
     elseif (w < 100) then
        iAux = iAux.."0"..w
     else
        iAux = iAux..w
     end
  end)
  return tonumber(iAux)
end
Title: Re: Convert IP BOT
Post by: Cêñoßy†ê on 08 March, 2007, 21:33:40
Try this
Code (lua) Select

--=[ DvdRip.sytes.net ]=--
--=[ Script Ip-Bot Por Genius ]=--
--=[ Adaptado e actualizado para DvdRip em Junho 2006 ]=--

--=[ Nome do Bot ]=--

sBot = "![ PT??w?s ]"
OpChatName = "![ PT??w?s ]"

--=[ Exep??es / Deixar entrar um internacional atrav?z do nick ]=--

excepcoes = {
[" xxxx"] = 1,
["  xxxx"] = 2,
["   xxxx"] = 3,
}


--=[ Ranges permitidas no Hub ]=--

arrIP = {
   ["xxxxxxx"] = "xxxxxx", -- xxxxx
}

--=[ Codigo do script ]=-

function Main()
   frmHub:RegBot(sBot)
end

--=[ Mensagem ao user n?o constante na Range ]=-

function NewUserConnected(user)
   if (excepcoes[user.sName] == nil) and (isGoodIP(user.sIP) == nil) then
user:SendData(sBot, " --=[ Este Servidor apenas permite Ips Nacionais. Se ?s de Portugal contacta-nos: RicardoFVTavaresHotmail.com [EMAIL]ou abre pvt com [PT]?Genius??, a tua ajuda ? preciosa. ]=-- ")
      user:SendData("$ForceMove PtDowns.sytes.net:8888")
user:Disconnect()
   end
end

OpConnected = NewUserConnected

function isGoodIP(sIP)
   sIP = ipToNumber(sIP)
   local iFirst,iLast
   for iFirst, iLast in pairs(arrIP) do
      if (sIP >= ipToNumber(iFirst) and sIP <= ipToNumber(iLast)) then
         return 1
      end
   end
   return nil
end

function ipToNumber(sIP)
   iAux = ""
   string.gsub(sIP,"(%d+)", function(w)
      w = tonumber(w)
      if (w < 10) then
         iAux = iAux.."00"..w
      elseif (w < 100) then
         iAux = iAux.."0"..w
      else
         iAux = iAux..w
      end
   end)
   return tonumber(iAux)
end
Title: Re: Convert IP BOT
Post by: ?[-?Genius?-]? on 08 March, 2007, 22:19:03
tankx men

works fine