-- Random Redirect bot (keeps changing the redirect after the chosen time) -- commands are !addred, !removered, !clearred, !chredtimer, !getredhubs. Bot = "Guardian" -- list of the hubs adresses to lett the bot chose from hubs = { "dhq-eurotopia.no-ip.com", "ehq-eurotopia.no-ip.com", "whq-eurotopia.no-ip.com", "dd-eurotopia1.no-ip.com" } 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 are no redirect hubs") end end end end end