is there someone who can convert this to lua5 because its not working with the new ptokax version =(
BotName = "-Yoda-"
kb = 1024
mb = kb*kb
gb = kb*kb*kb
redirect = {}
redirect[1] = {adress = "blabla1.myftp.org", minshare = 130*gb, maxhubs = 50, minslots = 0}
redirect[2] = {adress = "blabla2.myftp.org", minshare = 100*gb, maxhubs = 50, minslots = 0}
redirect[3] = {adress = "blabla3.myftp.org", minshare = 60*gb, maxhubs = 50, minslots = 0}
redirect[4] = {adress = "blabla4.myftp.org", minshare = 45*gb, maxhubs = 50, minslots = 0}
redirect[5] = {adress = "blabla5.myftp.org", minshare = 20*gb, maxhubs = 50, minslots = 0}
redirect[6] = {adress = "blabla6.myftp.org", minshare = 5*gb, maxhubs = 50, minslots = 0}
redirect["RedirectNMDC"] = "bla.mine.nu"
redirect["NetworkRedir"] = "blabla.mine.nu"
redirect["RedirectMLDC"] = "bla.mine.nu"
redirect["Notwanted"] = "bla.mine.nu"
sec = 1000
min = sec*60
h = min*60
tRedirectedusers = {}
function Main()
frmHub:RegBot(BotName)
SetTimer(15*min)
StartTimer()
end
function NewUserConnected(curUser)
if tRedirectedusers[curUser.sName] and tRedirectedusers[curUser.sName] >= 5 then
local RedirectAddress = redirect["Notwanted"]
curUser:SendData(BotName, "You have been redirected too many times and have therfore been redirected to: "..RedirectAddress)
curUser:SendData("$ForceMove "..RedirectAddress.."|")
curUser:TimeBan(30)
else
local p,d,tempdesc = strfind(curUser.sMyInfoString, "<%+%+ (%S*)>%$")
if not tempdesc then
if curUser.sIP == "127.0.0.1" then
return
elseif strfind(curUser.sMyInfoString, "mld",1,1) then
SendToOps(BotName , "*** MLDC REDIR: "..redirect["RedirectMLDC"].." User: "..curUser.sName)
curUser:SendData(BotName, "You are running mldc. Mldc isnt allowed, you are being redirected.")
curUser:SendData("$ForceMove "..redirect["RedirectMLDC"].."|")
tRedirectedusers[curUser.sName] = 5
curUser:TimeBan(1)
if curUser then
curUser:Disconnect()
end
return
else
local i,j,temp = strfind(curUser.sMyInfoString, "$(%d+)%$")
local tempshare = tonumber(temp)
if tempshare then
local Share = format("%0.2f", tempshare/gb)
SendToOps(BotName , "*** NMDC REDIR: "..redirect["RedirectNMDC"].." Share: "..Share.."Gb User "..curUser.sName)
else
local _,_,Share = strfind( curUser.sMyInfoString, "^%$MyINFO %$ALL [^ ]+ [^$]*%$ $[^$]+[^$]%$[^$]*%$%s*(%d+)%$" )
if Share then
Share = tonumber(Share)
if Share then
local Share = format("%0.2f", Share/gb)
SendToOps(BotName , "*** NMDC REDIR: "..redirect["RedirectNMDC"].." Share: "..Share.."Gb User "..curUser.sName)
else
SendToOps(BotName , "*** NMDC REDIR: "..redirect["RedirectNMDC"].." Share: *unknown* User "..curUser.sName)
end
else
SendToOps(BotName , "*** NMDC REDIR: "..redirect["RedirectNMDC"].." Share: *unknown* User "..curUser.sName)
end
end
curUser:SendData(BotName, "not running a dc++ client, you are being redirected to our NMDC hub.")
curUser:SendData("$ForceMove "..redirect["RedirectNMDC"].."|")
tRedirectedusers[curUser.sName] = 5
curUser:TimeBan(1)
return
end
end
local i,j,temp = strfind(curUser.sMyInfoString, "$(%d+)%$")
local tempshare = tonumber(temp)
if not tempshare then
SendToOps(BotName , "*** Notwanted REDIR: "..redirect["Notwanted"].." User: "..curUser.sName.." Because: couldn't decide the share size")
curUser:SendData(BotName, "Couldn't detect your share size so you are being redirected.")
curUser:SendData("$ForceMove "..redirect["Notwanted"].."|")
tRedirectedusers[curUser.sName] = 5
curUser:TimeBan(1)
return
end
-- V:0.25,M:A,H:1/1/1,S:5 ...
-- get nr of hubs
local p,d,th1,th2,th3 = strfind(tempdesc,"H:(%d+)/(%d+)/(%d+),")
local temphubs = 0
if p then
temphubs = tonumber(th1)+tonumber(th2)+tonumber(th3)
else
p,d,th = strfind(tempdesc,"H:(%d+)")
if p then
temphubs = tonumber(th)
else
SendToOps(BotName , "*** Notwanted REDIR: "..redirect["Notwanted"].." User: "..curUser.sName.." Because: couldn't decide how many hubs.")
curUser:SendData(BotName, "Couldn't detect how many hub you where visiting so you are being redirected.")
curUser:SendData("$ForceMove "..redirect["Notwanted"].."|")
tRedirectedusers[curUser.sName] = 5
curUser:TimeBan(1)
return
end
end
if temphubs == 0 then
SendToOps(BotName , "*** Notwanted REDIR: "..redirect["Notwanted"].." User: "..curUser.sName.." Because: couldn't decide how many hubs.")
curUser:SendData(BotName, "Couldn't detect how many hub you where visiting so you are being redirected.")
curUser:SendData("$ForceMove "..redirect["Notwanted"].."|")
tRedirectedusers[curUser.sName] = 5
curUser:TimeBan(1)
return
end
-- get nr of slots
local p,d,ts = strfind(tempdesc,"S:(%d+)")
local tempslots = 0
if p then
tempslots = tonumber(ts)
else
SendToOps(BotName , "*** Notwanted REDIR: "..redirect["Notwanted"].." User: "..curUser.sName.." Because: couldn't decide how many slots.")
curUser:SendData(BotName, "Couldn't detect how many slots you got so you are being redirected.")
curUser:SendData("$ForceMove "..redirect["Notwanted"].."|")
tRedirectedusers[curUser.sName] = 5
curUser:TimeBan(1)
return
end
if tempslots == 0 then
SendToOps(BotName , "*** Notwanted REDIR: "..redirect["Notwanted"].." User: "..curUser.sName.." Because: couldn't decide how many slots.")
curUser:SendData(BotName, "Couldn't detect how many slots you got so you are being redirected.")
curUser:SendData("$ForceMove "..redirect["Notwanted"].."|")
tRedirectedusers[curUser.sName] = 5
curUser:TimeBan(1)
return
end
local redirected = 0
local i = 1
local RedirectAddress = ""
while 1 do
if not redirect then
break
elseif tempshare >= redirect["minshare"] then
if temphubs <= redirect["maxhubs"] then
if temphubs*redirect["minslots"] <= tempslots then
RedirectAddress = redirect["adress"]
redirected = 1
break
end
end
end
i = i + 1
end
local Share = format("%0.2f", tonumber(tempshare)/gb)
if redirected == 0 then
curUser:SendData(BotName, "You are sharing "..Share.."Gb")
curUser:SendData(BotName, "You are in "..temphubs.." hubs")
curUser:SendData(BotName, "You have "..tempslots.." slots open")
curUser:SendData(BotName, "You do not meet the requirements in any of our hubs, redirecting to next network.")
curUser:SendData("$ForceMove "..redirect["NetworkRedir"].."|")
if tRedirectedusers[curUser.sName] then
tRedirectedusers[curUser.sName] = tRedirectedusers[curUser.sName] + 1
else
tRedirectedusers[curUser.sName] = 1
end
SendToOps(BotName , "*** NETWORKREDIR: "..redirect["NetworkRedir"].." Share: "..Share.."Gb Hubs:"..temphubs.." Slots:"..tempslots.." User: "..curUser.sName.." redirected: "..tRedirectedusers[curUser.sName].." times")
curUser:TimeBan(1)
else
curUser:SendData(BotName, "You are sharing "..Share.."Gb")
curUser:SendData(BotName, "You are in "..temphubs.." hubs")
curUser:SendData(BotName, "You have "..tempslots.." slots open")
curUser:SendData(BotName, "This means that you should be in hub "..RedirectAddress.." ... Redirecting.")
curUser:SendData("$ForceMove "..RedirectAddress.."|")
if tRedirectedusers[curUser.sName] then
tRedirectedusers[curUser.sName] = tRedirectedusers[curUser.sName] + 1
else
tRedirectedusers[curUser.sName] = 1
end
SendToOps(BotName , "*** REDIR: "..RedirectAddress.." Share: "..Share.."Gb Hubs:"..temphubs.." Slots:"..tempslots.." User: "..curUser.sName.." redirected: "..tRedirectedusers[curUser.sName].." times")
curUser:TimeBan(1)
end
end
end
function OnTimer()
tRedirectedusers = {}
end