local base = _G module("redirect") -- Rev: 1.0.3 base.require("luadchpp") local adchpp = base.luadchpp local autil = base.require('autil') 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://redirect.no-ip.info:411" -- Seconds you want the script to wait before the redirect (must be < the hubs logtimeout), 0 = redirect instantaneous. local Time = 10 -- 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 nmdc_t = {} local function nmdc_redirect(c) 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 local function nmdc_redirect_verify() for k, data in base.pairs(nmdc_t) do if data.victim:getState() == adchpp.Entity_STATE_PROTOCOL then rev = nmdc_redirect(data.victim) end nmdc_t[k] = nil end end add_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 and c:getState() == adchpp.Entity_STATE_PROTOCOL then if Time > 0 then nmdc_t[c:getSID()] = { victim = c } return end nmdc = nmdc_redirect(c) end end) rem_redirect_nmdc_to_adc = cm:signalDisconnected():connect(function(entity) local c = entity:asClient() if nmdc_t[c:getSID()] then nmdc_t[c:getSID()] = nil end end) nmdc_redirect_timer = sm:addTimedJob(Time * 1000, nmdc_redirect_verify) autil.on_unloading(_NAME, nmdc_redirect_timer)