PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: juda on 10 August, 2004, 15:09:41

Title: Please need warrning share bot!!!
Post by: juda on 10 August, 2004, 15:09:41
Hay!!!
I run hub with no share,and I wander,if anyone can do me a script.....
Something like this:
= When user connected with 0 GB share,is permited to stay on hub max. 24 hour.....[Wnen user connect BOT send PM: Hay!!! You are welcome in this hub,but you must fill your share in 24 hours [cca.500 MB],to stay connected on this hub....Thanks !!!]
= After 12 hours,BOT send warrning: Hay!!! Please put some files in your share.....You have 12 hours to do that !!!
= After 24 hours,if user not fill share,is disconnected.....[BOT send msg. in private:Your time to fill your share is run out....You are been disconnected]....
Something like that if it works.I need this script for my hub and I think,that every user must share some stufffffffff........ Bay fom SLOVENIJA
Title:
Post by: NightLitch on 10 August, 2004, 18:21:30
the amount of share every 12 hour does it matter what size the user downloads and share ?

I accept this challange.

/NL
Title: Finished !!
Post by: NightLitch on 10 August, 2004, 19:25:52
Here u go, I have tested it a little bit, so I hope it works after your needs...

--------------------------------------------------------
BotName = "-Share-Warning-" -- Set Botname

MinShareLimit = 500 -- Set Share Limit
MinShareUnit = MB -- Set Share Unit ( KB, MB, GB, TB )

NoShareTimeLimit = 24 -- Set Time Limit in hours for checking if share is more then 0 MB etc.
ShareUpdateTimeLimit = 12 -- Set Time Limit in hours for checking if share is updated after x hours
NoShareMessage = "You're welcome to stay in this hub, BUT you need to fill your Share with "..MinShareLimit.." MB within "..NoShareTimeLimit.." Hours to stay!"
--------------------------------------------------------
--// Code Starts Here \\--
--------------------------------------------------------
NoShare = {}
tTab = {n=0}

function Main()
SetTimer(TmrFreq)
StartTimer()
RegTimer(NoShareCheck, NoShareTimeLimit*Hour)
RegTimer(ShareUpdatedCheck, ShareUpdateTimeLimit*Hour)
end

function ShareUpdatedCheck()
for Nickname, Share in NoShare do
User = GetItemByName(Nickname)
if User then
SendToAll("User: "..User.sName.." is Found!")
local s,e,CurrentShare = strfind(User.sMyInfoString, "(%d+)%$%|$")
if tonumber(CurrentShare) <= tonumber(Share) then
SendToNick(Nickname, "<"..BotName.."> You haven't raised your share within "..ShareUpdateTimeLimit.." Hours and your share is still "..format("%.2f",Share/1024/1024).." MB !!")
SendToNick(Nickname, "<"..BotName.."> You are Disconnected!!")
User:Disconnect()
NoShare[Nickname] = nil
end
end
end
end

function NoShareCheck()
for Nickname, Share in NoShare do
if tonumber(Share) == 0 then
if GetItemByName(Nickname) then
SendToNick(Nickname, "<"..BotName.."> You have been online for "..NoShareTimeLimit.." Hours and your share is still "..format("%.2f",Share/1024/1024).." MB !!")
SendToNick(Nickname, "<"..BotName.."> You are Disconnected!!")
GetItemByName(Nickname):Disconnect()
NoShare[Nickname] = nil
end
end
end
end

function UserDisconnect(sUser)
NoShare[sUser.sName] = nil
end

function DataArrival(sUser,sData)
if strsub(sData, 1,7) == "$MyINFO" then
local s,e,sShare = strfind(sData, "(%d+)%$%|$")
NoShare[sUser.sName] = sShare
if tonumber(sShare) == 0 then
SendToNick(sUser.sName, "\r\n\t -------==[ NOTICE !! ]===================================================-------")
SendToNick(sUser.sName, "\r\n\t "..NoShareMessage)
SendToNick(sUser.sName, "\r\n\t -------===============================================================-------\r\n\r\n")
end
end
end

function OnTimer()
for i=1, getn(tTab) do
tTab[i].count = tTab[i].count + 1
if tTab[i].count > tTab[i].trig then
tTab[i].count=1
tTab[i]:func()
end
end
end

function RegTimer(f, Interval)
local tmpTrig = Interval / TmrFreq
assert(Interval >= TmrFreq , "RegTimer(): Please Adjust TmrFreq")
local Timer = {n=0}
Timer.func=f
Timer.trig=tmpTrig
Timer.count=1
tinsert(tTab, Timer)
end


Enjoy / NightLitch
Title:
Post by: Herodes on 11 August, 2004, 00:51:20
My take on the request ...

Again not tested enough ... I would be greatfull to have someone to point out any bugs ...
--- ShaveShare v1  on request by juda
--- by Herodes (early hours of 11/08 - 2004)
-------- -------- -------- -------- -------- -------- -------- --------
--- offers a way to handle under-the-share-limit users to enter your hub
--- it can disconnect/redirect/kick/tempban/ban after a certain configurable time...
--- Warns halfway to the timelimit ...
--- Informs about time left on each entry ...
--- adjustable required limit for the share.. (kb , mb , gb )
-------- -------- -------- -------- -------- -------- -------- --------
--- do not edit ... or if you do dont blame me ---
tUsers = {}
kb = 1024
mb = 1024 ^ 2
gb = 1024 ^ 3
minutes = 60
hours = 60 ^2
-------- -------- -------- -------- -------- -------- -------- --------

---  edit the following four lines as you wish  ---
-------- -------- -------- -------- -------- -------- -------- --------
wsBot = "ShaveShare" --- The name of the bot ... it is necessary ... don't include    s  p a c e s ...
wtime = 24 * hours --- this is the time in seconds. .. Feel free to use the #*hours to say in # hours ... and  #*minutes to say in # minutes .. :)
limitshare = 500 * mb --- this sets the share limit that needs to be reached by the user so that he doesnt get the action .. :) keep format ex: 5 *gb is 5GB ... and so on ..
TheAction = 1 --- this sets the action to take against these ppl .... ? 1 = disconnect , 2 = redirect , 3 = kick , 4 = tempban , 5 = ban ?
-------- -------- -------- -------- -------- -------- -------- --------
--- script starts ---
-------- -------- -------- -------- -------- -------- -------- --------
function Main()
frmHub:UnregBot(wsBot)
frmHub:RegBot(wsBot)
SetTimer(1000)
StartTimer()
warncount = 0
end

--- // --- Actions to do if a new user os connected ... inform him about the time he has left to fill up his share if it is below the limit defined by ' limitshare ' variable
function NewUserConnected(user)
if user.sMyInfoString then
_,_,share = strfind(user.sMyInfoString, "%$(%d+)%$")
if tonumber(share) < limitshare then
if tUsers[user.sName] == nil then
tUsers[user.sName] = 0
user:SendPM(wsBot, "Please make fill up your share to reach "..BytesPostFix(limitshare)..". Presently you are sharing "..BytesPostFix(tonumber(share))..".")
user:SendPM(wsBot, " - You have another "..DoTimeUnits(wtime).." left.")
else
user:SendPM(wsBot, "Please make fill up your share to reach "..BytesPostFix(limitshare)..". Presently you are sharing "..BytesPostFix(tonumber(share))..".")
user:SendPM(wsBot, " - You have another "..DoTimeUnits(wtime - tUsers[user.sName]).." left.")
end
end
end
end

--- // --- Doing stuff on Timer ... that is every second ... under certain conditions the users are going to be warned or have actions casted on them ...
function OnTimer()
for user, time in tUsers do
local usr = GetItemByName(user)
tUsers[user] = tUsers[user] + 1
if usr and usr.sMyInfoString then
_,_,share = strfind(usr.sMyInfoString, "%$(%d+)%$")
if tonumber(share) < limitshare then
if tUsers[user] >= (wtime) then
usr:SendPM(wsBot, "You didnt fill up your share to fulfill hub requirements.")
return Act(usr)
elseif ( tUsers[user] == floor(wtime/2) ) then
usr:SendPM(wsBot, "Please fill up ur share .. 1/2 warnings ... on the last warning you will get disconnected.")
usr:SendPM(wsBot, "- You have another "..DoTimeUnits(wtime - time).." left.")
end
else tUsers[usr.sName] = nil
end
end
end
collectgarbage()
flush()
end

--- // --- Transforming bytes Into KB, MB, GB, TB, PT and Returning the ideal (highest possible) Unit --- // ---
function BytesPostFix(intSize) --- Thanks to kepp and NotRambitWombat
if intSize ~= 0 then
local tUnits = { "Bytes", "KB", "MB", "GB", "TB" }
intSize = tonumber(intSize);
local sUnits;
for index = 1, getn(tUnits) do
if(intSize < 1024) then
sUnits = tUnits[index];
break;
else
intSize = intSize / 1024;
end
end
return format("%0.1f %s",intSize, sUnits);
else return "nothing"
end
end

--- // --- Performing action and also informing the user about it ... It is handled from the ' TheAction ' variable ....
function Act(user)
local tActions = {
[1] = function(user) user:SendPM(wsBot, "You will now be disconnected") user:Disconnect() end,
[2] = function(user) user:SendPM(wsBot, "You will now be redirected to "..frmHub:GetRedirectAddress()) user:SendData("$OpForceMove "..frmHub:GetRedirectAddress()) end,
[3] = function(user) user:SendPM(wsBot, "You are kicked") user:Kick() end,
[4] = function(user) user:SendPM(wsBot, "You are temporalily Banned") user:TempBan() end,
[5] = function(user) user:SendPM(wsBot, "You are permenantly Banned") user:Ban() end,
};
for i,v in tActions do
if i == TheAction then
tUsers[user.sName] = nil
return tActions[i](user)
end
end
tActions = nil
end


function DoTimeUnits(time)
local tTimes = {}
local time = time * 1000
if ( time >= 86400000 ) then
repeat
if tTimes[4] then
tTimes[4] = tTimes[4] + 1
else tTimes[4] = 1
end
time = time - 86400000
until time < 86400000
end

if ( time >= 3600000 ) then
repeat
if tTimes[3] then
tTimes[3] = tTimes[3] + 1
else tTimes[3] = 1
end
time = time - 3600000
until time < 3600000
end

if ( time >= 60000 ) then
repeat
if tTimes[2] then
tTimes[2] = tTimes[2] + 1
else tTimes[2] = 1
end
time = time - 60000
until time < 60000
end

if ( time >= 1000 ) then
repeat
if tTimes[1] then
tTimes[1] = tTimes[1] + 1
else tTimes[1] = 1
end
time = time - 1000
until time < 1000
end
local msg = ""
local tTimeUns = { "seconds", "minutes", "hours", "days"}
for i,v in tTimes do
msg = v.." "..tTimeUns[i].." "..msg
end
return msg
end
-------- -------- -------- -------- -------- -------- -------- --------
--- script ends ---
-------- -------- -------- -------- -------- -------- -------- --------
Title:
Post by: Herodes on 11 August, 2004, 14:08:17
update for the above script ...
found a way to adjust how many times the user will be warned before the action takes place ....
look at ' frequency ' variable in the editable part ...
--- ShaveShare v2 request by juda ( 10/08 - 2004 )
--- by Herodes ( early hours of 11/08 - 2004 )
-------- -------- -------- -------- -------- -------- -------- --------
--- offers a way to handle under-the-share-limit users to enter your hub
--- it can disconnect/redirect/kick/tempban/ban after a certain configurable time...
--- Warns halfway to the timelimit ...
--- --- ^ fixed in v 2 ... now it has a variable to say how many times to warn before disconnect
--- Informs about time left on each entry if the share limit isnt satisfied ...
--- adjustable required limit for the share.. (kb , mb , gb )
-------- -------- -------- -------- -------- -------- -------- --------
--- do not edit ... or if you do dont blame me ---
tUsers = {}
kb = 1024
mb = 1024 ^ 2
gb = 1024 ^ 3
minutes = 60
hours = 60 ^2
-------- -------- -------- -------- -------- -------- -------- --------
---  edit the following four lines as you wish  ---
-------- -------- -------- -------- -------- -------- -------- --------
wsBot = "ShaveShare" --- The name of the bot ... it is necessary ... don't include    s  p a c e s ...
wtime = 24 * hours --- this is the time in seconds. .. Feel free to use the #*hours to say in # hours ... and  #*minutes to say in # minutes .. :)
frequency = 4 --- this is the number of warnings the user is going to receive within the predifined time limit...
limitshare = 500 * mb --- this sets the share limit that needs to be reached by the user so that he doesnt get the action .. :) keep format ex: 5 *gb is 5GB ... and so on ..
TheAction = 1 --- this sets the action to take against these ppl .... ? 1 = disconnect , 2 = redirect , 3 = kick , 4 = tempban , 5 = ban ?
-------- -------- -------- -------- -------- -------- -------- --------
--- script starts ---
-------- -------- -------- -------- -------- -------- -------- --------
function Main()
frmHub:UnregBot(wsBot)
frmHub:RegBot(wsBot)
SetTimer(1000)
StartTimer()
bal = floor(wtime/frequency)
end

--- // --- Actions to do if a new user os connected ... inform him about the time he has left to fill up his share if it is below the limit defined by ' limitshare ' variable
function NewUserConnected(user)
if user.sMyInfoString then
_,_,share = strfind(user.sMyInfoString, "%$(%d+)%$")
if tonumber(share) < limitshare then
if tUsers[user.sName] == nil then
tUsers[user.sName] = {}
tUsers[user.sName][1] = 0
tUsers[user.sName][2] = 1
user:SendPM(wsBot, "Please make fill up your share to reach "..DoShareUnits(limitshare)..". Presently you are sharing "..DoShareUnits(tonumber(share))..".")
user:SendPM(wsBot, " - You have another "..DoTimeUnits(wtime).." left.")
else
user:SendPM(wsBot, "Please make fill up your share to reach "..DoShareUnits(limitshare)..". Presently you are sharing "..DoShareUnits(tonumber(share))..".")
user:SendPM(wsBot, " - You have another "..DoTimeUnits(wtime - tUsers[user.sName][1]).." left.")
end
end
end
end

--- // --- Doing stuff on Timer ... that is every second ... under certain conditions the users are going to be warned or have actions casted on them ...
function OnTimer()
for user, time in tUsers do
local usr = GetItemByName(user)
tUsers[user][1] = tUsers[user][1] + 1
SendToAll("before "..tUsers[user][2])
if usr and usr.sMyInfoString then
_,_,share = strfind(usr.sMyInfoString, "%$(%d+)%$")
if tonumber(share) < limitshare then
SendToAll("through before "..tUsers[user][2].." and "..bal*tUsers[user][2] )
if tUsers[user][1] >= (wtime) then
usr:SendPM(wsBot, "You didnt fill up your share to fulfill hub requirements.")
return Act(usr)
elseif ( tUsers[user][1] == bal*tUsers[user][2] ) then
tUsers[user][2] = tUsers[user][2] + 1
SendToAll("after "..tUsers[user][2])
usr:SendPM(wsBot, "Please fill up ur share ... "..(tUsers[user][2]-1).."/ "..frequency.." warnings ... on the last warning you will get disconnected.")
usr:SendPM(wsBot, "- You have another "..DoTimeUnits(wtime - tUsers[user][1]).." left.")
end
else tUsers[usr.sName] = nil
end
end
end
collectgarbage()
flush()
end


--- // --- Transforming bytes Into KB, MB, GB, TB, PT and Returning the ideal (highest possible) Unit --- // ---
function DoShareUnits(intSize) --- Thanks to kepp and NotRambitWombat
if intSize ~= 0 then
local tUnits = { "Bytes", "KB", "MB", "GB", "TB" }
intSize = tonumber(intSize);
local sUnits;
for index = 1, getn(tUnits) do
if(intSize < 1024) then
sUnits = tUnits[index];
break;
else
intSize = intSize / 1024;
end
end
return format("%0.1f %s",intSize, sUnits);
else return "nothing"
end
end

--- // --- Performing action and also informing the user about it ... It is handled from the ' TheAction ' variable ....
function Act(user)
local tActions = {
[1] = function(user) user:SendPM(wsBot, "You will now be disconnected") user:Disconnect() end,
[2] = function(user) user:SendPM(wsBot, "You will now be redirected to "..frmHub:GetRedirectAddress()) user:SendData("$OpForceMove "..frmHub:GetRedirectAddress()) end,
[3] = function(user) user:SendPM(wsBot, "You are kicked") user:Kick() end,
[4] = function(user) user:SendPM(wsBot, "You are temporalily Banned") user:TempBan() end,
[5] = function(user) user:SendPM(wsBot, "You are permenantly Banned") user:Ban() end,
};
for i,v in tActions do
if i == TheAction then
tUsers[user.sName] = nil
return tActions[i](user)
end
end
tActions = nil
end


function DoTimeUnits(time)
local tTimes = {}
local time = time * 1000
if ( time >= 86400000 ) then
repeat
if tTimes[4] then
tTimes[4] = tTimes[4] + 1
else tTimes[4] = 1
end
time = time - 86400000
until time < 86400000
end

if ( time >= 3600000 ) then
repeat
if tTimes[3] then
tTimes[3] = tTimes[3] + 1
else tTimes[3] = 1
end
time = time - 3600000
until time < 3600000
end

if ( time >= 60000 ) then
repeat
if tTimes[2] then
tTimes[2] = tTimes[2] + 1
else tTimes[2] = 1
end
time = time - 60000
until time < 60000
end

if ( time >= 1000 ) then
repeat
if tTimes[1] then
tTimes[1] = tTimes[1] + 1
else tTimes[1] = 1
end
time = time - 1000
until time < 1000
end
local msg = ""
local tTimeUns = { "seconds", "minutes", "hours", "days"}
for i,v in tTimes do
msg = v.." "..tTimeUns[i].." "..msg
end
return msg
end
-------- -------- -------- -------- -------- -------- -------- --------
--- script ends ---
-------- -------- -------- -------- -------- -------- -------- --------
Title: HAY NIGHTLITCH !!!
Post by: juda on 11 August, 2004, 15:23:24
HAY & thanks for fast replay !!!
You done good....I like your grafic,how is script shown in main.It is very nice and script show msg. when user connect.
When I start script,show Syntax error:

Syntax error: attempt to perform arithmetic on global `Hour' (a nil value)
stack traceback:
   1:  function `Main' at line 19 [file `... Files\PtokaX ver 330\scripts\Share-Warning.lua']

= I just change Bot name....Your concept of script is good,so please,update script and little request by me:
= Tray if you can set timer for hours and minutes.....
= When user connect,send warrning in PM......[I use a little long MOTD for hub and warrning is not very visible,because is shown on top of the screen.....]
            Keep good work & bye.........juda
Title: Herodes - great job !!!
Post by: juda on 11 August, 2004, 15:40:08
Hay & thanks.....
I tested your first script and working great.....
Tested myself and set share to 0 GB,and set time to 5 minutes.....
1.Warrning send to PM....[you have 5 minutes to......]good
2.After 2.5 minutes send another msg. in PM....[you have 2.5 minutes to.....]good
3.After 5 min. I `m history.......KICK...good
All working great.....I see that you already update first  script....VERY GOOD !!! And more options added...OK !!!
I will check your update today and see how script work !!! I think,this script will use many people,who have in hub 0 share.....See ya !!!
Title: QUESTIONS and more work!!!sorry
Post by: juda on 11 August, 2004, 16:17:22
== Little difficult to explain in english ==

Settings for share is 1 GB and time is 12 hours.[This  is settings that I use]

1.When user [xxxx] connect....Timer start.....and user is connected about 3 hours and than user go [disconnect] from the hub.....
2.When [xxxx] user come back into hub,will timer start again or remamber old time spend in the hub [3 hours].....This is important,becouse I have user who go and come back every 30 minutes.....It will be nice to remember time for every user.

IF YOU CAN ADD!!!

Whan user get 1 or 2 or 3 warnings,will be nice to also send PM to :
1. OPERATOR - juda-  = me - but just me [option to change nick]
2.Or send warrnings to main window....[to see warrnings all]
   BAY & thanks again......  yu rulz     juda
Title:
Post by: NightLitch on 11 August, 2004, 16:57:15
Here I missed a part... here u go:

--------------------------------------------------------
-- Share Warning - By: NightLitch - 2004/08/10
-- Request By: Juda
-- NOTE: NoShare Table is erased when Script is Restarted !!
--------------------------------------------------------
KB = 1024
MB = KB*KB
GB = KB*KB*KB
TB = KB*KB*KB*KB
Sec  = 1000
Min  = 60*Sec
Hour = 60*Min
TmrFreq = 1000
--------------------------------------------------------
--// Editable Part Start's Here \\--
--------------------------------------------------------
BotName = "-Share-Warning-" -- Set Botname

MinShareLimit = 500 -- Set Share Limit
MinShareUnit = MB -- Set Share Unit ( KB, MB, GB, TB )

NoShareTimeLimit = 24 -- Set Time Limit in hours for checking if share is more then 0 MB etc.
ShareUpdateTimeLimit = 12 -- Set Time Limit in hours for checking if share is updated after x hours
NoShareMessage = "You're welcome to stay in this hub, BUT you need to fill your Share with "..MinShareLimit.." MB within "..NoShareTimeLimit.." Hours to stay!"
--------------------------------------------------------
--// Code Starts Here \\--
--------------------------------------------------------
NoShare = {}
tTab = {n=0}

function Main()
SetTimer(TmrFreq)
StartTimer()
RegTimer(NoShareCheck, NoShareTimeLimit*Hour)
RegTimer(ShareUpdatedCheck, ShareUpdateTimeLimit*Hour)
end

function ShareUpdatedCheck()
for Nickname, Share in NoShare do
User = GetItemByName(Nickname)
if User then
SendToAll("User: "..User.sName.." is Found!")
local s,e,CurrentShare = strfind(User.sMyInfoString, "(%d+)%$%|$")
if tonumber(CurrentShare) <= tonumber(Share) then
SendToNick(Nickname, "<"..BotName.."> You haven't raised your share within "..ShareUpdateTimeLimit.." Hours and your share is still "..format("%.2f",Share/1024/1024).." MB !!")
SendToNick(Nickname, "<"..BotName.."> You are Disconnected!!")
User:Disconnect()
NoShare[Nickname] = nil
end
end
end
end

function NoShareCheck()
for Nickname, Share in NoShare do
if tonumber(Share) == 0 then
if GetItemByName(Nickname) then
SendToNick(Nickname, "<"..BotName.."> You have been online for "..NoShareTimeLimit.." Hours and your share is still "..format("%.2f",Share/1024/1024).." MB !!")
SendToNick(Nickname, "<"..BotName.."> You are Disconnected!!")
GetItemByName(Nickname):Disconnect()
NoShare[Nickname] = nil
end
end
end
end

function UserDisconnect(sUser)
NoShare[sUser.sName] = nil
end

function DataArrival(sUser,sData)
if strsub(sData, 1,7) == "$MyINFO" then
local s,e,sShare = strfind(sData, "(%d+)%$%|$")
NoShare[sUser.sName] = sShare
if tonumber(sShare) == 0 then
SendToNick(sUser.sName, "\r\n\t -------==[ NOTICE !! ]===================================================-------")
SendToNick(sUser.sName, "\r\n\t "..NoShareMessage)
SendToNick(sUser.sName, "\r\n\t -------===============================================================-------\r\n\r\n")
end
end
end

function OnTimer()
for i=1, getn(tTab) do
tTab[i].count = tTab[i].count + 1
if tTab[i].count > tTab[i].trig then
tTab[i].count=1
tTab[i]:func()
end
end
end

function RegTimer(f, Interval)
local tmpTrig = Interval / TmrFreq
assert(Interval >= TmrFreq , "RegTimer(): Please Adjust TmrFreq")
local Timer = {n=0}
Timer.func=f
Timer.trig=tmpTrig
Timer.count=1
tinsert(tTab, Timer)
end

/NL
Title:
Post by: Herodes on 11 August, 2004, 18:21:13
QuoteOriginally posted by juda
1.When user [xxxx] connect....Timer start.....and user is connected about 3 hours and than user go [disconnect] from the hub.....
2.When [xxxx] user come back into hub,will timer start again or remamber old time spend in the hub [3 hours].....This is important,becouse I have user who go and come back every 30 minutes.....It will be nice to remember time for every user.

It is there already in my script ..  
The user if he is still under the limit has his timer carrying on from where it left it ...


No problem with the request about sending to a nick about the warnings ... I 'll be back soon with a extended script ..

PS: I think NightLitch is doing a great job too ... keep it up King ...
Title: Hay !!! me again.....
Post by: juda on 11 August, 2004, 19:09:22
Yes,you two doing great job.....

TO HERODES:
1.Sorry,I test litle more and timer doing great....[user -x hours; -x minutes to fill share]....great
2.I test your second scripte [ShaveShare v2],but all doing fine....send  warrning in PM....bat in the main chat every 2 second is writen:

[before 1]
[trough before 1 and 21600]

This two lines is shown in main  every 2 sec. again and again... Any idea what goes wrong ???
          YO;YO  ciao and thanks..... Can I say more......goooood

TO NIGHTLITCH:
Now working good....[in SLOVENIJA we say "SVAKA ?AST" = "VERY GOOD"]
[I`m testing your script wright now,and set first timer to 2 hours and second to 1 hour....]
Will see how it work and take action......
I`ll update you,when I finish with my test.....[cca. 2 hours]
     Another compliment by me ............... thanks ---  juda
Title:
Post by: Herodes on 11 August, 2004, 19:19:18
another update ... sorry about the messages in main ...
I put them there so that I know what the list of the bot had .. :)

there you go man ... this one has a cmd and a nickname that can use it ...

presently the command is ' !noshare ' and the nick is ' Herodes '  you can edit as u wish ....

--- ShaveShare v3 request by judas ( 10/08 - 2004 )
--- by Herodes ( early hours of 11/08 - 2004 )
-------- -------- -------- -------- -------- -------- -------- --------
--- offers a way to handle under-the-share-limit users to enter your hub
--- it can disconnect/redirect/kick/tempban/ban after a certain configurable time...
--- Warns halfway to the timelimit ...
--- --- ^ fixed in v 2 ... now it has a variable to say how many times to warn before disconnect
--- Informs about time left on each entry if the share limit isnt satisfied ...
--- adjustable required limit for the share.. (kb , mb , gb )
--- Now there is a nick-to-send variable in place ... ( v 3 )
--- If you have that nick then use the command ' !noshare '
--- --- ^ ( Note : can change it to what you wish ...) to show a list of the ppl that are in the bots list ...
-------- -------- -------- -------- -------- -------- -------- --------
--- do not edit ... or if you do dont blame me ---
tUsers = {}
kb = 1024
mb = 1024 ^ 2
gb = 1024 ^ 3
minutes = 60
hours = 60 ^2
-------- -------- -------- -------- -------- -------- -------- --------
---  edit the following four lines as you wish  ---
-------- -------- -------- -------- -------- -------- -------- --------
wsBot = "ShaveShare" --- The name of the bot ... it is necessary ... don't include    s  p a c e s ...
TheCmd = "!noshare" --- The command for displaying the actual list of the ppl under the share limit ....
TheNick = "Herodes" --- Who is allowed to use the command above ...
wtime = 24 * hours --- this is the time in seconds. .. Feel free to use the #*hours to say in # hours ... and  #*minutes to say in # minutes .. :)
frequency = 4 --- this is the number of warnings the user is going to receive within the predifined time limit...
limitshare = 500 * mb --- this sets the share limit that needs to be reached by the user so that he doesnt get the action .. :) keep format ex: 5 *gb is 5GB ... and so on ..
TheAction = 1 --- this sets the action to take against these ppl .... ? 1 = disconnect , 2 = redirect , 3 = kick , 4 = tempban , 5 = ban ?
-------- -------- -------- -------- -------- -------- -------- --------
--- script starts ---
-------- -------- -------- -------- -------- -------- -------- --------
function Main()
frmHub:UnregBot(wsBot)
frmHub:RegBot(wsBot)
SetTimer(1000)
StartTimer()
bal = floor(wtime/frequency)
end

--- // --- Actions to do if a new user os connected ... inform him about the time he has left to fill up his share if it is below the limit defined by ' limitshare ' variable
function NewUserConnected(user)
if user.sMyInfoString then
_,_,share = strfind(user.sMyInfoString, "%$(%d+)%$")
if tonumber(share) < limitshare then
if tUsers[user.sName] == nil then
tUsers[user.sName] = {}
tUsers[user.sName][1] = 0
tUsers[user.sName][2] = 1
user:SendPM(wsBot, "Please make fill up your share to reach "..DoShareUnits(limitshare)..". Presently you are sharing "..DoShareUnits(tonumber(share))..".")
user:SendPM(wsBot, " - You have another "..DoTimeUnits(wtime).." left.")
else
user:SendPM(wsBot, "Please make fill up your share to reach "..DoShareUnits(limitshare)..". Presently you are sharing "..DoShareUnits(tonumber(share))..".")
user:SendPM(wsBot, " - You have another "..DoTimeUnits(wtime - tUsers[user.sName][1]).." left.")
end
end
end
end

--- // --- Doing stuff on Timer ... that is every second ... under certain conditions the users are going to be warned or have actions casted on them ...
function OnTimer()
for user, time in tUsers do
local usr = GetItemByName(user)
tUsers[user][1] = tUsers[user][1] + 1
if usr and usr.sMyInfoString then
_,_,share = strfind(usr.sMyInfoString, "%$(%d+)%$")
if tonumber(share) < limitshare then
if tUsers[user][1] >= (wtime) then
usr:SendPM(wsBot, "You didnt fill up your share to fulfill hub requirements.")
return Act(usr)
elseif ( tUsers[user][1] == bal*tUsers[user][2] ) then
tUsers[user][2] = tUsers[user][2] + 1
usr:SendPM(wsBot, "Please fill up ur share ... "..(tUsers[user][2]-1).."/ "..frequency.." warnings ... on the last warning you will get disconnected.")
usr:SendPM(wsBot, "- You have another "..DoTimeUnits(wtime - tUsers[user][1]).." left.")
end
else tUsers[usr.sName] = nil
end
end
end
collectgarbage()
flush()
end

function DataArrival(user, data)
if ( (user.sName == TheNick) and user.bOperator ) then
data = strsub(data,1,strlen(data)-1)
local s,e,cmd = strfind( data, "%b<>%s+(%S+)" )
if cmd == TheCmd then
local msg = "\r\n\t\t\t\t - ---==Users that are under the limit==--- -\r\n"
msg = msg..strrep(" -", 110).."\r\n"
for nick , time in tUsers do
if GetItemByName(nick) then
status = "online"
else status = "offline"
end
msg = msg.."\t - Nick : "..nick.."\t\t Time Left : "..DoTimeUnits(wtime - tUsers[nick][1]).."\t\t Warnings : "..(tUsers[nick][2]-1).."/ "..frequency.."\t\t Status : "..status.."\r\n"
end
msg = msg..strrep(" -", 110)
SendPmToNick(TheNick, wsBot, msg)
end
end
end
--- // --- Transforming bytes Into KB, MB, GB, TB, PT and Returning the ideal (highest possible) Unit --- // ---
function DoShareUnits(intSize) --- Thanks to kepp and NotRambitWombat
if intSize ~= 0 then
local tUnits = { "Bytes", "KB", "MB", "GB", "TB" }
intSize = tonumber(intSize);
local sUnits;
for index = 1, getn(tUnits) do
if(intSize < 1024) then
sUnits = tUnits[index];
break;
else
intSize = intSize / 1024;
end
end
return format("%0.1f %s",intSize, sUnits);
else return "nothing"
end
end

--- // --- Performing action and also informing the user about it ... It is handled from the ' TheAction ' variable ....
function Act(user)
local tActions = {
[1] = function(user) user:SendPM(wsBot, "You will now be disconnected") user:Disconnect() end,
[2] = function(user) user:SendPM(wsBot, "You will now be redirected to "..frmHub:GetRedirectAddress()) user:SendData("$OpForceMove "..frmHub:GetRedirectAddress()) end,
[3] = function(user) user:SendPM(wsBot, "You are kicked") user:Kick() end,
[4] = function(user) user:SendPM(wsBot, "You are temporalily Banned") user:TempBan() end,
[5] = function(user) user:SendPM(wsBot, "You are permenantly Banned") user:Ban() end,
};
for i,v in tActions do
if i == TheAction then
tUsers[user.sName] = nil
return tActions[i](user)
end
end
tActions = nil
end


function DoTimeUnits(time)
local tTimes = {}
local time = time * 1000
if ( time >= 86400000 ) then
repeat
if tTimes[4] then
tTimes[4] = tTimes[4] + 1
else tTimes[4] = 1
end
time = time - 86400000
until time < 86400000
end

if ( time >= 3600000 ) then
repeat
if tTimes[3] then
tTimes[3] = tTimes[3] + 1
else tTimes[3] = 1
end
time = time - 3600000
until time < 3600000
end

if ( time >= 60000 ) then
repeat
if tTimes[2] then
tTimes[2] = tTimes[2] + 1
else tTimes[2] = 1
end
time = time - 60000
until time < 60000
end

if ( time >= 1000 ) then
repeat
if tTimes[1] then
tTimes[1] = tTimes[1] + 1
else tTimes[1] = 1
end
time = time - 1000
until time < 1000
end
local msg = ""
local tTimeUns = { "seconds", "minutes", "hours", "days"}
for i,v in tTimes do
msg = v.." "..tTimeUns[i].." "..msg
end
return msg
end
-------- -------- -------- -------- -------- -------- -------- --------
--- script ends ---
-------- -------- -------- -------- -------- -------- -------- --------
If there are any more problems give another post me or Nightlitch will take care of it :D
Title: TO NIGHTLITCH !!!
Post by: juda on 11 August, 2004, 20:32:42
--------------------------------------------------------
--// Editable Part Start's Here \\--
--------------------------------------------------------
BotName = "-Share-Warning-"      -- Set Botname

MinShareLimit = 1    -- Set Share Limit
MinShareUnit = GB    -- Set Share Unit ( KB, MB, GB, TB )

NoShareTimeLimit = 2    -- Set Time Limit in hours for checking if share is more then 0 MB etc.
ShareUpdateTimeLimit = 1   -- Set Time Limit in hours for checking if share is updated after x hours
NoShareMessage = "You're welcome to stay in this hub, BUT you need to fill your Share with "..MinShareLimit.." MB within "..NoShareTimeLimit.." Hours to stay!"
--------------------------------------------------------
--// Code Starts Here \\--
--------------------------------------------------------
HAY again!!!
As I say,I test your second script,and I run for another problem.....This settings I use [look up]

 1. I connected at 19.14.......good
 2. than  first warrning come at 19.22....
 3. than second warrning come at 19.55.....
 4. at 20.14 I been disconnected.......

Is this correct ???
I think that must work like this:
- connect at 00.00
- first warrning at 01.00
- disconnected at 02.00
I dont know now anymore !!! Plese for replay......
    Script not have any other problem !!! For now !!! haaaa ........Be well----   juda
Title:
Post by: NightLitch on 11 August, 2004, 22:25:23
That was really strange... It works great for me... BUT! hehe...

lets say u put on the script at 13.00 hour and logs in 13.58 hour and after 1 hour you have the check then you will be checked at 14.00 hour even due u have only been online for 2 min.. hehe gonna see what I can do...

/NL
Title:
Post by: NightLitch on 11 August, 2004, 22:45:27
Here try this one, Have only tried a little bit, but I figure u got the time to w8 so test it a way:

--------------------------------------------------------
-- Share Warning - By: NightLitch - 2004/08/10
-- Request By: Juda
-- NOTE: NoShare Table is erased when Script is Restarted !!
-- Some Modification Done
--------------------------------------------------------
KB = 1024
MB = KB*KB
GB = KB*KB*KB
TB = KB*KB*KB*KB
Sec  = 1000
Min  = 60*Sec
Hour = 60*Min
TmrFreq = 1000
--------------------------------------------------------
--// Editable Part Start's Here \\--
--------------------------------------------------------
BotName = "-Share-Warning-" -- Set Botname

MinShareLimit = 500 -- Set Share Limit
MinShareUnit = MB -- Set Share Unit ( KB, MB, GB, TB )

NoShareTimeLimit = 24 -- Set Time Limit in hours for checking if share is more then 0 MB etc.
ShareUpdateTimeLimit = 12 -- Set Time Limit in hours for checking if share is updated after x hours
NoShareMessage = "You're welcome to stay in this hub, BUT you need to fill your Share with "..MinShareLimit.." MB within "..NoShareTimeLimit.." Hours to stay!"
--------------------------------------------------------
--// Code Starts Here \\--
--------------------------------------------------------
NoShare = {}
tTab = {n=0}

function Main()
SetTimer(TmrFreq)
StartTimer()
RegTimer(NoShareCheck, 1*Sec)
RegTimer(ShareUpdatedCheck, 1*Sec)
end

function ShareUpdatedCheck()
for Nickname, Table in NoShare do
User = GetItemByName(Nickname)
if User then
local _,_,h,m,s = strfind(Table[2], "(%d+):(%d+):(%d+)")
h = h + ShareUpdateTimeLimit
if h..":"..m..":"..s == date("%T") then
local _,_,CurrentShare = strfind(User.sMyInfoString, "(%d+)%$%|$")
if tonumber(CurrentShare) <= tonumber(Table[1]) then
SendToNick(Nickname, "<"..BotName.."> You haven't raised your share within "..ShareUpdateTimeLimit.." Hours and your share is still "..format("%.2f",Table[1]/1024/1024).." MB !!")
SendToNick(Nickname, "<"..BotName.."> You are Disconnected!!")
User:Disconnect()
NoShare[Nickname] = nil
end
end
end
end
end

function NoShareCheck()
for Nickname, Share in NoShare do
if tonumber(Share) == 0 then
User = GetItemByName(Nickname)
if User then
local _,_,h,m,s = strfind(Table[2], "(%d+):(%d+):(%d+)")
h = h + NoShareTimeLimit
if h..":"..m..":"..s == date("%T") then
SendToNick(Nickname, "<"..BotName.."> You have been online for "..NoShareTimeLimit.." Hours and your share is still "..format("%.2f",Share/1024/1024).." MB !!")
SendToNick(Nickname, "<"..BotName.."> You are Disconnected!!")
User:Disconnect()
NoShare[Nickname] = nil
end
end
end
end
end

function UserDisconnect(sUser)
NoShare[sUser.sName] = nil
end

function DataArrival(sUser,sData)
if strsub(sData, 1,7) == "$MyINFO" then
local s,e,sShare = strfind(sData, "(%d+)%$%|$")
NoShare[sUser.sName] = {sShare,date("%T")}
if tonumber(sShare) == 0 then
SendToNick(sUser.sName, "\r\n\t -------==[ NOTICE !! ]===================================================-------")
SendToNick(sUser.sName, "\r\n\t "..NoShareMessage)
SendToNick(sUser.sName, "\r\n\t -------===============================================================-------\r\n\r\n")
end
end
end

function OnTimer()
for i=1, getn(tTab) do
tTab[i].count = tTab[i].count + 1
if tTab[i].count > tTab[i].trig then
tTab[i].count=1
tTab[i]:func()
end
end
end

function RegTimer(f, Interval)
local tmpTrig = Interval / TmrFreq
assert(Interval >= TmrFreq , "RegTimer(): Please Adjust TmrFreq")
local Timer = {n=0}
Timer.func=f
Timer.trig=tmpTrig
Timer.count=1
tinsert(tTab, Timer)
end

/NL
Title:
Post by: NightLitch on 11 August, 2004, 22:53:13
Updated Version send in PM now:

--------------------------------------------------------
-- Share Warning - By: NightLitch - 2004/08/10
-- Request By: Juda
-- NOTE: NoShare Table is erased when Script is Restarted !!
-- Some Modification Done
-- Changed so it send in PM
--------------------------------------------------------
KB = 1024
MB = KB*KB
GB = KB*KB*KB
TB = KB*KB*KB*KB
Sec  = 1000
Min  = 60*Sec
Hour = 60*Min
TmrFreq = 1000
--------------------------------------------------------
--// Editable Part Start's Here \\--
--------------------------------------------------------
BotName = "-Share-Warning-" -- Set Botname

MinShareLimit = 500 -- Set Share Limit
MinShareUnit = MB -- Set Share Unit ( KB, MB, GB, TB )

NoShareTimeLimit = 24 -- Set Time Limit in hours for checking if share is more then 0 MB etc.
ShareUpdateTimeLimit = 12 -- Set Time Limit in hours for checking if share is updated after x hours
NoShareMessage = "You're welcome to stay in this hub, BUT you need to fill your Share with "..MinShareLimit.." MB within "..NoShareTimeLimit.." Hours to stay!"
--------------------------------------------------------
--// Code Starts Here \\--
--------------------------------------------------------
NoShare = {}
tTab = {n=0}

function Main()
frmHub:RegBot(BotName)
SetTimer(TmrFreq)
StartTimer()
RegTimer(NoShareCheck, 1*Sec)
RegTimer(ShareUpdatedCheck, 1*Sec)
end

function ShareUpdatedCheck()
for Nickname, Table in NoShare do
User = GetItemByName(Nickname)
if User then
local _,_,h,m,s = strfind(Table[2], "(%d+):(%d+):(%d+)")
h = h + ShareUpdateTimeLimit
if h..":"..m..":"..s == date("%T") then
local _,_,CurrentShare = strfind(User.sMyInfoString, "(%d+)%$%|$")
if tonumber(CurrentShare) <= tonumber(Table[1]) then
SendPmToNick(Nickname, BotName, "You haven't raised your share within "..ShareUpdateTimeLimit.." Hours and your share is still "..format("%.2f",Table[1]/1024/1024).." MB !!")
SendPmToNick(Nickname, BotName, "You are Disconnected!!")
User:Disconnect()
NoShare[Nickname] = nil
end
end
end
end
end

function NoShareCheck()
for Nickname, Share in NoShare do
if tonumber(Share) == 0 then
User = GetItemByName(Nickname)
if User then
local _,_,h,m,s = strfind(Table[2], "(%d+):(%d+):(%d+)")
h = h + NoShareTimeLimit
if h..":"..m..":"..s == date("%T") then
SendPmToNick(Nickname, BotName, "You have been online for "..NoShareTimeLimit.." Hours and your share is still "..format("%.2f",Share/1024/1024).." MB !!")
SendPmToNick(Nickname, BotName, "You are Disconnected!!")
User:Disconnect()
NoShare[Nickname] = nil
end
end
end
end
end

function UserDisconnect(sUser)
NoShare[sUser.sName] = nil
end

function DataArrival(sUser,sData)
if strsub(sData, 1,7) == "$MyINFO" then
local s,e,sShare = strfind(sData, "(%d+)%$%|$")
NoShare[sUser.sName] = {sShare,date("%T")}
if tonumber(sShare) == 0 then
SendPmToNick(sUser.sName, BotName, "\r\n\t -------==[ NOTICE !! ]===================================================-------")
SendPmToNick(sUser.sName, BotName, "\r\n\t "..NoShareMessage)
SendPmToNick(sUser.sName, BotName, "\r\n\t -------===============================================================-------\r\n\r\n")
end
end
end

function OnTimer()
for i=1, getn(tTab) do
tTab[i].count = tTab[i].count + 1
if tTab[i].count > tTab[i].trig then
tTab[i].count=1
tTab[i]:func()
end
end
end

function RegTimer(f, Interval)
local tmpTrig = Interval / TmrFreq
assert(Interval >= TmrFreq , "RegTimer(): Please Adjust TmrFreq")
local Timer = {n=0}
Timer.func=f
Timer.trig=tmpTrig
Timer.count=1
tinsert(tTab, Timer)
end

Enjoy / NL
Title: Hay NIGHTLITCH......
Post by: juda on 12 August, 2004, 10:33:18
I mark your versions like: Share-Warning v1 and second post v2;v3;v4 .....
In the last post - v4 - show syntax error:

Syntax error: `=' expected;
  last token read: `Version' at line 1 in file `C:\Program Files\PtokaX ver 330\scripts\Share-Warning v4.lua'

When I start hub,script wont even start....wont work
Plese for update and keep on doing good work !!!  

More update if you can....
1.Time is now in hours....please change timer to work in hours and minutes
2.Script I set to: NoShareTimeLimit = 24 hours ;ShareUpdateTimeLimit = 12 hours -
  When is user disconnected after 24 hours,and don`t fill share, even that,
  it will be nice to do,when user come back again,send PM:
    [Now is your second atempt to enter the hub with no share !!!!!!
      This time you have only 1 hour to put some files in,or you get PERMANENT BAN !!!!!!]...something like that


 Also if you can,put the [2] second update into HERODES script [ShaveShare v3]
    Nice of you to replay on my questions and updates....

 I try to write may own script,but brrrrrrrr....wont work [I`ll will keep on trying]
  So once again,you two must work very hard,I see you have a lot of other scripts....

                     SEE YA & thanks 100?  

                                                                          juda
Title:
Post by: Herodes on 12 August, 2004, 11:28:35
Sure that can be done but I have a question...

Do u want the script to remember the ppl that are coming back after the disconnect and still havent filled up their share or just screw that ?

PS: as you have noticed both the scripts we aremaking here by Nightlitch and me are "forgetting" after a script restart ...
Title:
Post by: Herodes on 12 August, 2004, 12:40:45
ok its done ... request added :)

--- ShaveShare v4 request by judas ( 10/08 - 2004 )
--- by Herodes ( early hours of 11/08 - 2004 )
-------- -------- -------- -------- -------- -------- -------- --------
--- offers a way to handle under-the-share-limit users to enter your hub
--- it can disconnect/redirect/kick/tempban/ban after a certain configurable time...
--- Warns halfway to the timelimit ...
--- --- ^ fixed in v 2 ... now it has a variable to say how many times to warn before disconnect
--- Informs about time left on each entry if the share limit isnt satisfied ...
--- adjustable required limit for the share.. (kb , mb , gb )
--- ---  v3 changes --- ---
--- Now there is a nick-to-send variable in place ... ( v 3 )
--- If you have that nick then use the command ' !noshare '
--- --- ^ ( Note : can change it to what you wish ...) to show a list of the ppl that are in the bots list ...
--- --- v4 changes --- ---
--- Now the users can enter again but the bot will remember them and act differently ( edit ' The2Action ' variable to change the behaviour ...)
--- You can also adjust the time for those ppl to be different than the ones that come for the first time. ... ( edit the ' w2time ' variable for that ...)
--- Edit the ' secfrequency ' variable to choose how many warnings these ppl will receive...
--- Made the messages of that the users receive aware of the action that is going to be taken if the requirments fail in the predifined time ....
--- I think it is fairly complete now ... if not give me a post ....
-------- -------- -------- -------- -------- -------- -------- --------
--- do not edit ... or if you do dont blame me ---
tUsers = {}
tMoreUsers = {}
tAgain = {}
kb = 1024
mb = 1024 ^ 2
gb = 1024 ^ 3
minutes = 60
hours = 60 ^2
-------- -------- -------- -------- -------- -------- -------- --------
--- edit the following 7 variables as you wish ---
-------- -------- -------- -------- -------- -------- -------- --------
wsBot = "ShaveShare" --- The name of the bot ... it is necessary ... don't include    s  p a c e s ...
TheCmd = "!noshare" --- The command for displaying the actual list of the ppl under the share limit ....
TheNick = "Herodes" --- Who is allowed to use the command above ...
wtime = 24 * hours --- this is the time in seconds. .. Feel free to use the #*hours to say in # hours ... and  #*minutes to say in # minutes .. :)
frequency = 4 --- this is the number of warnings the user is going to receive within the predifined time limit...
w2time = 3 * hours --- this is the time that a user entering with below share limit for the second time while have to fill up the requirement...
secfrequency = 2 --- this is how many times a user entering with below share limit for the second time is going to be warned in the time set by ' w2time ' variable...
limitshare = 500 * mb --- this sets the share limit that needs to be reached by the user so that he doesnt get the action .. :) keep format ex: 5 *gb is 5GB ... and so on ..
TheAction = 1 --- this sets the action to take against these ppl .... ? 1 = disconnect , 2 = redirect , 3 = kick , 4 = tempban , 5 = ban ?
The2Action = 5 --- this sets the action to take against the ppl that come back after they were given a first chance.... ? 1 = disconnect , 2 = redirect , 3 = kick , 4 = tempban , 5 = ban ?
-------- -------- -------- -------- -------- -------- -------- --------
--- script starts ---
-------- -------- -------- -------- -------- -------- -------- --------
function Main()
frmHub:UnregBot(wsBot)
frmHub:RegBot(wsBot)
SetTimer(1000)
StartTimer()
bal = floor(wtime/frequency)
bal2 = floor(w2time/secfrequency)
end

--- // --- Actions to do if a new user is connected ... inform him about the time he has left to fill up his share if it is below the limit defined by ' limitshare ' variable
function NewUserConnected(user)
if user.sMyInfoString then
_,_,share = strfind(user.sMyInfoString, "%$(%d+)%$")
if tonumber(share) < limitshare then
if tUsers[user.sName] == nil then
if tAgain[user.sName] == 1 then
tAgain[user.sName] = nil
tMoreUsers[user.sName] = {}
tMoreUsers[user.sName][1] = 0
tMoreUsers[user.sName][2] = 1
user:SendPM(wsBot, "You come without having the required share of "..DoShareUnits(limitshare).." Again ?.Presently you are sharing "..DoShareUnits(tonumber(share))..".")
user:SendPM(wsBot, "You now have just "..DoTimeUnits(w2time).." left to fill it up. If you dont you are getting "..DoStringActions(The2Action)..".")
else
tUsers[user.sName] = {}
tUsers[user.sName][1] = 0
tUsers[user.sName][2] = 1
user:SendPM(wsBot, "Please fill up your share to reach "..DoShareUnits(limitshare)..". Presently you are sharing "..DoShareUnits(tonumber(share))..".")
user:SendPM(wsBot, " - You have another "..DoTimeUnits(wtime).." left.")
end
else
if tMoreUsers[user.sName] then
user:SendPM(wsBot, "Fill up your share to reach "..DoShareUnits(limitshare)..". Presently you are sharing "..DoShareUnits(tonumber(share))..".")
user:SendPM(wsBot, " - You have another "..DoTimeUnits(w2time - tMoreUsers[user.sName][1]).." left.")
else
user:SendPM(wsBot, "Please fill up your share to reach "..DoShareUnits(limitshare)..". Presently you are sharing "..DoShareUnits(tonumber(share))..".")
user:SendPM(wsBot, " - You have another "..DoTimeUnits(wtime - tUsers[user.sName][1]).." left.")
end
end
end
end
end

--- // --- Doing stuff on Timer ... that is every second ... under certain conditions the users are going to be warned or have actions casted on them ...
function OnTimer()
for user, time in tUsers do
local usr = GetItemByName(user)
tUsers[user][1] = tUsers[user][1] + 1
if usr and usr.sMyInfoString then
_,_,share = strfind(usr.sMyInfoString, "%$(%d+)%$")
if tonumber(share) < limitshare then
if tUsers[user][1] >= (wtime) then
usr:SendPM(wsBot, "You didnt fill up your share to fulfill hub requirements.")
return Act(usr, TheAction)
elseif ( tUsers[user][1] == bal*tUsers[user][2] ) then
tUsers[user][2] = tUsers[user][2] + 1
usr:SendPM(wsBot, "Please fill up ur share ... "..(tUsers[user][2]-1).."/ "..frequency.." warnings ... on the last warning you will get "..DoStringActions(TheAction)..".")
usr:SendPM(wsBot, "- You have another "..DoTimeUnits(wtime - tUsers[user][1]).." left.")
end
else tUsers[usr.sName] = nil
end
end
end
for user, time in tMoreUsers do
local usr = GetItemByName(user)
tMoreUsers[user][1] = tMoreUsers[user][1] + 1
if usr and usr.sMyInfoString then
_,_,share = strfind(usr.sMyInfoString, "%$(%d+)%$")
if tonumber(share) < limitshare then
if tMoreUsers[user][1] >= (w2time) then
usr:SendPM(wsBot, "You didnt fill up your share to fulfill hub requirements.")
return Act(usr, The2Action)
elseif ( tMoreUsers[user][1] == bal2 * tMoreUsers[user][2] ) then
tMoreUsers[user][2] = tMoreUsers[user][2] + 1
usr:SendPM(wsBot, "Please fill up ur share ... "..(tMoreUsers[user][2]-1).."/ "..secfrequency.." warnings ... on the last warning you will get "..DoStringActions(The2Action)..".")
usr:SendPM(wsBot, "- You have another "..DoTimeUnits(w2time - tMoreUsers[user][1]).." left.")
end
else tMoreUsers[usr.sName] = nil
end
end
end
collectgarbage()
flush()
end

function DoStringActions(act)
local ret = ""
local tActionStr = {
[1] = "Disconnected",
[2] = "Redirected",
[3] = "Kicked",
[4] = "Temporalily Banned",
[5] = "Banned",
};
return tActionStr[act]
end
function DataArrival(user, data)
if ( (user.sName == TheNick) and user.bOperator ) then
data = strsub(data,1,strlen(data)-1)
local s,e,cmd = strfind( data, "%b<>%s+(%S+)" )
if cmd == TheCmd then
local msg = "\r\n\t\t\t\t - ---==Users that are under the limit==--- -\r\n"
msg = msg..strrep(" -", 110).."\r\n"
for nick , time in tUsers do
if GetItemByName(nick) then
status = "online"
else status = "offline"
end
msg = msg.."\t - Nick : "..nick.."\t\t Time Left : "..DoTimeUnits(wtime - tUsers[nick][1]).."\t\t Warnings : "..(tUsers[nick][2]-1).."/ "..frequency.."\t\t Status : "..status.."\r\n"
end
msg = msg..strrep(" -", 110)
SendPmToNick(TheNick, wsBot, msg)
end
end
end

--- // --- Transforming bytes Into KB, MB, GB, TB, PT and Returning the ideal (highest possible) Unit --- // ---
function DoShareUnits(intSize) --- Thanks to kepp and NotRambitWombat
if intSize ~= 0 then
local tUnits = { "Bytes", "KB", "MB", "GB", "TB" }
intSize = tonumber(intSize);
local sUnits;
for index = 1, getn(tUnits) do
if(intSize < 1024) then
sUnits = tUnits[index];
break;
else
intSize = intSize / 1024;
end
end
return format("%0.1f %s",intSize, sUnits);
else return "nothing"
end
end

--- // --- Performing action and also informing the user about it ... It is handled from the ' TheAction ' variable ....
function Act(user, var)
local tActions = {
[1] = function(user) user:SendPM(wsBot, "You will now be Disconnected") user:Disconnect() end,
[2] = function(user) user:SendPM(wsBot, "You will now be Redirected to "..frmHub:GetRedirectAddress()) user:SendData("$OpForceMove "..frmHub:GetRedirectAddress()) end,
[3] = function(user) user:SendPM(wsBot, "You will now be Kicked") user:Kick() end,
[4] = function(user) user:SendPM(wsBot, "You are temporalily Banned") user:TempBan() end,
[5] = function(user) user:SendPM(wsBot, "You are permenantly Banned") user:Ban() end,
};
for i,v in tActions do
if i == var then
tUsers[user.sName] = nil
if i ~=3 or i ~= 4 or i ~= 5 then
tAgain[user.sName] = 1
end
return tActions[i](user)
end
end
tActions = nil
end


function DoTimeUnits(time)
local tTimes = {}
local time = time * 1000
if ( time >= 86400000 ) then
repeat
if tTimes[4] then
tTimes[4] = tTimes[4] + 1
else tTimes[4] = 1
end
time = time - 86400000
until time < 86400000
end

if ( time >= 3600000 ) then
repeat
if tTimes[3] then
tTimes[3] = tTimes[3] + 1
else tTimes[3] = 1
end
time = time - 3600000
until time < 3600000
end

if ( time >= 60000 ) then
repeat
if tTimes[2] then
tTimes[2] = tTimes[2] + 1
else tTimes[2] = 1
end
time = time - 60000
until time < 60000
end

if ( time >= 1000 ) then
repeat
if tTimes[1] then
tTimes[1] = tTimes[1] + 1
else tTimes[1] = 1
end
time = time - 1000
until time < 1000
end
local msg = ""
local tTimeUns = { "seconds", "minutes", "hours", "days"}
for i,v in tTimes do
msg = v.." "..tTimeUns[i].." "..msg
end
return msg
end
-------- -------- -------- -------- -------- -------- -------- --------
--- script ends ---
-------- -------- -------- -------- -------- -------- -------- --------



It grew in a big script that one ... very functional I suppose .... If there are any errors let me know .
Title:
Post by: Herodes on 12 August, 2004, 14:44:48
The last ShaveShare (v4) didnt list the users that where entering the hub for the second time and had below-limit share ... now this one it is listing those as well ...
--- ShaveShare v4.1 request by judas ( 10/08 - 2004 )
--- by Herodes ( early hours of 11/08 - 2004 )
-------- -------- -------- -------- -------- -------- -------- --------
--- offers a way to handle under-the-share-limit users to enter your hub
--- it can disconnect/redirect/kick/tempban/ban after a certain configurable time...
--- Warns halfway to the timelimit ...
--- --- ^ fixed in v 2 ... now it has a variable to say how many times to warn before disconnect
--- Informs about time left on each entry if the share limit isnt satisfied ...
--- adjustable required limit for the share.. (kb , mb , gb )
--- ---  v3 changes --- ---
--- Now there is a nick-to-send variable in place ... ( v 3 )
--- If you have that nick then use the command ' !noshare '
--- --- ^ ( Note : can change it to what you wish ...) to show a list of the ppl that are in the bots list ...
--- --- v4 changes --- ---
--- Now the users can enter again but the bot will remember them and act differently ( edit ' The2Action ' variable to change the behaviour ...)
--- You can also adjust the time for those ppl to be different than the ones that come for the first time. ... ( edit the ' w2time ' variable for that ...)
--- Edit the ' secfrequency ' variable to choose how many warnings these ppl will receive...
--- Made the messages of that the users receive aware of the action that is going to be taken if the requirments fail in the predifined time ....
--- I think it is fairly complete now ... if not give me a post ....
--- --- v4.1 --- ---
--- displays both types of users in the list generated on the command
-------- -------- -------- -------- -------- -------- -------- --------
--- do not edit ... or if you do dont blame me ---
tUsers = {}
tMoreUsers = {}
tAgain = {}
kb = 1024
mb = 1024 ^ 2
gb = 1024 ^ 3
minutes = 60
hours = 60 ^2
-------- -------- -------- -------- -------- -------- -------- --------
--- edit the following 7 variables as you wish ---
-------- -------- -------- -------- -------- -------- -------- --------
wsBot = "ShaveShare" --- The name of the bot ... it is necessary ... don't include    s  p a c e s ...
TheCmd = "!noshare" --- The command for displaying the actual list of the ppl under the share limit ....
TheNick = "Herodes" --- Who is allowed to use the command above ...
wtime = 24 * hours --- this is the time in seconds. .. Feel free to use the #*hours to say in # hours ... and  #*minutes to say in # minutes .. :)
frequency = 4 --- this is the number of warnings the user is going to receive within the predifined time limit...
w2time = 3 * hours --- this is the time that a user entering with below share limit for the second time while have to fill up the requirement...
secfrequency = 2 --- this is how many times a user entering with below share limit for the second time is going to be warned in the time set by ' w2time ' variable...
limitshare = 500 * mb --- this sets the share limit that needs to be reached by the user so that he doesnt get the action .. :) keep format ex: 5 *gb is 5GB ... and so on ..
TheAction = 1 --- this sets the action to take against these ppl .... ? 1 = disconnect , 2 = redirect , 3 = kick , 4 = tempban , 5 = ban ?
The2Action = 5 --- this sets the action to take against the ppl that come back after they were given a first chance.... ? 1 = disconnect , 2 = redirect , 3 = kick , 4 = tempban , 5 = ban ?
-------- -------- -------- -------- -------- -------- -------- --------
--- script starts ---
-------- -------- -------- -------- -------- -------- -------- --------
function Main()
frmHub:UnregBot(wsBot)
frmHub:RegBot(wsBot)
SetTimer(1000)
StartTimer()
bal = floor(wtime/frequency)
bal2 = floor(w2time/secfrequency)
end

--- // --- Actions to do if a new user is connected ... inform him about the time he has left to fill up his share if it is below the limit defined by ' limitshare ' variable
function NewUserConnected(user)
if user.sMyInfoString then
_,_,share = strfind(user.sMyInfoString, "%$(%d+)%$")
if tonumber(share) < limitshare then
if tUsers[user.sName] == nil then
if tAgain[user.sName] == 1 then
tAgain[user.sName] = nil
tMoreUsers[user.sName] = {}
tMoreUsers[user.sName][1] = 0
tMoreUsers[user.sName][2] = 1
user:SendPM(wsBot, "You come without having the required share of "..DoShareUnits(limitshare).." Again ?.Presently you are sharing "..DoShareUnits(tonumber(share))..".")
user:SendPM(wsBot, "You now have just "..DoTimeUnits(w2time).." left to fill it up. If you dont you are getting "..DoStringActions(The2Action)..".")
else
tUsers[user.sName] = {}
tUsers[user.sName][1] = 0
tUsers[user.sName][2] = 1
user:SendPM(wsBot, "Please fill up your share to reach "..DoShareUnits(limitshare)..". Presently you are sharing "..DoShareUnits(tonumber(share))..".")
user:SendPM(wsBot, " - You have another "..DoTimeUnits(wtime).." left.")
end
else
if tMoreUsers[user.sName] then
user:SendPM(wsBot, "Fill up your share to reach "..DoShareUnits(limitshare)..". Presently you are sharing "..DoShareUnits(tonumber(share))..".")
user:SendPM(wsBot, " - You have another "..DoTimeUnits(w2time - tMoreUsers[user.sName][1]).." left.")
else
user:SendPM(wsBot, "Please fill up your share to reach "..DoShareUnits(limitshare)..". Presently you are sharing "..DoShareUnits(tonumber(share))..".")
user:SendPM(wsBot, " - You have another "..DoTimeUnits(wtime - tUsers[user.sName][1]).." left.")
end
end
end
end
end

--- // --- Doing stuff on Timer ... that is every second ... under certain conditions the users are going to be warned or have actions casted on them ...
function OnTimer()
for user, time in tUsers do
local usr = GetItemByName(user)
tUsers[user][1] = tUsers[user][1] + 1
if usr and usr.sMyInfoString then
_,_,share = strfind(usr.sMyInfoString, "%$(%d+)%$")
if tonumber(share) < limitshare then
if tUsers[user][1] >= (wtime) then
usr:SendPM(wsBot, "You didnt fill up your share to fulfill hub requirements.")
return Act(usr, TheAction)
elseif ( tUsers[user][1] == bal*tUsers[user][2] ) then
tUsers[user][2] = tUsers[user][2] + 1
usr:SendPM(wsBot, "Please fill up ur share ... "..(tUsers[user][2]-1).."/ "..frequency.." warnings ... on the last warning you will get "..DoStringActions(TheAction)..".")
usr:SendPM(wsBot, "- You have another "..DoTimeUnits(wtime - tUsers[user][1]).." left.")
end
else tUsers[usr.sName] = nil
end
end
end
for user, time in tMoreUsers do
local usr = GetItemByName(user)
tMoreUsers[user][1] = tMoreUsers[user][1] + 1
if usr and usr.sMyInfoString then
_,_,share = strfind(usr.sMyInfoString, "%$(%d+)%$")
if tonumber(share) < limitshare then
if tMoreUsers[user][1] >= (w2time) then
usr:SendPM(wsBot, "You didnt fill up your share to fulfill hub requirements.")
return Act(usr, The2Action)
elseif ( tMoreUsers[user][1] == bal2 * tMoreUsers[user][2] ) then
tMoreUsers[user][2] = tMoreUsers[user][2] + 1
usr:SendPM(wsBot, "Please fill up ur share ... "..(tMoreUsers[user][2]-1).."/ "..secfrequency.." warnings ... on the last warning you will get "..DoStringActions(The2Action)..".")
usr:SendPM(wsBot, "- You have another "..DoTimeUnits(w2time - tMoreUsers[user][1]).." left.")
end
else tMoreUsers[usr.sName] = nil
end
end
end
collectgarbage()
flush()
end

function DoStringActions(act)
local ret = ""
local tActionStr = {
[1] = "Disconnected",
[2] = "Redirected",
[3] = "Kicked",
[4] = "Temporalily Banned",
[5] = "Banned",
};
return tActionStr[act]
end


function DataArrival(user, data)
if ( (user.sName == TheNick) and user.bOperator ) then
data = strsub(data,1,strlen(data)-1)
local s,e,cmd = strfind( data, "%b<>%s+(%S+)" )
if cmd == TheCmd then
local msg = "\r\n\t\t\t\t - ---==Users that are under the limit==--- -\r\n"
msg = msg..strrep(" -", 110).."\r\n"
msg = msg.."\t The following users are going to be "..DoStringActions(TheAction).." after their period of grace is over( initialy set to"..DoTimeUnits(wtime)..")\r\n"
msg = msg..strrep(" -", 110).."\r\n"
for nick , time in tUsers do
if GetItemByName(nick) then
status = "online"
else status = "offline"
end
msg = msg.."\t - Nick : "..nick.."\t\t Time Left : "..DoTimeUnits(wtime - tUsers[nick][1]).."\t\t Warnings : "..(tUsers[nick][2]-1).."/ "..frequency.."\t\t Status : "..status.."\r\n"
end
msg = msg..strrep(" -", 110).."\r\n\r\n"
msg = msg..strrep(" -", 110).."\r\n"
msg = msg.."\t The following users are going to be "..DoStringActions(The2Action).." after their period of grace is over ( initialy set to"..DoTimeUnits(w2time)..")\r\n"
msg = msg..strrep(" -", 110).."\r\n"
for nick , time in tMoreUsers do
if GetItemByName(nick) then
status = "online"
else status = "offline"
end
msg = msg.."\t - Nick : "..nick.."\t\t Time Left : "..DoTimeUnits(w2time - tMoreUsers[nick][1]).."\t\t Warnings : "..(tMoreUsers[nick][2]-1).."/ "..secfrequency.."\t\t Status : "..status.."\r\n"
end
msg = msg..strrep(" -", 110)
SendPmToNick(TheNick, wsBot, msg)
end
end
end

--- // --- Transforming bytes Into KB, MB, GB, TB, PT and Returning the ideal (highest possible) Unit --- // ---
function DoShareUnits(intSize) --- Thanks to kepp and NotRambitWombat
if intSize ~= 0 then
local tUnits = { "Bytes", "KB", "MB", "GB", "TB" }
intSize = tonumber(intSize);
local sUnits;
for index = 1, getn(tUnits) do
if(intSize < 1024) then
sUnits = tUnits[index];
break;
else
intSize = intSize / 1024;
end
end
return format("%0.1f %s",intSize, sUnits);
else return "nothing"
end
end

--- // --- Performing action and also informing the user about it ... It is handled from the ' TheAction ' variable ....
function Act(user, var)
local tActions = {
[1] = function(user) user:SendPM(wsBot, "You will now be Disconnected") user:Disconnect() end,
[2] = function(user) user:SendPM(wsBot, "You will now be Redirected to "..frmHub:GetRedirectAddress()) user:SendData("$OpForceMove "..frmHub:GetRedirectAddress()) end,
[3] = function(user) user:SendPM(wsBot, "You will now be Kicked") user:Kick() end,
[4] = function(user) user:SendPM(wsBot, "You are temporalily Banned") user:TempBan() end,
[5] = function(user) user:SendPM(wsBot, "You are permenantly Banned") user:Ban() end,
};
for i,v in tActions do
if i == var then
tUsers[user.sName] = nil
if i ~=3 or i ~= 4 or i ~= 5 then
tAgain[user.sName] = 1
end
return tActions[i](user)
end
end
tActions = nil
end


function DoTimeUnits(time)
local tTimes = {}
local time = time * 1000
if ( time >= 86400000 ) then
repeat
if tTimes[4] then
tTimes[4] = tTimes[4] + 1
else tTimes[4] = 1
end
time = time - 86400000
until time < 86400000
end

if ( time >= 3600000 ) then
repeat
if tTimes[3] then
tTimes[3] = tTimes[3] + 1
else tTimes[3] = 1
end
time = time - 3600000
until time < 3600000
end

if ( time >= 60000 ) then
repeat
if tTimes[2] then
tTimes[2] = tTimes[2] + 1
else tTimes[2] = 1
end
time = time - 60000
until time < 60000
end

if ( time >= 1000 ) then
repeat
if tTimes[1] then
tTimes[1] = tTimes[1] + 1
else tTimes[1] = 1
end
time = time - 1000
until time < 1000
end
local msg = ""
local tTimeUns = { "seconds", "minutes", "hours", "days"}
for i,v in tTimes do
msg = v.." "..tTimeUns[i].." "..msg
end
return msg
end
-------- -------- -------- -------- -------- -------- -------- --------
--- script ends ---
-------- -------- -------- -------- -------- -------- -------- --------
Title:
Post by: NightLitch on 12 August, 2004, 14:49:54
I let u handle this Herodes... Yours seem to be better then mine... I did not put to much effort in mine though  :D

Cheers / NL
Title: good idea
Post by: EXNET OWNER on 12 August, 2004, 14:50:21
its a real good idea but what if you want a share limit of 10 gig, r u gonna giv them a week to get the share? or are you going to let them off lightly and let them bk everytime they get kicked

couldnt you make a deal with them so the script is set to that user for a certain time length for them individually??? sounds hard, would b ten times more better, some ppl hav 56k some hav 5600k lol see my point :S
Title:
Post by: Herodes on 12 August, 2004, 14:55:41
QuoteOriginally posted by EXNET OWNER
couldnt you make a deal with them so the script is set to that user for a certain time length for them individually??? sounds hard, would b ten times more better, some ppl hav 56k some hav 5600k lol see my point :S


hm ... I am not sure about what you mean .... can u provide some example of such case and how it might be handled ?

Inputs are more than welcome ... allthough the script is reaching the allowed post length .. loly :)
Title:
Post by: Herodes on 12 August, 2004, 14:57:07
QuoteOriginally posted by NightLitch
I let u handle this Herodes... Yours seem to be better then mine... I did not put to much effort in mine though  :D

Cheers / NL
Thanks man, I thought that I started getting on your nerves for hijacking the thread ... luckily you didn't get angry :D
Title: hmmm
Post by: EXNET OWNER on 12 August, 2004, 15:00:08
i may sound a little stupid now...

i mean if a user agrees with the op for example, that he will have his share increased in 3 hours, the time is only set to him....if you know wot i mean...

say i say to herodes, what connection are you on, then give him a length of time to increse it

command e.g

!sharewarn 56k

then it sets the time for a 56k user to make it a bit fairer as a T1 user would get the share quicker than a 56k modem ;)
Title:
Post by: Herodes on 12 August, 2004, 15:06:18
Shit I think Nightlitch went off just in time ... this is a hard one ... Nightlitch or anyone else is this possible in any way ?

I will trying thinking of how that would be possible Exnet ...

In the meantime try to make it follow a pattern of some sort ...
 mabey if u say Modems have 24 hours and T1 have 4 ? would that help ?
Title: yes it would but...
Post by: EXNET OWNER on 12 August, 2004, 15:11:26
yeah sure but!

wot if the user lies about their connection?

Hmmm maybe i shouldnt have bothrd but its good to try and improve scripts.

by the way i need a GUI specialist to make me a gui for my Bot Description Script, which is currently unnamed
any help anyone?
Title: Question on set share
Post by: [G-T-E]Gate? on 12 August, 2004, 16:28:04
Been reading this thread and think the idea is good,
 I have a question,
If I have my min users share set to 15Gb and I set this section to the following>>

limitshare = 2 * gb    --- this sets the share limit that needs to be reached by the user so that he doesnt get the action .. :) keep format ex: 5 *gb is 5GB ... and so on ..

will the script check to see if the user has added 2Gb to his share when he returns?

Excuse My ignorinse

G8
Title: U great job !!! Script rulez,as I expected.....
Post by: juda on 12 August, 2004, 16:42:53
HAY !!!
Another great idea EXNET OWNER,will see how it works....

Herodes !? sorry,but another error display again...
                   It is just like on v.3  - script wont start. Shown:

Syntax error: `=' expected;
                          last token read: `v4' at line 1 in file `C:\Program Files\PtokaX ver 330\scripts\ShaveShare v4.1.lua'

First reactions on script !!!
From yesterday I run version [ShaveShare v3.lua];[time:12 hour];[min.share 1 GB]
When I today get back from work,I check limit list "!noshare"...and suprise ?!?!
I have already 37 users in the limit list.....very good
Than I go check to my hub and I be suprised again....now is connected 6 users who fill his share after warning [all 6 users have 0 gb share when connected]....great
And more of this users will come back,but tonight.True the day I have on the hub cca.100-120 users,but after 18.00 hours peak groves to 150-180 users.....
SCRIPT DO JOB VERY WELL !!!
    If you want to see my time list,just tell me in the next post and I`ll send the list....[you see how is shown and check for any mistake...]
Want to send,but the time list is very big......or send anyway......[you say]
[P.S.]
I`m very happy how script working and growes....Already using this script my friend for his hub.....He say all the best !!!!!!!!

This is from me.......for now !!!! I`be watching you all !!! ha,ha,ha.....just joke

[All script I test on second hub - get quick look how script work !!!]    ciao  -   juda
Title:
Post by: 6Marilyn6Manson6 on 12 August, 2004, 16:59:24
This is the ShaveShare v4.1 correct:

--- ShaveShare v4.1 request by judas ( 10/08 - 2004 )
--- by Herodes ( early hours of 11/08 - 2004 )
-------- -------- -------- -------- -------- -------- -------- --------
--- offers a way to handle under-the-share-limit users to enter your hub
--- it can disconnect/redirect/kick/tempban/ban after a certain configurable time...
--- Warns halfway to the timelimit ...
--- --- ^ fixed in v 2 ... now it has a variable to say how many times to warn before disconnect
--- Informs about time left on each entry if the share limit isnt satisfied ...
--- adjustable required limit for the share.. (kb , mb , gb )
--- ---  v3 changes --- ---
--- Now there is a nick-to-send variable in place ... ( v 3 )
--- If you have that nick then use the command ' !noshare '
--- --- ^ ( Note : can change it to what you wish ...) to show a list of the ppl that are in the bots list ...
--- --- v4 changes --- ---
--- Now the users can enter again but the bot will remember them and act differently ( edit ' The2Action ' variable to change the behaviour ...)
--- You can also adjust the time for those ppl to be different than the ones that come for the first time. ... ( edit the ' w2time ' variable for that ...)
--- Edit the ' secfrequency ' variable to choose how many warnings these ppl will receive...
--- Made the messages of that the users receive aware of the action that is going to be taken if the requirments fail in the predifined time ....
--- I think it is fairly complete now ... if not give me a post ....
--- --- v4.1 --- ---
--- displays both types of users in the list generated on the command
--- ShaveShare v4.1 request by judas ( 10/08 - 2004 ) correct by 6Marilyn6Manson6
-------- -------- -------- -------- -------- -------- -------- --------
--- do not edit ... or if you do dont blame me ---
tUsers = {}
tMoreUsers = {}
tAgain = {}
kb = 1024
mb = 1024 ^ 2
gb = 1024 ^ 3
minutes = 60
hours = 60 ^2
-------- -------- -------- -------- -------- -------- -------- --------
--- edit the following 7 variables as you wish ---
-------- -------- -------- -------- -------- -------- -------- --------
wsBot = "ShaveShare"    --- The name of the bot ... it is necessary ... don't include    s  p a c e s ...
TheCmd = "!noshare"    --- The command for displaying the actual list of the ppl under the share limit ....
TheNick = "Herodes"    --- Who is allowed to use the command above ...
wtime = 24 * hours       --- this is the time in seconds. .. Feel free to use the #*hours to say in # hours ... and  #*minutes to say in # minutes .. :)
frequency = 4          --- this is the number of warnings the user is going to receive within the predifined time limit...
w2time = 3 * hours      --- this is the time that a user entering with below share limit for the second time while have to fill up the requirement...
secfrequency = 2      --- this is how many times a user entering with below share limit for the second time is going to be warned in the time set by ' w2time ' variable...
limitshare = 500 * mb    --- this sets the share limit that needs to be reached by the user so that he doesnt get the action .. :) keep format ex: 5 *gb is 5GB ... and so on ..
TheAction = 1          --- this sets the action to take against these ppl .... ? 1 = disconnect , 2 = redirect , 3 = kick , 4 = tempban , 5 = ban ?
The2Action = 5          --- this sets the action to take against the ppl that come back after they were given a first chance.... ? 1 = disconnect , 2 = redirect , 3 = kick , 4 = tempban , 5 = ban ?
-------- -------- -------- -------- -------- -------- -------- --------
         --- script starts ---
-------- -------- -------- -------- -------- -------- -------- --------
function Main()
   frmHub:UnregBot(wsBot)
   frmHub:RegBot(wsBot)
   SetTimer(1000)
   StartTimer()
   bal = floor(wtime/frequency)
   bal2 = floor(w2time/secfrequency)
end

--- // --- Actions to do if a new user is connected ... inform him about the time he has left to fill up his share if it is below the limit defined by ' limitshare ' variable
function NewUserConnected(user)
   if user.sMyInfoString then
      _,_,share = strfind(user.sMyInfoString, "%$(%d+)%$")
      if tonumber(share) < limitshare then
         if tUsers[user.sName] == nil then
            if tAgain[user.sName] == 1 then
               tAgain[user.sName] = nil
               tMoreUsers[user.sName] = {}
               tMoreUsers[user.sName][1] = 0
               tMoreUsers[user.sName][2] = 1
               user:SendPM(wsBot, "You come without having the required share of "..DoShareUnits(limitshare).." Again ?.Presently you are sharing "..DoShareUnits(tonumber(share))..".")
               user:SendPM(wsBot, "You now have just "..DoTimeUnits(w2time).." left to fill it up. If you dont you are getting "..DoStringActions(The2Action)..".")
            else
            tUsers[user.sName] = {}
            tUsers[user.sName][1] = 0
            tUsers[user.sName][2] = 1
            user:SendPM(wsBot, "Please fill up your share to reach "..DoShareUnits(limitshare)..". Presently you are sharing "..DoShareUnits(tonumber(share))..".")
            user:SendPM(wsBot, " - You have another "..DoTimeUnits(wtime).." left.")
            end
         else
            if tMoreUsers[user.sName] then
               user:SendPM(wsBot, "Fill up your share to reach "..DoShareUnits(limitshare)..". Presently you are sharing "..DoShareUnits(tonumber(share))..".")
               user:SendPM(wsBot, " - You have another "..DoTimeUnits(w2time - tMoreUsers[user.sName][1]).." left.")
            else   
               user:SendPM(wsBot, "Please fill up your share to reach "..DoShareUnits(limitshare)..". Presently you are sharing "..DoShareUnits(tonumber(share))..".")
               user:SendPM(wsBot, " - You have another "..DoTimeUnits(wtime - tUsers[user.sName][1]).." left.")
            end
         end
      end
   end
end

--- // --- Doing stuff on Timer ... that is every second ... under certain conditions the users are going to be warned or have actions casted on them ...
function OnTimer()
   for user, time in tUsers do
      local usr = GetItemByName(user)
      tUsers[user][1] = tUsers[user][1] + 1
      if usr and usr.sMyInfoString then
         _,_,share = strfind(usr.sMyInfoString, "%$(%d+)%$")
         if tonumber(share) < limitshare then
            if tUsers[user][1] >= (wtime) then
                  usr:SendPM(wsBot, "You didnt fill up your share to fulfill hub requirements.")
                  return Act(usr, TheAction)
            elseif ( tUsers[user][1] == bal*tUsers[user][2] ) then
               tUsers[user][2] = tUsers[user][2] + 1
               usr:SendPM(wsBot, "Please fill up ur share ... "..(tUsers[user][2]-1).."/ "..frequency.." warnings ... on the last warning you will get "..DoStringActions(TheAction)..".")
               usr:SendPM(wsBot, "- You have another "..DoTimeUnits(wtime - tUsers[user][1]).." left.")
            end
         else tUsers[usr.sName] = nil
         end
      end
   end
   for user, time in tMoreUsers do
      local usr = GetItemByName(user)
      tMoreUsers[user][1] = tMoreUsers[user][1] + 1
      if usr and usr.sMyInfoString then
         _,_,share = strfind(usr.sMyInfoString, "%$(%d+)%$")
         if tonumber(share) < limitshare then
            if tMoreUsers[user][1] >= (w2time) then
                  usr:SendPM(wsBot, "You didnt fill up your share to fulfill hub requirements.")
                  return Act(usr, The2Action)
            elseif ( tMoreUsers[user][1] == bal2 * tMoreUsers[user][2] ) then
               tMoreUsers[user][2] = tMoreUsers[user][2] + 1
               usr:SendPM(wsBot, "Please fill up ur share ... "..(tMoreUsers[user][2]-1).."/ "..secfrequency.." warnings ... on the last warning you will get "..DoStringActions(The2Action)..".")
               usr:SendPM(wsBot, "- You have another "..DoTimeUnits(w2time - tMoreUsers[user][1]).." left.")
            end
         else tMoreUsers[usr.sName] = nil
         end
      end
   end
   collectgarbage()
   flush()
end

function DoStringActions(act)
   local ret = ""
   local tActionStr = {
         [1] = "Disconnected",
         [2] = "Redirected",
         [3] = "Kicked",
         [4] = "Temporalily Banned",
         [5] = "Banned",
      };
   return tActionStr[act]
end


function DataArrival(user, data)
   if ( (user.sName == TheNick) and user.bOperator ) then
      data = strsub(data,1,strlen(data)-1)
      local s,e,cmd = strfind( data, "%b<>%s+(%S+)" )
      if cmd == TheCmd then
         local msg = "\r\n\t\t\t\t - ---==Users that are under the limit==--- -\r\n"
         msg = msg..strrep(" -", 110).."\r\n"
         msg = msg.."\t The following users are going to be "..DoStringActions(TheAction).." after their period of grace is over( initialy set to"..DoTimeUnits(wtime)..")\r\n"
         msg = msg..strrep(" -", 110).."\r\n"
         for nick , time in tUsers do
               if GetItemByName(nick) then
               status = "online"
               else status = "offline"
               end
               msg = msg.."\t - Nick : "..nick.."\t\t Time Left : "..DoTimeUnits(wtime - tUsers[nick][1]).."\t\t Warnings : "..(tUsers[nick][2]-1).."/ "..frequency.."\t\t Status : "..status.."\r\n"
         end
         msg = msg..strrep(" -", 110).."\r\n\r\n"
         msg = msg..strrep(" -", 110).."\r\n"
         msg = msg.."\t The following users are going to be "..DoStringActions(The2Action).." after their period of grace is over ( initialy set to"..DoTimeUnits(w2time)..")\r\n"
         msg = msg..strrep(" -", 110).."\r\n"
         for nick , time in tMoreUsers do
            if GetItemByName(nick) then
               status = "online"
            else status = "offline"
            end
            msg = msg.."\t - Nick : "..nick.."\t\t Time Left : "..DoTimeUnits(w2time - tMoreUsers[nick][1]).."\t\t Warnings : "..(tMoreUsers[nick][2]-1).."/ "..secfrequency.."\t\t Status : "..status.."\r\n"
         end
         msg = msg..strrep(" -", 110)
         SendPmToNick(TheNick, wsBot, msg)
      end
   end
end

--- // --- Transforming bytes Into KB, MB, GB, TB, PT and Returning the ideal (highest possible) Unit --- // ---
function DoShareUnits(intSize)            --- Thanks to kepp and NotRambitWombat
if intSize ~= 0 then
   local tUnits = { "Bytes", "KB", "MB", "GB", "TB" }
   intSize = tonumber(intSize);
   local sUnits;
   for index = 1, getn(tUnits) do
      if(intSize < 1024) then
         sUnits = tUnits[index];
         break;
      else
         intSize = intSize / 1024;
      end
   end
   return format("%0.1f %s",intSize, sUnits);
else return "nothing"
end
end

--- // --- Performing action and also informing the user about it ... It is handled from the ' TheAction ' variable ....
function Act(user, var)
   local tActions = {
      [1] = function(user) user:SendPM(wsBot, "You will now be Disconnected") user:Disconnect() end,
      [2] = function(user) user:SendPM(wsBot, "You will now be Redirected to "..frmHub:GetRedirectAddress()) user:SendData("$OpForceMove "..frmHub:GetRedirectAddress()) end,
      [3] = function(user) user:SendPM(wsBot, "You will now be Kicked") user:Kick() end,
      [4] = function(user) user:SendPM(wsBot, "You are temporalily Banned") user:TempBan() end,
      [5] = function(user) user:SendPM(wsBot, "You are permenantly Banned") user:Ban() end,
      };
   for i,v in tActions do
      if i == var then
         tUsers[user.sName] = nil
         if i ~=3 or i ~= 4 or i ~= 5 then
            tAgain[user.sName] = 1
         end
         return tActions(user)
      end
   end
   tActions = nil
end


function DoTimeUnits(time)
   local tTimes = {}
   local time = time * 1000
   if ( time >= 86400000 ) then
   repeat
      if tTimes[4] then
         tTimes[4] = tTimes[4] + 1
      else tTimes[4] = 1
      end
      time = time - 86400000
   until time < 86400000
   end

   if ( time >= 3600000 ) then
   repeat
      if tTimes[3] then
         tTimes[3] = tTimes[3] + 1
      else tTimes[3] = 1
      end
      time = time - 3600000
   until time < 3600000
   end

   if ( time >= 60000 ) then
   repeat
      if tTimes[2] then
         tTimes[2] = tTimes[2] + 1
      else tTimes[2] = 1
      end
      time = time - 60000
   until time < 60000
   end
   
   if ( time >= 1000 ) then
   repeat
      if tTimes[1] then
         tTimes[1] = tTimes[1] + 1
      else tTimes[1] = 1
      end
      time = time - 1000
   until time < 1000
   end
local msg = ""
local tTimeUns = { "seconds", "minutes", "hours", "days"}
for i,v in tTimes do
   msg = v.." "..tTimeUns.." "..msg
end
return msg
end
-------- -------- -------- -------- -------- -------- -------- --------
         --- script ends ---
-------- -------- -------- -------- -------- -------- -------- --------
Title: Error again !!!
Post by: juda on 12 August, 2004, 17:18:14
Syntax error: `=' expected;
                          last token read: `is' at line 1 in file `C:\Program Files\PtokaX ver 330\scripts\ShaveShare v4.1 correct.lua'
Title:
Post by: Herodes on 12 August, 2004, 17:21:43
QuoteOriginally posted by [G-T-E]Gate?
I have a question,
If I have my min users share set to 15Gb and I set this section to the following>>

limitshare = 2 * gb    --- this sets the share limit that needs to be reached by the user so that he doesnt get the action .. :) keep format ex: 5 *gb is 5GB ... and so on ..

will the script check to see if the user has added 2Gb to his share when he returns?
If you mean that the user has to have a share of 15GB(ur min) + 2gb (from that setting) = 17GB then the answer is no ...
if not then, yeah if he has the required share(2gb as set in that setting ...)  he will be taken out of the list of those users under_the_limt. . :)
Title:
Post by: Herodes on 12 August, 2004, 17:25:11
QuoteOriginally posted by juda
Syntax error: `=' expected;
                          last token read: `is' at line 1 in file `C:\Program Files\PtokaX ver 330\scripts\ShaveShare v4.1 correct.lua'

Manson had pointed the mistake and fixed it in his post ...
I edited the code in the last post that contained one (last one on prev page of this thread..)
It should be working without errors now .. pls grab it again...

The error was caused by an uncommented line ( without the "--" in front)  in the begging of the script ...

To Manson : can you please [ code ] the script ... because it looks a bit too much like that :)) lol
Title:
Post by: Herodes on 12 August, 2004, 18:06:36
Another update ....
--- ShaveShare v4.5 request by judas ( 10/08 - 2004 )
--- by Herodes ( early hours of 11/08 - 2004 )
-------- -------- -------- -------- -------- -------- -------- --------
--- offers a way to handle under-the-share-limit users to enter your hub
--- it can disconnect/redirect/kick/tempban/ban after a certain configurable time...
--- it has a variable to say how many times to warn before disconnect
-- v3 changes
--- Now there is a nick-to-send variable in place ... ( v 3 )
--- If you have that nick then use the command ' !noshare '  to show a list of the ppl that are in the bots list ...
-- v4 changes
--- Now the users can enter again but the bot will remember them and act differently ( edit ' The2Action ' variable to change the behaviour ...)
--- You can also adjust the time for those ppl to be different than the ones that come for the first time. ( edit the ' w2time ' variable for that ...)
--- Edit the ' secfrequency ' variable to choose how many warnings these ppl will receive...
--- Made the messages of that the users receive aware of the action that is going to be taken if the requirments fail in the predifined time ....
--- I think it is fairly complete now ... if not give me a post
--- --- v4.5 changes --- ---
--- now the list of users has a acsending count number infront of each user ...
--- and new command ' !disnoshare ' can only be used by the nick in the ' TheNick ' variable
--- --- ^disconnects all users in the list and clears the scripts memory ... from both fresh users and second-time user lists
-------- -------- -------- -------- -------- -------- -------- --------
--- do not edit ... or if you do dont blame me ---
tUsers = {}
tMoreUsers = {}
tAgain = {}
kb = 1024
mb = 1024 ^ 2
gb = 1024 ^ 3
minutes = 60
hours = 60 ^2
-------- -------- -------- -------- -------- -------- -------- --------
--- edit the values of the 11 following variables as you wish ---
-------- -------- -------- -------- -------- -------- -------- --------
wsBot = "ShaveShare" --- The name of the bot ... it is necessary ... don't include    s  p a c e s ...
TheCmd = "!noshare" --- The command for displaying the actual list of the ppl under the share limit ....
DisCmd = "!disnoshare" --- This drops all users that are below the share limit and clears the memory of the script ...
TheNick = "Herodes" --- Who is allowed to use the command above ...
wtime = 24 * hours --- this is the time in seconds. .. Feel free to use the #*hours to say in # hours ... and  #*minutes to say in # minutes .. :)
frequency = 4 --- this is the number of warnings the user is going to receive within the predifined time limit...
w2time = 3 * hours --- this is the time that a user entering with below share limit for the second time while have to fill up the requirement...
secfrequency = 2 --- this is how many times a user entering with below share limit for the second time is going to be warned in the time set by ' w2time ' variable...
limitshare = 500 * mb --- this sets the share limit that needs to be reached by the user so that he doesnt get the action .. :) keep format ex: 5 *gb is 5GB ... and so on ..
TheAction = 1 --- this sets the action to take against these ppl .... ? 1 = disconnect , 2 = redirect , 3 = kick , 4 = tempban , 5 = ban ?
The2Action = 5 --- this sets the action to take against the ppl that come back after they were given a first chance.... ? 1 = disconnect , 2 = redirect , 3 = kick , 4 = tempban , 5 = ban ?
-------- -------- -------- -------- -------- -------- -------- --------
--- script starts ---
-------- -------- -------- -------- -------- -------- -------- --------
function Main()
frmHub:UnregBot(wsBot)
frmHub:RegBot(wsBot)
SetTimer(1000)
StartTimer()
bal = floor(wtime/frequency)
bal2 = floor(w2time/secfrequency)
end

--- // --- Actions to do if a new user is connected ... inform him about the time he has left to fill up his share if it is below the limit defined by ' limitshare ' variable
function NewUserConnected(user)
if user.sMyInfoString then
_,_,share = strfind(user.sMyInfoString, "%$(%d+)%$")
if tonumber(share) < limitshare then
if tUsers[user.sName] == nil then
if tAgain[user.sName] == 1 then
tAgain[user.sName] = nil
tMoreUsers[user.sName] = {}
tMoreUsers[user.sName][1] = 0
tMoreUsers[user.sName][2] = 1
user:SendPM(wsBot, "You come without having the required share of "..DoShareUnits(limitshare).." Again ?.Presently you are sharing "..DoShareUnits(tonumber(share))..".")
user:SendPM(wsBot, "You now have just "..DoTimeUnits(w2time).." left to fill it up. If you dont you are getting "..DoStringActions(The2Action)..".")
else
tUsers[user.sName] = {}
tUsers[user.sName][1] = 0
tUsers[user.sName][2] = 1
user:SendPM(wsBot, "Please fill up your share to reach "..DoShareUnits(limitshare)..". Presently you are sharing "..DoShareUnits(tonumber(share))..".")
user:SendPM(wsBot, " - You have another "..DoTimeUnits(wtime).." left.")
end
else
if tMoreUsers[user.sName] then
user:SendPM(wsBot, "Fill up your share to reach "..DoShareUnits(limitshare)..". Presently you are sharing "..DoShareUnits(tonumber(share))..".")
user:SendPM(wsBot, " - You have another "..DoTimeUnits(w2time - tMoreUsers[user.sName][1]).." left.")
else
user:SendPM(wsBot, "Please fill up your share to reach "..DoShareUnits(limitshare)..". Presently you are sharing "..DoShareUnits(tonumber(share))..".")
user:SendPM(wsBot, " - You have another "..DoTimeUnits(wtime - tUsers[user.sName][1]).." left.")
end
end
end
end
end

--- // --- Doing stuff on Timer ... that is every second ... under certain conditions the users are going to be warned or have actions casted on them ...
function OnTimer()
for user, time in tUsers do
local usr = GetItemByName(user)
tUsers[user][1] = tUsers[user][1] + 1
if usr and usr.sMyInfoString then
_,_,share = strfind(usr.sMyInfoString, "%$(%d+)%$")
if tonumber(share) < limitshare then
if tUsers[user][1] >= (wtime) then
usr:SendPM(wsBot, "You didnt fill up your share to fulfill hub requirements.")
return Act(usr, TheAction)
elseif ( tUsers[user][1] == bal*tUsers[user][2] ) then
tUsers[user][2] = tUsers[user][2] + 1
usr:SendPM(wsBot, "Please fill up ur share ... "..(tUsers[user][2]-1).."/ "..frequency.." warnings ... on the last warning you will get "..DoStringActions(TheAction)..".")
usr:SendPM(wsBot, "- You have another "..DoTimeUnits(wtime - tUsers[user][1]).." left.")
end
else tUsers[usr.sName] = nil
end
end
end
for user, time in tMoreUsers do
local usr = GetItemByName(user)
tMoreUsers[user][1] = tMoreUsers[user][1] + 1
if usr and usr.sMyInfoString then
_,_,share = strfind(usr.sMyInfoString, "%$(%d+)%$")
if tonumber(share) < limitshare then
if tMoreUsers[user][1] >= (w2time) then
usr:SendPM(wsBot, "You didnt fill up your share to fulfill hub requirements.")
return Act(usr, The2Action)
elseif ( tMoreUsers[user][1] == bal2 * tMoreUsers[user][2] ) then
tMoreUsers[user][2] = tMoreUsers[user][2] + 1
usr:SendPM(wsBot, "Please fill up ur share ... "..(tMoreUsers[user][2]-1).."/ "..secfrequency.." warnings ... on the last warning you will get "..DoStringActions(The2Action)..".")
usr:SendPM(wsBot, "- You have another "..DoTimeUnits(w2time - tMoreUsers[user][1]).." left.")
end
else tMoreUsers[usr.sName] = nil
end
end
end
collectgarbage()
flush()
end

function DoStringActions(act)
local ret = ""
local tActionStr = {
[1] = "Disconnected",
[2] = "Redirected",
[3] = "Kicked",
[4] = "Temporalily Banned",
[5] = "Banned",
};
return tActionStr[act]
end


function DataArrival(user, data)
if ( (user.sName == TheNick) and user.bOperator ) then
data = strsub(data,1,strlen(data)-1)
local s,e,cmd = strfind( data, "%b<>%s+(%S+)" )
if cmd == TheCmd then
local cnt = 0
local seccnt = 0
local msg = "\r\n\t\t\t\t - ---==Users that are under the limit==--- -\r\n"
msg = msg..strrep(" -", 110).."\r\n"
msg = msg.."\t The following users are going to be "..DoStringActions(TheAction).." after their period of grace is over( initialy set to"..DoTimeUnits(wtime)..")\r\n"
msg = msg..strrep(" -", 110).."\r\n"
for nick , time in tUsers do
if GetItemByName(nick) then
status = "online"
else status = "offline"
end
cnt = cnt + 1
msg = msg..cnt..".\t - Nick : "..nick.."\t Time Left : "..DoTimeUnits(wtime - tUsers[nick][1]).."\t Warnings : "..(tUsers[nick][2]-1).."/ "..frequency.."\t Status : "..status.."\r\n"
end
msg = msg..strrep(" -", 110).."\r\n\r\n"
msg = msg..strrep(" -", 110).."\r\n"
msg = msg.."\t The following users are going to be "..DoStringActions(The2Action).." after their period of grace is over ( initialy set to"..DoTimeUnits(w2time)..")\r\n"
msg = msg..strrep(" -", 110).."\r\n"
for nick , time in tMoreUsers do
if GetItemByName(nick) then
status = "online"
else status = "offline"
end
seccnt = seccnt + 1
msg = msg..seccnt..".\t - Nick : "..nick.."\t Time Left : "..DoTimeUnits(w2time - tMoreUsers[nick][1]).."\t Warnings : "..(tMoreUsers[nick][2]-1).."/ "..secfrequency.."\t Status : "..status.."\r\n"
end
msg = msg..strrep(" -", 110)
SendPmToNick(TheNick, wsBot, msg)
elseif cmd == DisCmd then
for nick, v in tUsers do
local usr = GetItemByName(nick)
if usr then
usr:SendPM(wsBot, user.sName.." said you have to leave because your share was not enough for this hub ...")
usr:Disconnect()
end
end
for nick, v in tMoreUsers do
local usr = GetItemByName(nick)
if usr then
usr:SendPM(wsBot, user.sName.." said you have to leave because your share was not enough for this hub ...")
usr:Disconnect()
end
end
tUsers = {}
tMoreUsers= {}
end
end
end

--- // --- Transforming bytes Into KB, MB, GB, TB, PT and Returning the ideal (highest possible) Unit --- // ---
function DoShareUnits(intSize) --- Thanks to kepp and NotRambitWombat
if intSize ~= 0 then
local tUnits = { "Bytes", "KB", "MB", "GB", "TB" }
intSize = tonumber(intSize);
local sUnits;
for index = 1, getn(tUnits) do
if(intSize < 1024) then
sUnits = tUnits[index];
break;
else
intSize = intSize / 1024;
end
end
return format("%0.1f %s",intSize, sUnits);
else return "nothing"
end
end

--- // --- Performing action and also informing the user about it ... It is handled from the ' TheAction ' variable ....
function Act(user, var)
local tActions = {
[1] = function(user) user:SendPM(wsBot, "You will now be Disconnected") user:Disconnect() end,
[2] = function(user) user:SendPM(wsBot, "You will now be Redirected to "..frmHub:GetRedirectAddress()) user:SendData("$OpForceMove "..frmHub:GetRedirectAddress()) end,
[3] = function(user) user:SendPM(wsBot, "You will now be Kicked") user:Kick() end,
[4] = function(user) user:SendPM(wsBot, "You are temporalily Banned") user:TempBan() end,
[5] = function(user) user:SendPM(wsBot, "You are permenantly Banned") user:Ban() end,
};
for i,v in tActions do
if i == var then
tUsers[user.sName] = nil
if i ~=3 or i ~= 4 or i ~= 5 then
tAgain[user.sName] = 1
end
return tActions[i](user)
end
end
tActions = nil
end


function DoTimeUnits(time)
local tTimes = {}
local time = time * 1000
if ( time >= 86400000 ) then
repeat
if tTimes[4] then
tTimes[4] = tTimes[4] + 1
else tTimes[4] = 1
end
time = time - 86400000
until time < 86400000
end

if ( time >= 3600000 ) then
repeat
if tTimes[3] then
tTimes[3] = tTimes[3] + 1
else tTimes[3] = 1
end
time = time - 3600000
until time < 3600000
end

if ( time >= 60000 ) then
repeat
if tTimes[2] then
tTimes[2] = tTimes[2] + 1
else tTimes[2] = 1
end
time = time - 60000
until time < 60000
end

if ( time >= 1000 ) then
repeat
if tTimes[1] then
tTimes[1] = tTimes[1] + 1
else tTimes[1] = 1
end
time = time - 1000
until time < 1000
end
local msg = ""
local tTimeUns = { "seconds", "minutes", "hours", "days"}
for i,v in tTimes do
msg = v.." "..tTimeUns[i].." "..msg
end
return msg
end


Keep posting guys the previous posts are the cause of this update
Title:
Post by: Herodes on 12 August, 2004, 18:08:41
The post above had the changelog cut because it wouldnt fit in the maximum characters per post ... i dont know how to give this script out if it gets bigger ... any ideas are welcome.
ty
Title: Ye Herodes !!! You win !!!
Post by: juda on 12 August, 2004, 19:20:30
B ?! I`m stupid,ya !!!
Now copy v4 and v4.1 as you say and work great....
I already tested v4 & 4.1.....I think I stick today on v4.1
I`ll will restart my hub around 20.00 and then I put v4.1 to run 12 hours....and will see
In that time will check your updates and tested new versions like mad on my testing hub !!!!
                                                                         
UUUU,just 1 little update:
Please in the next version,if you can,put text into bot "ShaveShare" description......
Show in description: [All you guys who work on this script....nicknames or names,you know who work on this script] please don`t forgett to put your name in......
It will be nice to see who are doing good stuff !!!

     Until next time........bay
Title:
Post by: Herodes on 12 August, 2004, 19:25:20
QuoteOriginally posted by juda
B ?! I`m stupid,ya !!!
Now copy v4 and v4.1 as you say and work great....
I already tested v4 & 4.1.....I think I stick today on v4.1
I`ll will restart my hub around 20.00 and then I put v4.1 to run 12 hours....and will see
In that time will check your updates and tested new versions like mad on my testing hub !!!!
                                                                         
UUUU,just 1 little update:
Please in the next version,if you can,put text into bot "ShaveShare" description......
Show in description: [All you guys who work on this script....nicknames or names,you know who work on this script] please don`t forgett to put your name in......
It will be nice to see who are doing good stuff !!!

     Until next time........bay
Thanks for the feedback :)
I will put the description in the bot ... np :)
But I need a way to post it in one post ... I think it will solve many problems for you guys ...  so pls come up with ideas ... maybe I could upload it somewhere ?
Title:
Post by: NightLitch on 12 August, 2004, 19:33:27
Looking good Herodes...

About the Connection Checks u can if u want todo an overkill table make it...

ex:

Table = {
["56Kbps"] = {Time = 24, ShareLimit = 500 * mb},
["LAN(T1)"] = {Time = 18, ShareLimit = 1 * gb},
}

hope it helps some, just an idea... don't now what I where thinkin, but somethin in that direction...

/NL
Title:
Post by: Herodes on 12 August, 2004, 19:41:12
gracias Nightlitch .. :) I think I know where that goes ... I just need a way for it to fit smoothly ..
:)

PS: Oooh now I am in trouble :D
Title:
Post by: NightLitch on 12 August, 2004, 19:53:28
some updated code on my version, should be better now:

--------------------------------------------------------
-- Share Warning - By: NightLitch - 2004/08/10
-- Request By: Juda
-- NOTE: NoShare Table is erased when Script is Restarted !!
-- Some Modification Done
-- Changed so it send in PM
-- Some Fixes done with help from Herodes =)
--------------------------------------------------------
KB = 1024
MB = KB*KB
GB = KB*KB*KB
TB = KB*KB*KB*KB
Sec  = 1000
Min  = 60*Sec
Hour = 60*Min
TmrFreq = 1000
--------------------------------------------------------
--// Editable Part Start's Here \\--
--------------------------------------------------------
BotName = "-Share-Warning-" -- Set Botname

MinShareLimit = 500 -- Set Share Limit
MinShareUnit = MB -- Set Share Unit ( KB, MB, GB, TB )

NoShareTimeLimit = 1 -- Set Time Limit in hours for checking if share is more then 0 MB etc.
ShareUpdateTimeLimit = 1 -- Set Time Limit in hours for checking if share is updated after x hours
NoShareMessage = "You're welcome to stay in this hub, BUT you need to fill your Share with "..MinShareLimit.." MB within "..NoShareTimeLimit.." Hours to stay!"
--------------------------------------------------------
--// Code Starts Here \\--
--------------------------------------------------------
NoShare = {}
tTab = {n=0}

function Main()
frmHub:RegBot(BotName)
SetTimer(TmrFreq)
StartTimer()
RegTimer(NoShareCheck, 1*Sec)
RegTimer(ShareUpdatedCheck, 1*Sec)
end

function ShareUpdatedCheck()
for Nickname, Table in NoShare do
User = GetItemByName(Nickname)
if User then
local _,_,h,m,s = strfind(Table[2], "(%d+):(%d+):(%d+)")
h = h + ShareUpdateTimeLimit
if h >= 24 then h = h -24 end
if h..":"..m..":"..s == date("%T") then
local _,_,CurrentShare = strfind(User.sMyInfoString, "(%d+)%$%|$")
if tonumber(CurrentShare) <= tonumber(Table[1]) then
SendPmToNick(Nickname, BotName, "You haven't raised your share within "..ShareUpdateTimeLimit.." Hours and your share is still "..format("%.2f",Table[1]/1024/1024).." MB !!")
SendPmToNick(Nickname, BotName, "You are Disconnected!!")
User:Disconnect()
NoShare[Nickname] = nil
end
end
end
end
end

function NoShareCheck()
for Nickname, Share in NoShare do
if tonumber(Share) == 0 then
User = GetItemByName(Nickname)
if User then
local _,_,h,m,s = strfind(Table[2], "(%d+):(%d+):(%d+)")
h = h + NoShareTimeLimit
if h >= 24 then h = h -24 end
if h..":"..m..":"..s == date("%T") then
SendPmToNick(Nickname, BotName, "You have been online for "..NoShareTimeLimit.." Hours and your share is still "..format("%.2f",Share/1024/1024).." MB !!")
SendPmToNick(Nickname, BotName, "You are Disconnected!!")
User:Disconnect()
NoShare[Nickname] = nil
end
end
end
end
end

function UserDisconnect(sUser)
NoShare[sUser.sName] = nil
end

function DataArrival(sUser,sData)
if strsub(sData, 1,7) == "$MyINFO" then
local s,e,sShare = strfind(sData, "(%d+)%$%|$")
NoShare[sUser.sName] = {sShare,date("%T")}
if tonumber(sShare) == 0 then
SendPmToNick(sUser.sName, BotName, "\r\n\t -------==[ NOTICE !! ]===================================================-------")
SendPmToNick(sUser.sName, BotName, "\r\n\t "..NoShareMessage)
SendPmToNick(sUser.sName, BotName, "\r\n\t -------===============================================================-------\r\n\r\n")
end
end
end

function OnTimer()
for i=1, getn(tTab) do
tTab[i].count = tTab[i].count + 1
if tTab[i].count > tTab[i].trig then
tTab[i].count=1
tTab[i]:func()
end
end
end

function RegTimer(f, Interval)
local tmpTrig = Interval / TmrFreq
assert(Interval >= TmrFreq , "RegTimer(): Please Adjust TmrFreq")
local Timer = {n=0}
Timer.func=f
Timer.trig=tmpTrig
Timer.count=1
tinsert(tTab, Timer)
end


/NL
Title: HAY !!!
Post by: juda on 12 August, 2004, 20:55:27
I copy your script.....thanks again !!!

Now I have 1 or 2 questions,,,,Please to any replay !!!!
It is possible to do or already  exist any script to make sound like "pip" in the mainchat,when user say "a".....
In DC++ only make sounds when you get PM from user.....
I want to make sound,whan is any word  written in mainchat.....
Also heard that sounds have BCDC++ client ???I`m write or wrong ???
It is happend,that I don`t know,whan any user say something in mainchat !!!
This I need,becouse I`m on the web or looking into my computer,
in the mintime,user ask for help and I even don`t know that someone say something.....
uuu.sorry for my spelling [not very good in english]

Please for help or I must send new thread in forum ???


Please for help.....Thhhhhhhhhaaaaaannnnnnnkkkkkkksssssss
Title:
Post by: Herodes on 12 August, 2004, 21:37:52
update for the my script request added .. :)
--- ShaveShare v4.6 request by judas ( 10/08 - 2004 )
--- by Herodes ( 11/08 - 2004 )
-------- -------- -------- -------- -------- -------- -------- --------
--- Offers a way to handle under-the-share-limit users to enter your hub
--- It can disconnect/redirect/kick/tempban/ban (' TheAction ' variable) after a certain configurable time...
--- Warns for defined times ( ' frequency ' variable ) to the timelimit ( ' wtime ' variable ) before the action
--- Remebers where users left off if they disconnect and connect again
--- Adjustable required limit for the share (kb , mb , gb )
--- ---  v3 changes --- ---
--- Now there is an allowed nick ( ' TheNick ' Variable ) to use the command
--- Command ' !noshare ' ( ' TheCmd ' variable ) shows a list of the ppl that are in the bots list
--- --- v4 changes --- ---
--- Now the users can enter again but the bot will remember them and act differently ( edit ' The2Action ' variable to change the behaviour )
--- You can also adjust the time for those ppl to be different than the ones that come for the first time. ( ' w2time ' variable )
--- Edit the ' secfrequency ' variable to choose how many warnings these ppl will receive
--- Made the messages of that the users receive aware of the action that is going to be taken
--- --- v4.5 changes --- ---
--- now the list of users has a acsending count number infront of each user ...
--- Command ' !disnoshare ' (' DisCmd ' variable ) disconnects all users in the lists of the bot that are online and clears the scripts memory
--- --- v4.6 changes --- ---
--- optimized the script less lines and less code .. :)
--- installed Bot information
-------- -------- -------- -------- -------- -------- -------- --------
--- ( Last Update 12/8 - 2004 )
-------- -------- -------- -------- -------- -------- -------- --------
--- do not edit ... or if you do dont blame me ---
tUsers = {}
tMoreUsers = {}
tAgain = {}
kb = 1024
mb = 1024 ^ 2
gb = 1024 ^ 3
minutes = 60
hours = 60 ^2
wsBotDesc = "Made by Herodes idea by juda (thnx Nightlitch)"
wsBotEmail = "http://board.univ-angers.fr"
-------- -------- -------- -------- -------- -------- -------- --------
--- edit the values of the 11 following variables as you wish ---
-------- -------- -------- -------- -------- -------- -------- --------
wsBot = "ShaveShare" --- The name of the bot ... it is necessary ... don't include    s  p a c e s ...
TheCmd = "!noshare" --- The command for displaying the actual list of the ppl under the share limit ....
DisCmd = "!disnoshare" --- This drops all users that are below the share limit and clears the memory of the script ...
TheNick = "Herodes" --- Who is allowed to use the command above ...
wtime = 24 * hours --- this is the time in seconds. .. Feel free to use the #*hours to say in # hours ... and  #*minutes to say in # minutes .. :)
frequency = 4 --- this is the number of warnings the user is going to receive within the predifined time limit...
w2time = 12 * hours --- this is the time that a user entering with below share limit for the second time while have to fill up the requirement...
secfrequency = 2 --- this is how many times a user entering with below share limit for the second time is going to be warned in the time set by ' w2time ' variable...
limitshare = 500 * mb --- this sets the share limit that needs to be reached by the user so that he doesnt get the action .. :) keep format ex: 5 *gb is 5GB ... and so on ..
TheAction = 1 --- this sets the action to take against these ppl .... ? 1 = disconnect , 2 = redirect , 3 = kick , 4 = tempban , 5 = ban ?
The2Action = 5 --- this sets the action to take against the ppl that come back after they were given a first chance.... ? 1 = disconnect , 2 = redirect , 3 = kick , 4 = tempban , 5 = ban ?

-------- -------- -------- -------- -------- -------- -------- -------- Script Starts
function Main()
frmHub:UnregBot(wsBot)
frmHub:RegBot(wsBot)
SetTimer(1000)
StartTimer()
bal = floor(wtime/frequency)
bal2 = floor(w2time/secfrequency)
DoBotInfo()
end

function OpConnected(user)
DoBotInfo(user)
end
--- // --- Actions to do if a new user is connected ... inform him about the time he has left to fill up his share if it is below the limit defined by ' limitshare ' variable
function NewUserConnected(user)
if user.sMyInfoString then
_,_,share = strfind(user.sMyInfoString, "%$(%d+)%$")
if tonumber(share) < limitshare then
if tUsers[user.sName] == nil then
if tAgain[user.sName] == 1 then
tAgain[user.sName] = nil
tMoreUsers[user.sName] = {}
tMoreUsers[user.sName][1] = 0
tMoreUsers[user.sName][2] = 1
user:SendPM(wsBot, "You come without having the required share of "..DoShareUnits(limitshare).." Again ?.Presently you are sharing "..DoShareUnits(tonumber(share))..".")
user:SendPM(wsBot, "You now have just "..DoTimeUnits(w2time).." left to fill it up. If you dont you are getting "..DoStringActions(The2Action)..".")
else
tUsers[user.sName] = {}
tUsers[user.sName][1] = 0
tUsers[user.sName][2] = 1
user:SendPM(wsBot, "Please fill up your share to reach "..DoShareUnits(limitshare)..". Presently you are sharing "..DoShareUnits(tonumber(share))..".")
user:SendPM(wsBot, " - You have another "..DoTimeUnits(wtime).." left.")
end
else
if tMoreUsers[user.sName] then
user:SendPM(wsBot, "Fill up your share to reach "..DoShareUnits(limitshare)..". Presently you are sharing "..DoShareUnits(tonumber(share))..".")
user:SendPM(wsBot, " - You have another "..DoTimeUnits(w2time - tMoreUsers[user.sName][1]).." left.")
else
user:SendPM(wsBot, "Please fill up your share to reach "..DoShareUnits(limitshare)..". Presently you are sharing "..DoShareUnits(tonumber(share))..".")
user:SendPM(wsBot, " - You have another "..DoTimeUnits(wtime - tUsers[user.sName][1]).." left.")
end
end
end
end
DoBotInfo(user)
end

function DoBotInfo(user)
if user ~= nil then
user:SendData("$MyINFO $ALL "..wsBot.." "..wsBotDesc.."<++V:0.4.6,M:A,H0/0/1,S:1>$ $LAN(T3)$"..wsBotEmail.."$0$|")
else SendToAll("$MyINFO $ALL "..wsBot.." "..wsBotDesc.."<++V:0.4.6,M:A,H0/0/1,S:1>$ $LAN(T3)$"..wsBotEmail.."$0$|")
end
end
--- // --- Doing stuff on Timer ... that is every second ... under certain conditions the users are going to be warned or have actions casted on them ...
function OnTimer()
TakeCare(tUsers, wtime, bal, frequency, TheAction)
TakeCare(tMoreUsers, w2time, bal2, secfrequency, The2Action)
collectgarbage()
flush()
end

function TakeCare(table, timeallowed, balance, freq, doaction)
for user, time in table do
local usr = GetItemByName(user)
table[user][1] = table[user][1] + 1
if usr and usr.sMyInfoString then
_,_,share = strfind(usr.sMyInfoString, "%$(%d+)%$")
if tonumber(share) < limitshare then
if ( table[user][1] >= timeallowed ) then
usr:SendPM(wsBot, "You didnt fill up your share to fulfill hub requirements.")
return Act(usr, doaction)
elseif ( table[user][1] == balance * table[user][2] ) then
table[user][2] = table[user][2] + 1
usr:SendPM(wsBot, "Please fill up ur share ... "..(table[user][2]-1).."/ "..freq.." warnings ... on the last warning you will get "..DoStringActions(doaction)..".")
usr:SendPM(wsBot, "- You have another "..DoTimeUnits(timeallowed - table[user][1]).." left.")
end
else table[usr.sName] = nil
end
end
end
end


function DoStringActions(act)
local ret = ""
local tActionStr = {
[1] = "Disconnected",
[2] = "Redirected",
[3] = "Kicked",
[4] = "Temporalily Banned",
[5] = "Banned",
};
return tActionStr[act]
end


function DataArrival(user, data)
if ( (user.sName == TheNick) and user.bOperator ) then
data = strsub(data,1,strlen(data)-1)
local s,e,cmd = strfind( data, "%b<>%s+(%S+)" )
if cmd == TheCmd then
local msg = "\r\n\t\t\t\t - ---==Users that are under the limit==--- -\r\n"
msg = msg..strrep(" -", 110).."\r\n"
msg = msg.."\t The following users are going to be "..DoStringActions(TheAction).." after their period of grace is over( initialy set to "..DoTimeUnits(wtime)..")\r\n"
msg = msg..strrep(" -", 110).."\r\n"..DoList(tUsers, wtime, frequency)
msg = msg..strrep(" -", 110).."\r\n\r\n"
msg = msg..strrep(" -", 110).."\r\n"
msg = msg.."\t The following users are going to be "..DoStringActions(The2Action).." after their period of grace is over ( initialy set to "..DoTimeUnits(w2time)..")\r\n"
msg = msg..strrep(" -", 110).."\r\n"..DoList(tMoreUsers, w2time, secfrequency)
msg = msg..strrep(" -", 110)
SendPmToNick(TheNick, wsBot, msg)
elseif cmd == DisCmd then
TableClear(tUsers)
TableClear(tMoreUsers)
end
end
end

function DoList(table, timeallowed, freq)
local msg = ""
local cnt = 0
for nick , time in table do
if GetItemByName(nick) then
status = "online"
else status = "offline"
end
cnt = cnt + 1
msg = msg..cnt..".\t - Nick : "..nick.."\t Time Left : "..DoTimeUnits(timeallowed - table[nick][1]).."\t Warnings : "..(table[nick][2]-1).."/ "..freq.."\t Status : "..status.."\r\n"
end
return msg
end


function TableClear(table)
for nick, v in table do
local usr = GetItemByName(nick)
if usr then
usr:SendPM(wsBot, TheNick.." said you have to leave because your share was not enough for this hub ...")
usr:Disconnect()
end
end
table = {}
end

--- // --- Transforming bytes Into KB, MB, GB, TB, PT and Returning the ideal (highest possible) Unit --- // ---
function DoShareUnits(intSize) --- Thanks to kepp and NotRambitWombat
if intSize ~= 0 then
local tUnits = { "Bytes", "KB", "MB", "GB", "TB" }
intSize = tonumber(intSize);
local sUnits;
for index = 1, getn(tUnits) do
if(intSize < 1024) then
sUnits = tUnits[index];
break;
else
intSize = intSize / 1024;
end
end
return format("%0.1f %s",intSize, sUnits);
else return "nothing"
end
end

--- // --- Performing action and also informing the user about it ... It is handled from the ' TheAction ' variable ....
function Act(user, var)
local tActions = {
[1] = function(user) user:SendPM(wsBot, "You will now be Disconnected") user:Disconnect() end,
[2] = function(user) user:SendPM(wsBot, "You will now be Redirected to "..frmHub:GetRedirectAddress()) user:SendData("$OpForceMove "..frmHub:GetRedirectAddress()) end,
[3] = function(user) user:SendPM(wsBot, "You will now be Kicked") user:Kick() end,
[4] = function(user) user:SendPM(wsBot, "You are temporalily Banned") user:TempBan() end,
[5] = function(user) user:SendPM(wsBot, "You are permenantly Banned") user:Ban() end,
};
for i,v in tActions do
if i == var then
tUsers[user.sName] = nil
if i ~=3 or i ~= 4 or i ~= 5 then
tAgain[user.sName] = 1
end
return tActions[i](user)
end
end
tActions = nil
end


function DoTimeUnits(time)
local tTimes = {}
local time = time * 1000
if ( time >= 86400000 ) then
repeat
if tTimes[4] then
tTimes[4] = tTimes[4] + 1
else tTimes[4] = 1
end
time = time - 86400000
until time < 86400000
end

if ( time >= 3600000 ) then
repeat
if tTimes[3] then
tTimes[3] = tTimes[3] + 1
else tTimes[3] = 1
end
time = time - 3600000
until time < 3600000
end

if ( time >= 60000 ) then
repeat
if tTimes[2] then
tTimes[2] = tTimes[2] + 1
else tTimes[2] = 1
end
time = time - 60000
until time < 60000
end

if ( time >= 1000 ) then
repeat
if tTimes[1] then
tTimes[1] = tTimes[1] + 1
else tTimes[1] = 1
end
time = time - 1000
until time < 1000
end
local msg = ""
local tTimeUns = { "seconds", "minutes", "hours", "days"}
for i,v in tTimes do
msg = v.." "..tTimeUns[i].." "..msg
end
return msg
end
-------- -------- -------- -------- -------- -------- -------- --------  Script Ends

I havent touched the connections issue .... I will but I dont promise anything ...
Title:
Post by: Herodes on 12 August, 2004, 21:40:15
QuoteOriginally posted by juda
I copy your script.....thanks again !!!

Now I have 1 or 2 questions,,,,Please to any replay !!!!
It is possible to do or already  exist any script to make sound like "pip" in the mainchat,when user say "a".....
In DC++ only make sounds when you get PM from user.....
I want to make sound,whan is any word  written in mainchat.....
Also heard that sounds have BCDC++ client ???I`m write or wrong ???
It is happend,that I don`t know,whan any user say something in mainchat !!!
This I need,becouse I`m on the web or looking into my computer,
in the mintime,user ask for help and I even don`t know that someone say something.....
uuu.sorry for my spelling [not very good in english]

Please for help or I must send new thread in forum ???


Please for help.....Thhhhhhhhhaaaaaannnnnnnkkkkkkksssssss

Yeah it can be done for sure .. and you are right about BCDC++ the client side lua script exists here (http://board.univ-angers.fr/thread.php?threadid=2479&boardid=11)
But if u want it in PtokaX better start another thread .. this one is for this specific script we are making here ... if it is for another script completely better have it on another thread ... :)
Title: OK !
Post by: juda on 12 August, 2004, 21:49:57
Thanks for update and your advice on post.....
I open new thread.....& will see

  Again.....gracie for all
Title: ERROR !!!
Post by: juda on 12 August, 2004, 22:45:37
I tested script and get this errors:

Syntax error: attempt to index local `user' (a nil value)
stack traceback:

   1:  function `DoBotInfo' at line 76 [file `...iles\PtokaX ver 330\scripts\ShaveShare v4.6.lua']
   2:  function `Main' at line 34 [file `...iles\PtokaX ver 330\scripts\ShaveShare v4.6.lua']

Or it is me again.....I copy just like others !!!

     Good night
Title:
Post by: Herodes on 12 August, 2004, 23:03:40
QuoteOriginally posted by juda
I tested script and get this errors:

Syntax error: attempt to index local `user' (a nil value)
stack traceback:

   1:  function `DoBotInfo' at line 76 [file `...iles\PtokaX ver 330\scripts\ShaveShare v4.6.lua']
   2:  function `Main' at line 34 [file `...iles\PtokaX ver 330\scripts\ShaveShare v4.6.lua']

Or it is me again.....I copy just like others !!!

     Good night
Above script is fixed ... :) sorry bout that ... grab again ... :)
Title: Hay !!!
Post by: juda on 13 August, 2004, 11:06:27
Yo my man!!!
I tested v4.6 little more and work script ok.....just
 - Options to disconnect;timeban & ban user working good [1 time & 2 time]...ok
 - Problem is if I set to 3"kick" option [1 time] & 3"kick"[2 time]
   Then after time run out,will not kick,but stay connected.....
 - Then I set option 1"disconnected" [1 time] & 3"kick"[2 time]
   When [1 time] run out,disconnect user normaly....good
   But when [2 time]run out,user wont kick [stay online] and in PM displays randomly every 2 sec. - You will now be Kicked.....and on and on...

I think is something wrong with option to "kick" user on [2 time]
Everytime when I set "kick" all goes wrong......help
   
              good day
Title:
Post by: Herodes on 13 August, 2004, 12:05:45
--- ShaveShare v4.8 request by judas ( 10/08 - 2004 )
--- by Herodes ( 11/08 - 2004 )
-------- -------- -------- -------- -------- -------- -------- --------
--- Offers a way to handle under-the-share-limit users to enter your hub
--- It can disconnect/redirect/kick/tempban/nickban/ban/flood (' TheAction ' variable) after a certain configurable time...
--- Warns for defined times ( ' frequency ' variable ) to the timelimit ( ' wtime ' variable ) before the action
--- Remebers where users left off if they disconnect and connect again
--- Adjustable required limit for the share (kb , mb , gb )
--v3
--- Now there is an allowed nick ( ' TheNick ' Variable ) to use the command
--- Command ' !noshare ' ( ' TheCmd ' variable ) shows a list of the ppl that are in the bots list
--v4
--- Now the users can enter again but the bot will remember them and act differently ( edit ' The2Action ' variable to change the behaviour )
--- You can also adjust the time for those ppl to be different than the ones that come for the first time. ( ' w2time ' variable )
--- Edit the ' secfrequency ' variable to choose how many warnings these ppl will receive
--- Made the messages of that the users receive aware of the action that is going to be taken
--v4.5
--- now the list of users has a acsending count number infront of each user ...
--- Command ' !disnoshare ' (' DisCmd ' variable ) disconnects all users in the lists of the bot that are online and clears the scripts memory
--v4.6 changes
--- optimized the script less lines and less code .. :)
--- installed Bot information
--v 4.8 changes
--- added NickBan, TimeBan ( 'bantime ' variable ), Flood ( ' floodTimes ' variable ) actions...
--- ( Last Update 13/8 - 2004 )

--- // --- do not edit ... or if you do dont blame me ---
tUsers = {}
tMoreUsers = {}
tAgain = {}
kb = 1024
mb = 1024 ^ 2
gb = 1024 ^ 3
minutes = 60
hours = 60 ^2
wsBotDesc = "Made by Herodes idea by juda (thnx Nightlitch)"
wsBotEmail = "http://board.univers-angers.net"

--- // --- edit the values of the 13 following variables as you wish ---
wsBot = "ShaveShare" --- The name of the bot (necessary) don't include    s  p a c e s
TheCmd = "!noshare" --- The command for displaying the actual list of the ppl under the share limit
DisCmd = "!disnoshare" --- This drops all users that are below the share limit and clears the memory of the script
TheNick = "Herodes" --- Who is allowed to use the command above
wtime = 10 --- this is the time in seconds. .. Feel free to use the #*hours to say in # hours ... and  #*minutes to say in # minutes .. :)
frequency = 4 --- this is the number of warnings the user is going to receive within the predifined time limit
w2time = 10 --- this is the time that a user entering with below share limit for the second time while have to fill up the requirement
secfrequency = 2 --- this is how many times a user entering with below share limit for the second time is going to be warned in the time set by ' w2time ' variable.
limitshare = 500 * mb --- this sets the share limit that needs to be reached by the user so that he doesnt get the action .. :) keep format ex: 5 *gb is 5GB ... and so on
--- for the two variables below ( TheAction & The2Action ) use these ? 1 = disconnect , 2 = redirect , 3 = kick , 4 = tempban , 5 = ban, 6 = nickban, 7 = timeban, 8 = flood&disconnect ?
TheAction = 1 --- this sets the action to take against these ppl
The2Action = 8 --- this sets the action to take against the ppl that come back after they were given a first chance
bantime = 20 --- the time for the Time Ban action in minutes
floodTimes = 100 --- how many times the user may be flooded
floodMsg = "You should have done something about it ..." --- the message the user will be flooded with

--- // --- Script Starts
function Main()
frmHub:UnregBot(wsBot)
frmHub:RegBot(wsBot)
SetTimer(1000)
StartTimer()
bal = floor(wtime/frequency)
bal2 = floor(w2time/secfrequency)
DoBotInfo()
end

function OpConnected(user)
DoBotInfo(user)
end
--- // --- Actions to do if a new user is connected ... inform him about the time he has left to fill up his share if it is below the limit defined by ' limitshare ' variable
function NewUserConnected(user)
if user.sMyInfoString then
_,_,share = strfind(user.sMyInfoString, "%$(%d+)%$")
if tonumber(share) < limitshare then
if tUsers[user.sName] == nil then
if tAgain[user.sName] == 1 then
tAgain[user.sName] = nil
tMoreUsers[user.sName] = {}
tMoreUsers[user.sName][1] = 0
tMoreUsers[user.sName][2] = 1
user:SendPM(wsBot, "You come without having the required share of "..DoShareUnits(limitshare).." Again ?.Presently you are sharing "..DoShareUnits(tonumber(share))..".")
user:SendPM(wsBot, "You now have just "..DoTimeUnits(w2time).." left to fill it up. If you dont you are getting "..DoStringActions(The2Action)..".")
else
tUsers[user.sName] = {}
tUsers[user.sName][1] = 0
tUsers[user.sName][2] = 1
user:SendPM(wsBot, "Please fill up your share to reach "..DoShareUnits(limitshare)..". Presently you are sharing "..DoShareUnits(tonumber(share))..".")
user:SendPM(wsBot, " - You have another "..DoTimeUnits(wtime).." left.")
end
else
if tMoreUsers[user.sName] then
user:SendPM(wsBot, "Fill up your share to reach "..DoShareUnits(limitshare)..". Presently you are sharing "..DoShareUnits(tonumber(share))..".")
user:SendPM(wsBot, " - You have another "..DoTimeUnits(w2time - tMoreUsers[user.sName][1]).." left.")
else
user:SendPM(wsBot, "Please fill up your share to reach "..DoShareUnits(limitshare)..". Presently you are sharing "..DoShareUnits(tonumber(share))..".")
user:SendPM(wsBot, " - You have another "..DoTimeUnits(wtime - tUsers[user.sName][1]).." left.")
end
end
end
end
DoBotInfo(user)
end

function FloodU(user)
local cnt = 0
for i = 1, floodTimes do
cnt = cnt + 1
SendPmToNick(user.sName, wsBot, floodMsg.." "..cnt.."/"..floodTimes)
if (cnt == floodTimes) then
user:Disconnect()
end
end
end

function DoBotInfo(user)
InfoStr = "$MyINFO $ALL "..wsBot.." "..wsBotDesc.."<++V:0.4.6,M:A,H0/0/1,S:1>$ $LAN(T3)$"..wsBotEmail.."$0$|"
if user ~= nil then
user:SendData(InfoStr)
else SendToAll(InfoStr)
end
end
--- // --- Doing stuff on Timer ... that is every second ... under certain conditions the users are going to be warned or have actions casted on them ...
function OnTimer()
TakeCare(tUsers, wtime, bal, frequency, TheAction)
TakeCare(tMoreUsers, w2time, bal2, secfrequency, The2Action)
collectgarbage()
flush()
end

function TakeCare(table, timeallowed, balance, freq, doaction)
for user, time in table do
local usr = GetItemByName(user)
table[user][1] = table[user][1] + 1
if usr and usr.sMyInfoString then
_,_,share = strfind(usr.sMyInfoString, "%$(%d+)%$")
if tonumber(share) < limitshare then
if ( table[user][1] >= timeallowed ) then
usr:SendPM(wsBot, "You didnt fill up your share to fulfill hub requirements.")
return Act(usr, doaction)
elseif ( table[user][1] == balance * table[user][2] ) then
table[user][2] = table[user][2] + 1
usr:SendPM(wsBot, "Please fill up ur share ... "..(table[user][2]-1).."/ "..freq.." warnings ... on the last warning you will get "..DoStringActions(doaction)..".")
usr:SendPM(wsBot, "- You have another "..DoTimeUnits(timeallowed - table[user][1]).." left.")
end
else table[usr.sName] = nil
end
end
end
end


function DoStringActions(act)
local tActionStr = {
[1] = "Disconnected",
[2] = "Redirected",
[3] = "Kicked",
[4] = "Temporalily Banned",
[5] = "Banned",
[6] = "Banned",
[7] = "Time Banned",
[8] = "Flooded "..floodTimes.." times and then Disconnected",
};
return tActionStr[act]
end


function DataArrival(user, data)
if ( (user.sName == TheNick) and user.bOperator ) then
data = strsub(data,1,strlen(data)-1)
local s,e,cmd = strfind( data, "%b<>%s+(%S+)" )
if cmd == TheCmd then
local msg = "\r\n\t\t\t\t - ---==Users that are under the limit==--- -\r\n"
msg = msg..strrep(" -", 110).."\r\n"
msg = msg.."\t The following users are going to be "..DoStringActions(TheAction).." after their period of grace is over( initialy set to "..DoTimeUnits(wtime)..")\r\n"
msg = msg..strrep(" -", 110).."\r\n"..DoList(tUsers, wtime, frequency)
msg = msg..strrep(" -", 110).."\r\n\r\n"
msg = msg..strrep(" -", 110).."\r\n"
msg = msg.."\t The following users are going to be "..DoStringActions(The2Action).." after their period of grace is over ( initialy set to "..DoTimeUnits(w2time)..")\r\n"
msg = msg..strrep(" -", 110).."\r\n"..DoList(tMoreUsers, w2time, secfrequency)
msg = msg..strrep(" -", 110)
SendPmToNick(TheNick, wsBot, msg)
elseif cmd == DisCmd then
TableClear(tUsers)
TableClear(tMoreUsers)
end
end
end

function DoList(table, timeallowed, freq)
local msg = ""
local cnt = 0
for nick , time in table do
if GetItemByName(nick) then
status = "online"
else status = "offline"
end
cnt = cnt + 1
msg = msg..cnt..".\t - Nick : "..nick.."\t Time Left : "..DoTimeUnits(timeallowed - table[nick][1]).."\t Warnings : "..(table[nick][2]-1).."/ "..freq.."\t Status : "..status.."\r\n"
end
return msg
end

function TableClear(table)
for nick, v in table do
local usr = GetItemByName(nick)
if usr then
usr:SendPM(wsBot, TheNick.." said you have to leave because your share was not enough for this hub ...")
usr:Disconnect()
end
end
table = {}
end

--- // --- Transforming bytes Into KB, MB, GB, TB, PT and Returning the ideal (highest possible) Unit --- // ---
function DoShareUnits(intSize) --- Thanks to kepp and NotRambitWombat
if intSize ~= 0 then
local tUnits = { "Bytes", "KB", "MB", "GB", "TB" }
intSize = tonumber(intSize);
local sUnits;
for index = 1, getn(tUnits) do
if(intSize < 1024) then
sUnits = tUnits[index];
break;
else
intSize = intSize / 1024;
end
end
return format("%0.1f %s",intSize, sUnits);
else return "nothing"
end
end

--- // --- Performing action and also informing the user about it ... It is handled from the ' TheAction ' variable ....
function Act(user, var)
local tActions = {
[1] = function(user) user:SendPM(wsBot, "You will now be Disconnected") user:Disconnect() end,
[2] = function(user) user:SendPM(wsBot, "You will now be Redirected to "..frmHub:GetRedirectAddress()) user:SendData("$OpForceMove "..frmHub:GetRedirectAddress()) end,
[3] = function(user) user:SendPM(wsBot, "You will now be Kicked") user:Kick("You didn't meet the Hub's share requirements ...") user:Disconnect() end,
[4] = function(user) user:SendPM(wsBot, "You are temporalily Banned") user:TempBan() end,
[5] = function(user) user:SendPM(wsBot, "You are Banned") user:NickBan() end,
[6] = function(user) user:SendPM(wsBot, "You are permenantly Banned") user:Ban() end,
[7] = function(user) user:SendPM(wsBot, "You are Banned for "..bantime.." minutes.") user:TimeBan(bantime) end,
[8] = function(user) FloodU(user) end,
};
for i,v in tActions do
if i == var then
tUsers[user.sName] = nil
if ( (i ~= 3) or (i ~= 4) or (i ~= 5) or (i ~= 6) ) then
tAgain[user.sName] = 1
end
return tActions[i](user)
end
end
tActions = nil
end


function DoTimeUnits(time)
local tTimes = {}
local time = time * 1000
if ( time >= 86400000 ) then
repeat
if tTimes[4] then
tTimes[4] = tTimes[4] + 1
else tTimes[4] = 1
end
time = time - 86400000
until time < 86400000
end

if ( time >= 3600000 ) then
repeat
if tTimes[3] then
tTimes[3] = tTimes[3] + 1
else tTimes[3] = 1
end
time = time - 3600000
until time < 3600000
end

if ( time >= 60000 ) then
repeat
if tTimes[2] then
tTimes[2] = tTimes[2] + 1
else tTimes[2] = 1
end
time = time - 60000
until time < 60000
end

if ( time >= 1000 ) then
repeat
if tTimes[1] then
tTimes[1] = tTimes[1] + 1
else tTimes[1] = 1
end
time = time - 1000
until time < 1000
end
local msg = ""
local tTimeUns = { "seconds", "minutes", "hours", "days"}
for i,v in tTimes do
msg = v.." "..tTimeUns[i].." "..msg
end
return msg
end
--- // ---  Script Ends
Title:
Post by: Herodes on 13 August, 2004, 12:06:49
The above is yet another update ... grab and test ... please .. :) added some more stuff ...
Title:
Post by: Herodes on 14 August, 2004, 15:05:04
--- Version 5 Changes ---
--- added the ability to make custom limits for a user.
--- --- available limits are time allowed / number of warnings / share to reach / action to happen
--- Use the appropriate command ( ' CusCmd ' variable ) to set them
--- Added the display of custom limited users in the ' !noshare ' cmd ( ' TheCmd ' variable )
--- ( Last Update 14/8 - 2004 )

Grab It from here (http://www.plop.nl/ptokaxbots/Herodes.php)
Title:
Post by: ((UKSN))shad_dow on 14 August, 2004, 15:41:16
Dear Herodes

Well u done it again , the scripts getting better and better :)

:D keeping Ptokax alive and Kicking Ass

yours

shad
Title:
Post by: NightLitch on 15 August, 2004, 16:11:57
Progress is going fine I see, any idea I post my new build version ?? It will be easy to build on with other functions for users now.

/NL
Title:
Post by: NightLitch on 15 August, 2004, 18:46:24
Here's my new version give it a try and tell me what u think...

---------------------------------------------------------------------
-- Share Warn // By: NightLitch
-- Version: 0.1
-- Credits:
-- Kepp and Wombat for the ShareUnit func.
---------------------------------------------------------------------
KB = 1024
MB = KB*KB
GB = KB*KB*KB
TB = KB*KB*KB*KB
Sec  = 1000
Min  = 60*Sec
Hour = 60*Min
---------------------------------------------------------------------
-- Editable Data --
---------------------------------------------------------------------
-- Set Botname
BotName = "-Share-Warn-"
---------------------------------------------------------------------
-- Set NoShare Disconnection Time ( Hour, Min, Sec )
NoShareTime = { 1 , 30 , 0  }
-- Set Amount of Warnings before Disconnected
NoShareCounts = 3
---------------------------------------------------------------------
-- Set MinShare
NoMinShare = 500
-- Set Unit  ( MB, GB, TB )
NoMinUnit = MB
---------------------------------------------------------------------
-- Main Code Start Here, Don't Change anything
---------------------------------------------------------------------
NoShare = {}
UnitTable = {[MB] = "MB",[GB] = "GB",[TB] = "TB"}

function Main()
frmHub:RegBot(BotName)
SetTimer(1*Sec)
StartTimer()
end

function OnTimer()
for nick,table in NoShare do
NoShare[nick][2] = NoShare[nick][2] + 1
if NoShare[nick][2] == NoShareTime[1] * 60 * 60 + NoShareTime[2] * 60 + NoShareTime[3] then
NoShare[nick][3] = NoShare[nick][3] + 1
if NoShare[nick][3] > NoShareCounts then curUser = GetItemByName(nick)
if curUser then
local s,e,curShare = strfind(curUser.sMyInfoString, "(%d+)%$%|$")
if curShare then
if tonumber(curShare) == 0 then
SendPmToNick(curUser.sName, BotName, " You still share "..DoShareUnits(curShare))
SendPmToNick(curUser.sName, BotName, " You will be Disconnected...")
NoShare[curUser.sName] = nil
DisconnectByName(curUser.sName)
elseif tonumber(curShare) - tonumber(NoShare[nick][1]) <= NoMinShare * NoMinUnit then
SendPmToNick(curUser.sName, BotName, " You still share "..DoShareUnits(curShare))
SendPmToNick(curUser.sName, BotName, " You will be Disconnected...")
NoShare[curUser.sName] = nil
DisconnectByName(curUser.sName)
end
end
end
else
SendPmToNick(nick, BotName, " This is your "..NoShare[nick][3].." warning increase your share with "..NoMinShare.." "..UnitTable[NoMinUnit])
NoShare[nick] = {NoShare[nick][1], 0,NoShare[nick][3]}
SendToAll(NoShare[nick][3])
end
end
end
end

function DataArrival(sUser,sData)
if strsub(sData, 1,7) == "$MyINFO" then
local s,e,sShare = strfind(sData, "(%d+)%$%|$")
NoShare[sUser.sName] = {sShare, 0,0}
if tonumber(sShare) == 0 then
NoShare[sUser.sName] = {sShare, 0,0}
SendPmToNick(sUser.sName, BotName,"\t -------==[ NOTICE !! ]===================================================-------")
SendPmToNick(sUser.sName, BotName,"\t You're welcome to stay in this hub, BUT you need to fill your Share with "..NoMinShare.." "..UnitTable[NoMinUnit].." within "..TimeCalc(NoShareTime[1] * 60 * 60 + NoShareTime[2] * 60 + NoShareTime[3]).." to stay!")
SendPmToNick(sUser.sName, BotName,"\t -------===============================================================-------\r\n\r\n")
end
end
end

function TimeCalc(SC)
local Hours = floor(mod(SC/3600,24))
local Mins = floor(mod(SC/60,60))
local Secs = floor(mod(SC/1,60))
return  Hours.." Hours, "..Mins.." Minutes and "..Secs.." Seconds"
end

function DoShareUnits(intSize)
if tonumber(intSize) ~= 0 then
local tUnits = { "Bytes", "KB", "MB", "GB", "TB" }
intSize = tonumber(intSize);
local sUnits;
for index = 1, getn(tUnits) do
if(intSize < 1024) then
sUnits = tUnits[index];
break;
else
intSize = intSize / 1024;
end
end
return format("%0.1f %s",intSize, sUnits);
else
return "nothing"
end
end

Not as many features as Herodes but I can input some requests if u tell me what is absolutelly needed...

Cheers / NL
Title:
Post by: Herodes on 15 August, 2004, 19:30:56
"grrr Nightlitch tries to make a more clean code than mine" Lol  
Nice going Nl ... happy to see u are not off this thread :))

I grabbed and off to test it :)
Title:
Post by: NightLitch on 15 August, 2004, 19:59:48
QuoteOriginally posted by Herodes
"grrr Nightlitch tries to make a more clean code than mine" Lol  
Nice going Nl ... happy to see u are not off this thread :))

I grabbed and off to test it :)

Nice, maybe u get some ideas then.. heh...

I think that one is Rather Ok, if not tell me whats wrong...

/NL
Title:
Post by: Herodes on 16 August, 2004, 01:04:30
Nightlitch you are on my teachers-list already ;)
thanks for all the work u have done till now ...

Nthing wrong to report :)
Title:
Post by: QuikThinker on 18 August, 2004, 16:57:35
I NEED this script does it work alongside RoboCop's reggin system?
Title:
Post by: Herodes on 18 August, 2004, 18:52:23
QuoteOriginally posted by QuikThinker
I NEED this script does it work alongside RoboCop's reggin system?
how do you mean ? (btw I havent tested beside any major bots .. )
Title:
Post by: stinger on 22 August, 2004, 17:58:43
Hi there...

               

--- Version 5 Changes ---
--- added the ability to make custom limits for a user.
--- --- available limits are time allowed / number of warnings / share to reach / action to happen
--- Use the appropriate command ( ' CusCmd ' variable ) to set them
--- Added the display of custom limited users in the ' !noshare ' cmd ( ' TheCmd ' variable )
--- ( Last Update 14/8 - 2004 )

Grab It from here <<<----------

link didn't work
Title:
Post by: Herodes on 22 August, 2004, 18:30:27
Yep ... I know ... the site is down at the moment ... I'll see if I can find somewhere to post it ... atm it doesnt fit in a single post ... and I hate posting multiple posts for 1 script ...
Title:
Post by: Herodes on 23 August, 2004, 12:33:16
[*Note*] The link now works ...
Title:
Post by: jiten on 03 September, 2004, 12:57:17
where can I find the link to version 5, Herodes?
Title:
Post by: Herodes on 03 September, 2004, 15:56:35
There is a link up this thread ..

But you can also Grab It from here (http://www.plop.nl/ptokaxbots/Herodes.php)