PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: Requiem on 19 December, 2004, 03:25:18

Title: Nonstandard account checker bot
Post by: Requiem on 19 December, 2004, 03:25:18
Hi

I am using PtokaX DC Hub 0.3.2.6 TestDrive 4.99 with RoboCop v9.0e. I set min share limit for Regged to 20 Gb and for Users to 0 Gb. I use RoboCop's download blocker to force users share more and reg themselves to download. But in my network, I have to keep people with small sharings, even 1 GB sharers.. So I created some extra LowShare [LSx] accounts for them. These are the rules:

[LS1] >> min 1 GB up to 5 GB
[LS2] >> min 5 GB up to 10 GB
[LS3] >> min 10 GB up to 20 GB

Rules are working pretty fine. Everybody is happy but I am not. Cos I can't control their min and max share with a bot. Can somebody help me?

PtokaX profiles:
0|Master|11111110111111111111000000000000
1|Operator|11110100001001111111000000000000
2|VIP|10000000000001111000000000000000
3|Reg|10000000000000000000000000000000
4|Moderator|11111110011101111111000000000000
5|NetFounder|11111111111111111111000000000000
6|LS1|10000000000000000000000000000000
7|LS2|10000000000000000000000000000000
8|LS3|10000000000000000000000000000000

Title:
Post by: bastya_elvtars on 19 December, 2004, 03:58:57
Hi, here you go:

-- share check by profiles
-- by bastya_elvtars
-- for Requiem
-- feel free to include any profile index (not name!) - see profiles.dat


profiles_share={ -- [profileindex]=minshareingigabytes

[6]=10,

[7]=20,

[8]=30,

}

maxShare=2 -- in terabytes, to keep out some idiot fakeeeeeeeeeeeeers

todoforlowshare=1 -- 1 to disconnect, 2 to redirect

redir_addy="redirect.address.here"

-- do not edit below

function NewUserConnected(user)
checkshare(user)
end

function DataArrival(user,data)
if strsub(data, 1, 7) == "$MyINFO" then
checkshare(user)
end
end

checkshare=function(user)
local _,_,temp = strfind(user.sMyInfoString, "%$(%d+)%$")
local minshare=minShare*1024*1024*1024
local maxshare=maxShare*1024*1024*1024*1024
local Share = format("%0.2f", tonumber(temp)/gb)
if tonumber(temp) < minshare then
if todoforlowshare == 2 then
user:SendData("ShareCheck","You do not meet the share minimum ("..minShare.." GB)!")
user:SendData("RedirectBot","You are being redirected ... ")
user:SendData("$ForceMove "..redir_addy.."|")
elseif todoforlowshare==1 then
user:SendData("ShareCheck","You do not meet the share minimum, and are being disconnected ...")
user:Disconnect()
end
elseif tonumber(temp) > maxshare then
user:SendData("ShareCheck","Do you really think that i believe that you are sharing "..format("%0.2f", tonumber(temp)/(gb*1024)).." TBytes of data??? |")
user:Disconnect() return "shit"
end
end
Title: And one more request
Post by: Requiem on 19 December, 2004, 15:47:57
Thank you bastya_elvtars, as far as I see it works fine. May I request a script that can be used to register LSx accounts with commands just like !regreg or !regvip ? (I need !regls1 !regls2 !regl3 for sure)

This is all I need now cos I have to do all these from server soft and there are many LSx accounts.

Best regards.
Title:
Post by: bastya_elvtars on 19 December, 2004, 17:38:46
QuoteOriginally posted by Requiem
Thank you bastya_elvtars, as far as I see it works fine. May I request a script that can be used to register LSx accounts with commands just like !regreg or !regvip ? (I need !regls1 !regls2 !regl3 for sure)

This is all I need now cos I have to do all these from server soft and there are many LSx accounts.

Best regards.

sure, m8, but a bit later in the evening. You will be amazed! ;)
Title:
Post by: Requiem on 20 December, 2004, 02:39:12
Hi.

I need this script urgently (there are about 150-200 people waiting to be regged as LowShare and I am alone :( ). Can somebody else help me?
Title:
Post by: bastya_elvtars on 20 December, 2004, 03:10:31
Not tested. Please feedback!

-- share check & reg by profiles
-- by bastya_elvtars
-- for Requiem
-- use !command
-- feel free to include any profile index (not name!) - see profiles.dat


levels_height={ -- profile_index=strength_of_level
-- determines the power of levels. why? see below
-- you can also exclude ppl you dont want to be able to allow to reg
--master:

[0]=4,

-- op:

[1]=3,

-- moderator:

[4]=5,

-- netfounder:

[5]=6,

}

allowed_to_reg=3 -- minimum profile power (see above) for the ppl alowed to reg these folks - if you set Ops as 2, VIPs as 1,
-- and this value is 2, Ops can reg ppl, vips cannot.

profiles_share={ -- [profileindex]=minshareingigabytes

[6]=10,

[7]=20,

[8]=30,

}

profiles_cmd={ -- ["command"]=profile_index,

["!regls1"]=6,

["!regls2"]=7,

["regls3"]=8,
}



maxShare=2 -- in terabytes, to keep out some idiot fakeeeeeeeeeeeeers

todoforlowshare=1 -- 1 to disconnect, 2 to redirect

redir_addy="redirect.address.here"

-- do not edit below

profiles={}

function NewUserConnected(user)
checkshare(user)
end

function DataArrival(user,data)
if strsub(data, 1, 7) == "$MyINFO" then
if user.sMyInfoString and strlen (user.sMyInfoString) > (strlen(user.sName)+13) then
checkshare(user)
end
elseif strsub(data,1,1)=="<" then
data=strsub(data,1,strlen(data)-1)
local _,_,cmd = strfind(data,"%b<>%s+[%!%+%#](%S+)")
if cmd then
if profiles_cmd[cmd] then
regprof(user,data,profiles_cmd[cmd])
return 1
end
end
end
end

checkshare=function(user)
if profiles_share[user.iProfile] then
local _,_,temp = strfind(user.sMyInfoString, "%$(%d+)%$")
if not temp then user:SendData("ShareCheck","Your client is idiot."); user:Disconnect() return 1 end
local minshare=profiles_share[user.iProfile]*1024*1024*1024
local maxshare=maxShare*1024*1024*1024*1024
if tonumber(temp) < minshare then
if todoforlowshare == 2 then
user:SendData("ShareCheck","You do not meet the share minimum ("..minShare.." GB)!")
user:SendData("RedirectBot","You are being redirected ... ")
user:SendData("$ForceMove "..redir_addy.."|")
elseif todoforlowshare==1 then
user:SendData("ShareCheck","You do not meet the share minimum, and are being disconnected ...")
user:Disconnect()
end
elseif tonumber(temp) > maxshare then
user:SendData("ShareCheck","Do you really think that i believe that you are sharing "..format("%0.2f", tonumber(temp)/(gb*1024)).." TBytes of data??? |")
user:Disconnect() return "shit"
end
end
end

function loadusers()
local regusers={}
readfrom("../RegisteredUsers.dat")
while 1 do
local line = read()
if line == nil then
readfrom()
break
end
local _,_,name,levl = strfind(line,"(.+)|.+|(%d+)")
regusers[name]=tonumber(levl)

end
readfrom()
return regusers
end


function regprof(user,data,idx)
if levels_height[user.iProfile] and levels_height[user.iProfile]>=allowed_to_reg then
local regppl=loadusers()
local _,_,cmd,toreg,pw=strfind(data,"%b<>%s+(%S+)%s+(%S+)%s+(%S+)")
if toreg and pw then
if regppl[toreg] then
user:SendData("Reggabot","User is already regged as "..GetProfileName(regppl[toreg]).." !!! Do not waste my time!")
else
AddRegUser(toreg,pw,idx)
SendToNick(toreg," "..user.sName.." has regged you as "..GetProfileName(idx).." with password "..pw" . Edit your settings in Favourite Hubs and reconnect!")
SendToOps(" "..user.sName.." has regged "..toreg.." as "..GetProfileName(idx)".")
end
else
user:SendData("Reggabot","Bad usage! Correct usage: "..cmd.." ")
end
else
user:SendData("Reggabot","Not allowed to reg!")
end
end
Title:
Post by: Requiem on 20 December, 2004, 03:36:58
I get:

Syntax Error: table index is nil
Syntax Error: table index is nil
Syntax Error: table index is nil
Syntax Error: table index is nil
Syntax Error: table index is nil
Syntax Error: table index is nil
Syntax Error: attempt to perform arithmetic on global `minShare' (a nil value)
Syntax Error: attempt to perform arithmetic on global `minShare' (a nil value)
Syntax Error: table index is nil
Syntax Error: table index is nil
Syntax Error: table index is nil
Syntax Error: table index is nil
Syntax Error: table index is nil
Syntax Error: table index is nil
Syntax Error: table index is nil
Syntax Error: table index is nil
Syntax Error: table index is nil
Syntax Error: table index is nil
Syntax Error: attempt to perform arithmetic on global `minShare' (a nil value)
Syntax Error: attempt to perform arithmetic on global `minShare' (a nil value)


And also; commands don't work.
Title: And..
Post by: Requiem on 20 December, 2004, 03:57:12
I also noticed that I need some extra codes to check these extra profiles' slots. RoboCop neither PtokaX doesn't do that (PtokaX applies a global slot check but min slot value varies as to profiles in my hub)
Title:
Post by: bastya_elvtars on 20 December, 2004, 04:20:21
edited the script

slot check would be quite hard, maybe this is rather a robo update

also make sure you run this script after robo ie it is after the robo lua in alphab order
Title:
Post by: Requiem on 20 December, 2004, 04:49:02
Thank you. I will change this scripts name to ZZZ.lua and try but I must ask: May I translate and edit the script in my native language just as:

-- share check & reg by profiles
-- by bastya_elvtars
-- for Requiem
-- use !command
-- feel free to include any profile index (not name!) - see profiles.dat


levels_height={ -- profile_index=strength_of_level
-- determines the power of levels. why? see below
-- you can also exclude ppl you dont want to be able to allow to reg
--master:

[0]=4,

-- op:

[1]=3,

-- moderator:

[4]=5,

-- netfounder:

[5]=6,

}

allowed_to_reg=3 -- minimum profile power (see above) for the ppl alowed to reg these folks - if you set Ops as 2, VIPs as 1,
-- and this value is 2, Ops can reg ppl, vips cannot.

profiles_share={ -- [profileindex]=minshareingigabytes

--VIP icin
[2]=80,

--REG icin
[3]=20,

--LS1 icin
[6]=1,

--LS2 icin
[7]=5,

--LS3 icin
[8]=10,

}

profiles_cmd={ -- ["command"]=profile_index,

["!regls1"]=6,

["!regls2"]=7,

--I found out that here is ! missing, I added it. Is it wrong?

["!regls3"]=8,
}



maxShare=1 -- in terabytes, to keep out some idiot fakeeeeeeeeeeeeers

todoforlowshare=1 -- 1 to disconnect, 2 to redirect

redir_addy="127.0.0.1"

-- do not edit below

profiles={}

function NewUserConnected(user)
checkshare(user)
end

function DataArrival(user,data)
if strsub(data, 1, 7) == "$MyINFO" then
if user.sMyInfoString and strlen (user.sMyInfoString) > (strlen(user.sName)+13) then
checkshare(user)
end
elseif strsub(data,1,1)=="<" then
data=strsub(data,1,strlen(data)-1)
local _,_,cmd = strfind(data,"%b<>%s+[%!%+%#](%S+)")
if cmd then
if profiles_cmd[cmd] then
regprof(data,profiles_cmd[cmd])
return 1
end
end
end
end

checkshare=function(user)
local _,_,temp = strfind(user.sMyInfoString, "%$(%d+)%$")
local minshare=profiles_share[user.iProfile]*1024*1024*1024
local maxshare=maxShare*1024*1024*1024*1024
local Share = format("%0.2f", tonumber(temp)/gb)
if tonumber(temp) < minshare then
if todoforlowshare == 2 then
user:SendData("ShareCheck","Profiliniz i?in ?ng?r?len en az paylasim miktarini ("..minShare.." GB) karsilayamiyorsunuz.!")
user:SendData("RedirectBot","Yonlendirildiginiz adres: ")
user:SendData("$ForceMove "..redir_addy.."|")
elseif todoforlowshare==1 then
user:SendData("ShareCheck","Profiliniz i?in ?ng?r?len en az paylasim miktarini karsilayamiyorsunuz. Hub'la baglantiniz kesilecektir..")
user:Disconnect()
end
elseif tonumber(temp) > maxshare then
user:SendData("ShareCheck","Sence ger?ekten "..format("%0.2f", tonumber(temp)/(gb*1024)).." TByte paylastigina inaniyor muyum??? |")
user:Disconnect() return "shit"
end
end

function Main()
loadprofiles()
end


function loadprofiles()
readfrom("../Profiles.dat")
while 1 do
local line = read()
if line == nil then
readfrom()
break
end
local _,_,idx,name = strfind(line,"(.+)|(.+)|%d+")
profiles[tonumber(idx)]=name
end
readfrom()
end

function loadusers()
local regusers={}
readfrom("../RegisteredUsers.dat")
while 1 do
local line = read()
if line == nil then
readfrom()
break
end
local _,_,name,levl = strfind(line,"(.+)|.+|(%d+)")
regusers[name]=tonumber(levl)

end
readfrom()
return regusers
end


function regprof(user,data,idx)
if levels_height[user.iProfile] and levels_height[user.iProfile]>=allowed_to_reg then
local regppl=loadusers()
local _,_,cmd,toreg,pw=strfind(data,"%b<>%s+(%S+)%s+(%S+)%s+(%S+)")
if toreg and pw then
if regppl[toreg] then
user:SendData("Vadi-Guvenlik","Kullanici zaten "..GetProfileName(regppl[toreg]) olarak kaydedilmistir..." !!! Birbirimizi kandirmayalim...!")
else
AddRegUser(toreg,pw,idx)
SendToNick(toreg," "..user.sName.." tarafindan "..GetProfileName(idx).." olarak "..pw" sifresiyle kaydedildiniz. Lutfen Favorite Hubs'tan ayarlarinizi d?zeltip yeniden baglaniniz!")
SendToOps(" "..user.sName.." , "..toreg.." 'i "..GetProfileName(idx)" olarak kaydetmistir...")
end
else
user:SendData("Vadi-Guvenlik","Komut dizilimi hatali! Su sekilde kullanmalisiniz: "..cmd.." ")
end
else
user:SendData("Vadi-Guvenlik","Kullanici kayit etmek i?in yeterli yetkiniz yoktur. Uzgunum.")
end
end
Title:
Post by: Requiem on 20 December, 2004, 05:02:30
I have found that translating sux  :]  so decided to use the original script and got errors while trying to reg a LS3

No syntax errors in script file PtokaX\scripts\RoboCop.lua
No syntax errors in script file PtokaX\scripts\ZLSxBot.lua

Syntax Error: table index is nil
Syntax Error: table index is nil
Syntax Error: table index is nil
Syntax Error: table index is nil
Syntax Error: table index is nil
Syntax Error: table index is nil
Syntax Error: attempt to perform arithmetic on a nil value
Syntax Error: table index is nil
Syntax Error: table index is nil
Syntax Error: table index is nil
Syntax Error: table index is nil
Syntax Error: table index is nil
Syntax Error: table index is nil
Syntax Error: attempt to perform arithmetic on a nil value
Syntax Error: attempt to index local `user' (a string value)
Title:
Post by: bastya_elvtars on 20 December, 2004, 05:10:01
wahaaaaaaaaa im an idiot... updated again

sorry gotta go sleep test till then if erroneous maby somebody will fix

sorry i am really sleeeeeeeeeeeeeeepy now
Title:
Post by: Requiem on 20 December, 2004, 05:14:22
thank you for everything you have done. have a good sleep.
Title:
Post by: bastya_elvtars on 20 December, 2004, 12:34:24
ok woke up.

any errors?

:D
Title:
Post by: Requiem on 20 December, 2004, 14:04:11
Lots of errors like:

Syntax Error: table index is nil
Syntax Error: table index is nil
Syntax Error: attempt to perform arithmetic on a nil value
Syntax Error: table index is nil
Syntax Error: table index is nil
Syntax Error: table index is nil
Syntax Error: table index is nil
Syntax Error: attempt to perform arithmetic on a nil value
Title:
Post by: bastya_elvtars on 20 December, 2004, 18:40:13
when do they occur?
Title:
Post by: Requiem on 20 December, 2004, 20:31:23
whenever the script loads, I try to reg a profile, script sees a new user etc. Nearly whatever i do..
Title:
Post by: bastya_elvtars on 20 December, 2004, 21:05:27
ok probably fixed

altho tested on 15.25

edited the above
Title:
Post by: Requiem on 20 December, 2004, 22:22:36
Tested and still getting "Syntax Error: table index is nil" errors upon loading script and trying to use a !regls command. Would you like my whole hub soft to try it yourself?
Title:
Post by: bastya_elvtars on 21 December, 2004, 03:38:29
updated again

nothing happens on script restart: so debugging is easier and also optimized.
Title:
Post by: Requiem on 21 December, 2004, 09:23:40
Getting Syntax Error: table index is nil when trying to reg smo.
Title:
Post by: bastya_elvtars on 21 December, 2004, 12:56:22
QuoteOriginally posted by Requiem
Getting Syntax Error: table index is nil when trying to reg smo.

gonna look in the evening
Title:
Post by: kepp on 21 December, 2004, 13:08:37
To start with you're passing two variables
regprof(data,profiles_cmd[cmd])

function regprof(user,data,idx) <-- holds 3

so, user in regprof is the data you pass in DataArr
Also some checks wether.

Another thing to think of is the hash, etc:
Table = {[0] = 1,[1] = 4,[2] = 1}
PrintTable(4)

function PrintTable(Idx)
   print(Table[Idx]);
end

Can you notice the problem in this one?
Title:
Post by: Requiem on 21 December, 2004, 16:07:38
Kepp, can you tell me how to and where to use these codes? Will I add them to bastya_elvtars' script?
Title:
Post by: kepp on 21 December, 2004, 16:10:39
i gave bast a hint, thats all
Title:
Post by: bastya_elvtars on 22 December, 2004, 00:05:21
damn i should have slept in the last few days :)

altho strange i thought i fixed it

maybe i forgot something, even my black box is flushed now

-- share check & reg by profiles
-- by bastya_elvtars
-- for Requiem
-- use !command
-- feel free to include any profile index (not name!) - see profiles.dat


levels_height={ -- profile_index=strength_of_level
-- determines the power of levels. why? see below
-- you can also exclude ppl you dont want to be able to allow to reg
--master:

[0]=4,

-- op:

[1]=3,

-- moderator:

[4]=5,

-- netfounder:

[5]=6,

}

allowed_to_reg=3 -- minimum profile power (see above) for the ppl alowed to reg these folks - if you set Ops as 2, VIPs as 1,
-- and this value is 2, Ops can reg ppl, vips cannot.

profiles_share={ -- [profileindex]=minshareingigabytes

[6]=10,

[7]=20,

[8]=30,

}

profiles_cmd={ -- ["command"]=profile_index,

["!regls1"]=6,

["!regls2"]=7,

["regls3"]=8,
}



maxShare=2 -- in terabytes, to keep out some idiot fakeeeeeeeeeeeeers

todoforlowshare=1 -- 1 to disconnect, 2 to redirect

redir_addy="redirect.address.here"

-- do not edit below

profiles={}

function NewUserConnected(user)
checkshare(user)
end

function DataArrival(user,data)
if strsub(data, 1, 7) == "$MyINFO" then
if user.sMyInfoString and strlen (user.sMyInfoString) > (strlen(user.sName)+13) then
checkshare(user)
end
elseif strsub(data,1,1)=="<" then
data=strsub(data,1,strlen(data)-1)
local _,_,cmd = strfind(data,"%b<>%s+[%!%+%#](%S+)")
if cmd then
if profiles_cmd[cmd] then
regprof(user,data,profiles_cmd[cmd])
return 1
end
end
end
end

checkshare=function(user)
if profiles_share[user.iProfile] then
local _,_,temp = strfind(user.sMyInfoString, "%$(%d+)%$")
if not temp then user:SendData("ShareCheck","Your client is idiot."); user:Disconnect() return 1 end
local minshare=profiles_share[user.iProfile]*1024*1024*1024
local maxshare=maxShare*1024*1024*1024*1024
if tonumber(temp) < minshare then
if todoforlowshare == 2 then
user:SendData("ShareCheck","You do not meet the share minimum ("..minShare.." GB)!")
user:SendData("RedirectBot","You are being redirected ... ")
user:SendData("$ForceMove "..redir_addy.."|")
elseif todoforlowshare==1 then
user:SendData("ShareCheck","You do not meet the share minimum, and are being disconnected ...")
user:Disconnect()
end
elseif tonumber(temp) > maxshare then
user:SendData("ShareCheck","Do you really think that i believe that you are sharing "..format("%0.2f", tonumber(temp)/(gb*1024)).." TBytes of data??? |")
user:Disconnect() return "shit"
end
end
end

function loadusers()
local regusers={}
readfrom("../RegisteredUsers.dat")
while 1 do
local line = read()
if line == nil then
readfrom()
break
end
local _,_,name,levl = strfind(line,"(.+)|.+|(%d+)")
regusers[name]=tonumber(levl)

end
readfrom()
return regusers
end


function regprof(user,data,idx)
if levels_height[user.iProfile] and levels_height[user.iProfile]>=allowed_to_reg then
local regppl=loadusers()
local _,_,cmd,toreg,pw=strfind(data,"%b<>%s+(%S+)%s+(%S+)%s+(%S+)")
if toreg and pw then
if regppl[toreg] then
user:SendData("Reggabot","User is already regged as "..GetProfileName(regppl[toreg]).." !!! Do not waste my time!")
else
AddRegUser(toreg,pw,idx)
SendToNick(toreg," "..user.sName.." has regged you as "..GetProfileName(idx).." with password "..pw" . Edit your settings in Favourite Hubs and reconnect!")
SendToOps(" "..user.sName.." has regged "..toreg.." as "..GetProfileName(idx)".")
end
else
user:SendData("Reggabot","Bad usage! Correct usage: "..cmd.." ")
end
else
user:SendData("Reggabot","Not allowed to reg!")
end
end
Title: thank you
Post by: Requiem on 29 December, 2004, 20:22:52
havent been able to test it for days. thank you. works fine now.
Title:
Post by: bastya_elvtars on 29 December, 2004, 21:50:29
QuoteOriginally posted by Requiem
havent been able to test it for days. thank you. works fine now.

yw this was my xmas present 4 you  8)