PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: BeeR on 31 December, 2004, 17:10:22

Title: redirect bot
Post by: BeeR on 31 December, 2004, 17:10:22
I have an ide on a bot !!

A rd-bot that redirects users if they not get regged in the hub within time set by hubrunner (value = min)

a redirect reason like " you are now redirected because: U did not reg yourself in this hub !!
Title:
Post by: b_w_johan on 06 January, 2005, 16:33:16
i even have an better idea,

if youre not regged youre redirected,
(this part is for my network then)

so when a users is found which is not regged
we redirect him to a hub in this small database like thing

1GB{
jan.no-ip.
piet.no-ip.
}

5GB{
jeroen.no-ip
pietersen.no-ip
}

so if the user is not registerd hes redirected, but first share check to see which hub fits him

if you have an idea how to make this work please reply

if you have a part of this idea like checking in a file for minshare that also good now i have nothing so i get started
Title:
Post by: [UK]Madman on 06 January, 2005, 16:54:23
Slight ammendment on an old bot .. it would redirect randomly to a hub in the hubs table after a set period of time and several warnings.

Good idea about working on share size, will add that wen im not at work!


-- By [UK]Madman
-- References - Lua Language Board

var = {["bot"] = "RegToStayBot", ["time"] = 10, ["command"] = "?notreg"}, --time is in mins before redirect
times = {},
hubs =  { hubaddress1, hubaddress2} -- list of possible hubs


function Main()
frmHub:RegBot(var.bot)
SetTimer(60000*(tonumber(var.time)/4))
StartTimer()
end

function NewUserConnected(Curuser)

if Curuser.iProfile == -1 then
times[Curuser.sName] = var.time
Curuser:SendData (var.bot, "You have to register to stay in this hub, you currently have: "..var.time.." mins to register!")
end
end

function UserDisconnected (Curuser)
times[Curuser.sName] = Nil
end

function OnTimer()
for key, value in times do
value = value - (var.time/4)
times[key] = value

if value == 0 then tokick = GetItemByName(key)
times[tokick] = nil
tokick:SendData (var.bot, "You did not register, so are now being redirected!")
tohub = random(getn(hubs))
tokick:SendData("$ForceMove "..hubs[tohub])


elseif value == (var.time - tonumber(var.time)/2) then towarn = GetItemByName(key)
towarn:SendData (var.bot, "You have not registered, you will be redirected in: "..value.." mins unless you register!")
end
end

function DataArrival(Curuser,data)
data = strsub(data, 1, strlen(data)-1)
if strsub(data, 1, 1) == "<" then
s,e,cmd = strfind(data, "%b<>%s+(%S+)")

if cmd == var.command and Curuser.bOperator then
Curuser:SendPM (var.bot, "The following users are currently not regged:")
for key, value in times do
Curuser:SendPM (var.bot, key.." Has approx "..value.." mins till being redirected!")
end
return 1
end
end
end



Sorry if theres any errors, cant test it at work :o(
Title:
Post by: b_w_johan on 06 January, 2005, 17:14:42
thx [UK]Madman
im gonna test the script inmediatly
ill try to figure out that checking for share
and then redirect

Greetings Johan
Title:
Post by: BeeR on 06 January, 2005, 17:22:24
QuoteOriginally posted by b_w_johan
i even have an better idea,

if youre not regged youre redirected,
(this part is for my network then)

so when a users is found which is not regged
we redirect him to a hub in this small database like thing

1GB{
jan.no-ip.
piet.no-ip.
}

5GB{
jeroen.no-ip
pietersen.no-ip
}

so if the user is not registerd hes redirected, but first share check to see which hub fits him

if you have an idea how to make this work please reply

if you have a part of this idea like checking in a file for minshare that also good now i have nothing so i get started

i run now a private reghub and want to run it in my networks rd as a publichub - but still be a reghub,,
thats why i dont need more than my request
Title:
Post by: b_w_johan on 06 January, 2005, 20:10:21
well thats the script wich madman posted... that say register or youre redirected within x min...
but theres a problem ...
it didn't worked by my ... :'(
so i try to strip it down to redirect without registering so everyone who connects check for being registred not so by .. not that time period and register period... but script origionally didn't worked and i mest it up so now its still not working...

madman did it work by you before ???
you said can't test it cause im at work ..
so i guess you maded one before and based this to it ?

so now im trying to get it working like its now and strip away the time period madman if you got something like this wich does work please post it =-)


here are some errors
var = {["bot"] = "RegToStayBot", ["time"] = 10, ["command"] = "?notreg"}, --time is in mins before redirect
times = {},
hubs =  { hubaddress1, hubaddress2} -- list of possible hubs


like last read = on line 5 ...and if you want an adres like johan-hub.no-ip.info:666 it gives an error because of the port number ... :'(
Title:
Post by: [UK]Madman on 06 January, 2005, 20:23:14
Tested now and working ok

-- By [UK]Madman
-- References - Lua Language Board

var = {["bot"] = "RegToStayBot", ["time"] = 10, ["command"] = "?notreg"} --time is in mins before redirect
times = {}
hubs =  { "hub1.no-ip.com:500", "hub2.no-ip.com:500"} -- list of possible hubs

function Main()
frmHub:RegBot(var.bot)
SetTimer(60000*(tonumber(var.time)/4))
StartTimer()
end

function NewUserConnected(Curuser)
if Curuser.iProfile == -1 then
times[Curuser.sName] = var.time
Curuser:SendData (var.bot, "You have to register to stay in this hub, you currently have: "..var.time.." mins to register!")
end
end

function UserDisconnected (Curuser)
times[Curuser.sName] = Nil
end

function OnTimer()
for key, value in times do
value = value - (var.time/4)
times[key] = value

if value == 0 then tokick = GetItemByName(key)
times[tokick] = nil
tokick:SendData (var.bot, "You did not register, so are now being redirected!")
tohub = random(getn(hubs))
tokick:SendData("$ForceMove "..hubs[tohub])

elseif value == (var.time - tonumber(var.time)/2) then towarn = GetItemByName(key)
towarn:SendData (var.bot, "You have not registered, you will be redirected in: "..value.." mins unless you register!")
end
end
end


function DataArrival(Curuser,data)
data = strsub(data, 1, strlen(data)-1)
if strsub(data, 1, 1) == "<" then
s,e,cmd = strfind(data, "%b<>%s+(%S+)")
if cmd == var.command and Curuser.bOperator then
Curuser:SendPM (var.bot, "The following users are currently not regged:")
for key, value in times do
Curuser:SendPM (var.bot, key.." Has approx "..value.." mins till being redirected!")
end
return 1
end
end
end

At home now :oP and yes its based on an old bot that just disconnected after a set time, not re-directed.
Title:
Post by: b_w_johan on 06 January, 2005, 20:46:50
thx its working now =-')
now im gona make it look for sharesize dont now how but ill try to figure it out=-)
Title:
Post by: BeeR on 06 January, 2005, 21:01:02
Yes i can see that this bot do the thing i asked for ,,
 what i not want is the 2 hub addys to be typed - just
 a "get from hub rd" command ,, then i dont need to
 manually change the rd in bot when networks rd            is changed
Title:
Post by: [UK]Madman on 07 January, 2005, 12:07:55
To get the redirect address from the address set in the hub .. replace

tohub = random(getn(hubs))
tokick:SendData("$ForceMove "..hubs[tohub])


With....

tokick:SendData("$ForceMove "..frmHub:GetRedirectAddress())

you will also be able to remove the table

hubs =  { "hub1.no-ip.com:500", "hub2.no-ip.com:500"} -- list of possible hubs
Title:
Post by: b_w_johan on 09 January, 2005, 10:45:59
i liked this part:
hubs =  { "hub1.no-ip.com:500", "hub2.no-ip.com:500"} -- list of possible hubs

but now there's one thing i like to now is there a way to make that part in another file.

cause with guestbook you can add adresses to a txt file
and if that txt file is the random part then its easyer to add and remove hubs ...
cause some of he hubs in network where redirect is placed to some go offline at night and come online in the morning.

so if you can make it read from another file i can make an read remove thing...

thx Johan