PtokaX forum

Lua 5.3/5.2/5.1 Scripts (for PtokaX 0.4.0.0 and newer) => Conversion Requests => Topic started by: ?[-?Genius?-]? on 27 February, 2008, 13:53:29

Title: convert
Post by: ?[-?Genius?-]? on 27 February, 2008, 13:53:29
Hi

Its possible convert this scripts for me plz?

Slot bot

--=[ Nome do Bot ]=-

botName = "[!???] ??vdRip?"
sOpChatName = "[!???] ?Op Cha??"


--=[ Comando ]=-
Command = "!slots"

--=[ Codigo ]=--

function getid(Table, name)
return table.foreachi(Table, function(id, item) if item.sName == name then return id end end)
end

function putitem(Table, item)
if not item then
return
end
local id = getid(Table, item.sName)
if id then
Table[id] = item
else
table.insert(Table, item)
id = Table.n
end
return id
end

function OnTimer()
local i = 1 while tabSlots[i] do
local Table = tabSlots[i]
if os.clock() >= Table.iClock + tmrSlots then
if Table.tItems.n == 0 then
SendPmToNick(Table.sName, botName, " ? N?o a mais users com slots livres no ??vdRip? ? |")
end
SendPmToNick(Table.sName, botName, " ? Feito ?|")
table.remove(tabSlots, i)
if tabSlots.n == 0 then
end
else i = i + 1
end
end
end

function doSlots(user, nr, nick)
user:SendPM(botName, " ? A procurar... ? |")
SendPmToOps(sOpChatName, " - = [  A enviar informa??o do comando !slots ao Utilizador  "..user.sName.."  ] =- ")
SendToAll("$Search Hub:"..Command.." T?F?0?1?.|")
putitem(tabSlots, { sName = user.sName, iClock = os.clock(), iNR = nr, tItems = {n=0} })
end


tmrSlots = 5

tabSlots = {n=0}

function ChatArrival(user, data)
if string.find(data, "%b<>%s+("..Command..").*|") then
s, e, nr = string.find(data, "%b<>%s+"..Command.."%s+([0-9]+)")
if s then
nr = tonumber(nr)
else
nr = 1
end
doSlots(user, nr)
return 1
end
end


function SRArrival(user, data)
local s, e, free, all = string.find(data, " (%d+)/(%d+)"..string.char(5))
table.foreachi(tabSlots, function(id, item)
if not getid(item.tItems, user.sName) then
putitem(item.tItems, { sName = user.sName, sValue = free.."/"..all })
if (tonumber(free) >= item.iNR) then
SendPmToNick(item.sName, botName, " ? User ? ? "..user.sName.." ? ? "..free.."/"..all.." ?|")
end
end end)
end

function Main()
frmHub:RegBot(botName)
SetTimer(tmrSlots*1000)
StartTimer()
end


slots hubs share

--=[ Nome do Bot ]=-

sBot= "--=( DvdRip )=--"

kb = 1024
mb = 1024 ^ 2
gb = 1024 ^ 3

--=[ Configura??o ]=-

MinShare = 5120*mb -- in MBs
MinSlots = 3
MaxSlots = 5
--[ MaxHubs = 10 ]--

--=[ User inumes ao Bot ]=-

tImmune = {  ["[SP]putnick"] = 1, ["[CV]dream[er]"] = 1, ["[NT]mmmm@work"] = 1, ["[VIP]HELDER-TUGA"] = 1, ["[NT]saburu"] = 1, ["[VDF]NKS"] = 1, ["[NT]SpyFakes"] = 1, ["[SP]reg"] = 1, ["[SP]C???????-x"] = 1, ["[SP]Guitas"] = 1, ["[NT]monika"] = 1, ["[NT]maryjoint"] = 1, ["[SP]Cypress"] = 1, ["[NV]Bills"] = 1,  ["[SP]Red"] = 1, ["[SP]estrela_cadente"] = 1, [""] = 1, ["[NT]Chucky"] = 1, ["[NT]Nitinha"] = 1, ["[NT]soniamartins"] = 1, ["[SP]user"] = 1, ["[SP]??ee?"] = 1, ["[SP]KillerIsDead"] = 1, ["![Hsrv]-diablo?"] = 1, ["[SP]Cyber_Cube?"] = 1, ["[SP]-?DiOsPiRo?-"] = 1, ["[SP]????????r??"] = 1, ["[SP]Nizi_Moon"] = 1, ["[NT]Algaman"] = 1, ["[SP]Nezinha"] = 1, ["[NT]zero-cool"] = 1, ["[SP]__MARS__"] = 1,} --##  -Operators Immune List (["nick"] = 1) ##--

--=[ C?digo ]=-

DoShareUnits = function(intSize)
if intSize ~= 0 then
local tUnits = { "Bytes", "KB", "MB", "GB", "TB" }
intSize = tonumber(intSize);
local sUnits;
for index = 1, table.getn(tUnits) do
if(intSize < 1024) then sUnits = tUnits[index]; break; else intSize = intSize / 1024; end
end
return string.format("%0.1f %s",intSize, sUnits);
else
return "nothing"
end
end

ConnectToMeArrival = function(curUser,data)
if not curUser.bOperator then
if not tImmune[curUser.sName] then
if curUser.iShareSize < MinShare then
return curUser:SendPM(sBot, "DvdRip:Hub. --=( Boas, tens pouca partilha. O minimo ? de [ "..DoShareUnits(MinShare).." ]. Abra o seu espirito de partilha, e d? mais algum contributo. At? l? ficar? impossibilitado de efectuar downloads. )=--  --=( DvdRip.sytes.net )=--"),1
elseif curUser.iSlots < MinSlots then
return curUser:SendPM(sBot, "DvdRip:Hub. --=( Boas, tens poucas slots abertas. O minimo ? de "..MinSlots.." slots. Abra 3 a 5 slots para puder efectuar downloads no Hub. )=--  --=( DvdRip.sytes.net )=--"),1
elseif curUser.iSlots > MaxSlots then
return curUser:SendPM(sBot, "DvdRip:Hub. --=( Boas, tens muitas slots abertas. O m?ximo ? de "..MaxSlots.." slots. Abra 3 a 5 slots para puder efectuar downloads no Hub. )=--  --=( DvdRip.sytes.net )=--"),1
--[ elseif (curUser.iNormalHubs + curUser.iRegHubs) > MaxHubs then ]--
--[ return curUser:SendPM(sBot, "DvdRip:Hub. --=( Boas, t?s ligado a demasiados Hubs. O limite maximo ? de "..MaxHubs..". Pf Desligue-se de alguns. At? l? fica impossibilitado de efectuar downloads. )=--  --=( DvdRip.sytes.net )=--"),1 ]--
end
end
end
end

RevConnectToMeArrival = ConnectToMeArrival


block CV downloads

--=[ Nome do Bot ]=-
sBot = "[!???] ??vdRip?"

--=[ Nome do OpChat ]=-
sOpChatName = "[!???] ?Op Cha??"


--=[ Configura??o ]=-

--=[ Insere aqui os prefixos ]=-

sPrefix = { "[CV]" ,}

--=[ Insere aqui as rangs dos users CV ]=-

arrIP = {
  ["10.6.0.0"] = "10.6.0.30",
  ["84.90.0.0"] = "84.91.255.255",      --  Cabovisao,SA
  ["213.228.128.0"] = "213.228.191.255",   --  Cabovisao,SA
  ["217.129.0.0"] = "217.129.255.255",      --  Cabovisao,SA
}

--=[ C?digo ]=-

function Main()
frmHub:RegBot(sBot)
end

function NewUserConnected(user)
if (CheckUserPrefix(user) == nil) and not (isGoodIP(user.sIP) == nil) then
user:SendPM(sBot, "\r\n \r\n                                ???? ?? ?? ?? ??? ??????? ?? ?? ?? ??? ??????? ?? ?? ?? ??? ??????? ?? ?? ?? ??? ??????? ?? ?? ?? ??? ??????? ?? ?? ?? ??? ???? \r\n                                                                      ?? ?? ? ?? v ?? d ?? R ?? i ?? P ?? ?? \r\n                                ???? ?? ?? ?? ??? ??????? ?? ?? ?? ??? ??????? ?? ?? ?? ??? ??????? ?? ?? ?? ??? ??????? ?? ?? ?? ??? ??????? ?? ?? ?? ??? ???? \r\n \r\n                                  Boas caro utilizador. \r\n                                  Vimos por este meio informar que foram postam novas regras em vigor no Hub. \r\n                                  Ter? que acrescentar o prefixo [CV] no seu nickname para puder efectuar  \r\n                                  downloads no Hub. \r\n \r\n                                  Ex: [CV]user \r\n \r\n                                  Estar? a perguntar a si mesmo porque temos tal regras no hub. Mas eu explico. \r\n                                  Todos sabemos que temos uns fornecedores de Internet [ ISP?s ] muito fatelas, \r\n                                  pagamos servi?os que n?o uzamos entre outras injusti?as. \r\n                                  No caso do Fornecedor SAPO Adsl ? bastante grave porque todos os downloads  \r\n                                  que eles fazem dos utilizadores CaboVis?o ou Telepac contam como internacional. \r\n                                  Dai existir tal regra. Se todos os Utilizadores usarem uma TAG a mencionar o \r\n                                  Fornecedor de Internet [ ISP ] que utiliza, os users podem gerir os seus  \r\n                                  downloads e tb ter certezas da fonte dos mesmos. \r\n                                  Esta regra ? para ser aplicada.  \r\n                                  Aviza-mos que quem n?o a cumprir ser? Banido do Hub. \r\n                                  Colabore. N?o custa nada!! \r\n \r\n                                  Bons  downloads \r\n \r\n                                ???? ?? ?? ?? ??? ??????? ?? ?? ?? ??? ??????? ?? ?? ?? ??? ??????? ?? ?? ?? ??? ??????? ?? ?? ?? ??? ??????? ?? ?? ?? ??? ???? \r\n                                                                      ?? ?? ? ?? v ?? d ?? R ?? i ?? P ?? ?? \r\n                                ???? ?? ?? ?? ??? ??????? ?? ?? ?? ??? ??????? ?? ?? ?? ??? ??????? ?? ?? ?? ??? ??????? ?? ?? ?? ??? ??????? ?? ?? ?? ??? ???? \r\n")
SendPmToOps(sOpChatName, " - = [  O utilizador  [ "..user.sName.." ]  com o Ip  [ "..user.sIP.." ]  foi requesitado a usar a TAG [CV]  ] = -")
end
end

OpConnected = NewUserConnected

function ConnectToMeArrival(user,data)
if (CheckUserPrefix(user) == nil) and (isGoodIP(user.sIP) ~= nil) then
user:SendData(sBot, "\r\n \r\n                                ???? ?? ?? ?? ??? ??????? ?? ?? ?? ??? ??????? ?? ?? ?? ??? ??????? ?? ?? ?? ??? ??????? ?? ?? ?? ??? ??????? ?? ?? ?? ??? ???? \r\n                                                                      ?? ?? ? ?? v ?? d ?? R ?? i ?? P ?? ?? \r\n                                ???? ?? ?? ?? ??? ??????? ?? ?? ?? ??? ??????? ?? ?? ?? ??? ??????? ?? ?? ?? ??? ??????? ?? ?? ?? ??? ??????? ?? ?? ?? ??? ???? \r\n \r\n                                  Boas caro utilizador. \r\n                                  Vimos por este meio informar que foram postam novas regras em vigor no Hub. \r\n                                  Ter? que acrescentar o prefixo [CV] no seu nickname para puder efectuar  \r\n                                  downloads no Hub. \r\n \r\n                                  Ex: [CV]user \r\n \r\n                                  Estar? a perguntar a si mesmo porque temos tal regras no hub. Mas eu explico. \r\n                                  Todos sabemos que temos uns fornecedores de Internet [ ISP?s ] muito fatelas, \r\n                                  pagamos servi?os que n?o uzamos entre outras injusti?as. \r\n                                  No caso do Fornecedor SAPO Adsl ? bastante grave porque todos os downloads  \r\n                                  que eles fazem dos utilizadores CaboVis?o ou Telepac contam como internacional. \r\n                                  Dai existir tal regra. Se todos os Utilizadores usarem uma TAG a mencionar o \r\n                                  Fornecedor de Internet [ ISP ] que utiliza, os users podem gerir os seus  \r\n                                  downloads e tb ter certezas da fonte dos mesmos. \r\n                                  Esta regra ? para ser aplicada.  \r\n                                  Aviza-mos que quem n?o a cumprir ser? Banido do Hub. \r\n                                  Colabore. N?o custa nada!! \r\n \r\n                                  Bons  downloads \r\n \r\n                                ???? ?? ?? ?? ??? ??????? ?? ?? ?? ??? ??????? ?? ?? ?? ??? ??????? ?? ?? ?? ??? ??????? ?? ?? ?? ??? ??????? ?? ?? ?? ??? ???? \r\n                                                                      ?? ?? ? ?? v ?? d ?? R ?? i ?? P ?? ?? \r\n                                ???? ?? ?? ?? ??? ??????? ?? ?? ?? ??? ??????? ?? ?? ?? ??? ??????? ?? ?? ?? ??? ??????? ?? ?? ?? ??? ??????? ?? ?? ?? ??? ???? \r\n")
return 1
end
end

RevConnectToMeArrival = ConnectToMeArrival

function CheckUserPrefix(user)
for key,pre in pairs(sPrefix) do
if string.find(string.lower(user.sName), string.lower(pre),1,1) then
return 1
end
end
end

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