local base = _G module("redirect") base.require("luadchpp") local adchpp = base.luadchpp local cm = adchpp.getCM() local sm = adchpp.getSM() -- WARNING !!!!!!!!!! This script can NOT be used on a ADCS hub without having the TIMER function enabled, there is no way to see if a connecting user is in secure mode or not in ADCH LUA so it would disconnect all adcs connection attempts. -- When the script does not use a timer the redirect is instantaneous, advantage is no extra timers creation or pending sockets, disadvantage is a litle tx band as you send the redirect to all users. -- Script needs ADCH++ (rev 504) or above. -- Settings: -- Fully ADC qualified hub address. local Redirect = "adcs://adc.test.net:411" -- Seconds you want the script to wait before the redirect (must be < the hubs logtimeout), 0 = redirect instantaneous. local Time = 4 -- Must be > 0 when hub has a secure server port !!!! -- Bot name used for the msg's. local Bot = "Redirect_Bot" -- Hubname as you want it's shown in the msg. local Hubname = "ADCH_Hub" -- Reason that you want to be send in PM to the redirected user, if "" no reason will be send. local Reason = "You should update your favorits for " .. Hubname .. " with the new address !" -- Array test NMDC to ADC(S) redirect local function nmdc_redirect(c) if c:getState() == adchpp.Entity_STATE_PROTOCOL then if #Reason > 0 then c:send(adchpp.Buffer_create("$To: Guest From: " .. Bot .. " $<<" .. Bot .. ">> You are being redirected to " .. Redirect .. " : " .. Reason .. "|")) end c:send(adchpp.Buffer_create("$ForceMove " .. Redirect .. "|\n")) end end redirect_nmdc_to_adc = cm:signalConnected():connect(function(entity) -- Sending a NMDC redirect to all connecting users after x time or instant. local c = entity:asClient() if c then if Time > 0 then nmdc_t = sm:addJob(Time * 1000, function() nmdc_redirect(c) end) return end nmdc = nmdc_redirect(c) end end)