PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: lazyj189 on 09 November, 2003, 00:59:27

Title: A different sort of redirect
Post by: lazyj189 on 09 November, 2003, 00:59:27
Is it possible to make a small script that changes the redirect address of the hub to other addresses that it like pulls from either inside the script or from a text file every amount of time that is specified by the hub owner?

So one minute it is set to hub a's address
another minute it chagnes to hub b's adress, and hub c's address , or even it can change hub address randomly.  The amount of time that it takes to change address can be defined from 1 second to whatever in minutes.
Title: redirect script
Post by: kbeh273300 on 09 November, 2003, 02:37:56
i have such a script

Bot = "-=T-G-T_REDIRBOT=-"
hubs = {"hub one,hubtwo,hub three"}

sec = 1000
min = 60 * sec
hour = 60 * min

index = nil

function Main()
frmHub:RegBot(Bot)
SetTimer(30*sec)
StartTimer()
end

function OnTimer()
index = next(hubs, index)
if not index then
index = next(hubs, index)
end
if hubs[index] then
frmHub:SetRedirectAddress(hubs[index])
else
frmHub:SetRedirectAll(0)
frmHub:SetRedirectFull(0)
end
end

function DataArrival(user, data)
if (strsub(data, 1, 1) == "<" ) and user.bOperator then
-- remove end pipe
data=strsub(data,1,strlen(data)-1)
--extract command
_,_,cmd=strfind(data, "%b<>%s+(%S+)")
--check if cmd exist
if not cmd then cmd = "0" end

if (strsub(cmd, 1, 1) ~= "!" ) then
return 0
else
cmd = strlower(cmd)
if cmd == "!addred" then
_,_,arg = strfind(data, "%b<>%s+%S+%s+(%S+)")
tinsert ( hubs, arg)
frmHub:SetRedirectFull(1)
user:SendData(Bot, arg.." has been added to the redirect list")
hubs["n"]=nil
elseif cmd == "!removered" then
local _,_,arg = strfind(data, "%b<>%s+%S+%s+(%S+)")
for i,v in hubs do
if v == arg then
tremove(hubs, i)
hubs["n"]=nil
user:SendData(Bot, v.." has been removed from the redirect list")
break
end
end
elseif cmd == "!clearred" then
frmHub:SetRedirectAll(0)
frmHub:SetRedirectFull(0)
hubs = {}
user:SendData(Bot, "All redirects has been removed")
elseif cmd == "!chredtimer" then
_,_,arg,time = strfind(data, "%b<>%s+%S+%s+(%S+)%s+(%S+)")
timer = strlower(time)
if timer == "sec" then
SetTimer(tonumber(arg)*sec)
elseif timer == "min" then
SetTimer(tonumber(arg)*min)
elseif timer == "hour" then
SetTimer(tonumber(arg)*hour)
end
user:SendData(Bot, "The interval between changing redaddress has been changed to once every "..arg.." "..time)
elseif cmd == "!getredhubs" then
local j = 0
for i,v in hubs do
j = j + 1
user:SendData(Bot, "Redirect address"..j.." is "..v.." "..i)
end
if j == 0 then
user:SendData(Bot, "There is no redirect hubs")
end
end
end
end
end
------------------------------------------------------------------
saveing lua

-=T-G-T=- network
Network Webpage: //www.t-g-t.nl
Network forum http://tgt.shows.it
Hub address: houseofkings.no-ip.org
hub webpage: http://houseofkings.no-ip.org
my lua forum http://lua.uknnet.com/
Title:
Post by: lazyj189 on 09 November, 2003, 02:54:25
Dude, that is just awesome.  Thanks alot for your help