Please need warrning share bot!!!
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

Please need warrning share bot!!!

Started by juda, 10 August, 2004, 15:09:41

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

juda

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
juda

NightLitch

the amount of share every 12 hour does it matter what size the user downloads and share ?

I accept this challange.

/NL
//NL

NightLitch

#2
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
//NL

Herodes

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 ---
-------- -------- -------- -------- -------- -------- -------- --------

Herodes

#4
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 ---
-------- -------- -------- -------- -------- -------- -------- --------

juda

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
juda

juda

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 !!!
juda

juda

== 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
juda

NightLitch

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
//NL

Herodes

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 ...

juda

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
juda

Herodes

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

juda

--------------------------------------------------------
--// 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
juda

NightLitch

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
//NL

NightLitch

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
//NL

NightLitch

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
//NL

juda

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
juda

Herodes

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 ...

Herodes

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 .

Herodes

#19
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 ---
-------- -------- -------- -------- -------- -------- -------- --------

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
//NL

EXNET OWNER

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

Herodes

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 :)

Herodes

#23
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

EXNET OWNER

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 ;)

SMF spam blocked by CleanTalk