Inactive users
 

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

Inactive users

Started by uffetjur, 15 March, 2008, 14:33:41

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

uffetjur

I'm i a kneed for a script that drops / timeban /kicks users who has been inactice for 24 hours - no posts in PM or main, this for my reghub to keep it cleen from iinactive users!
Somewhere in Cyberspace

Gnuff?

Quote from: uffetjur on 15 March, 2008, 14:33:41
I'm i a kneed for a script that drops / timeban /kicks users who has been inactice for 24 hours - no posts in PM or main, this for my reghub to keep it cleen from iinactive users!

If that?s what you want, you can be sure your hub will be very empty in short time.
You are in other word forcing users to post in the hub every day, or else they will get kicked, some people have a job too you know  :D
Gnuff

uffetjur

#2
as i poinetd out is a hub for speedtest and users are not allowed to download from each other. the only reason for them to enter this hub is to get their share and speed checked!
Somewhere in Cyberspace

Madman

-- K I U - Kill Inactive User
-- Made by Madman
-- Requested by uffetjur

tConfig = {
	Bot = "KIU",
	Action = "drop", -- drops / timeban /kick
	Msg = "You have been [action] beacuse you havent written a pm or posted in main for [time]",
	-- [action] and [time] will be auto replaced with:
	-- [action] is the action written in tConfig.Action
	-- [time] is the settings written in tConfig.Time table
	BanTime = 20, -- Time in Minutes
	Time = {
		Nr = 10,
		Unit = "second",
	},
	IgnoreCmd = nil,
	-- Set to 1 to ignore cmd's as posts in main/pm
	-- Set to nil to count cmd's as post in main/pm
}

-- Time Definition
Sec  = 1000
Min  = 60*Sec
Hour = 60*Min
Day  = 24*Hour

function OnStartup()
	timID = TmrMan.AddTimer(Min*30) -- Check every 30 min
	tUsers = {} -- Store the users...
end

function UserConnected(user)
	if tUsers[user.sNick] == nil then
		local tTime = os.date("*t")
		tUsers[user.sNick] = {}
		tUsers[user.sNick]["year"] = tTime.year
		tUsers[user.sNick]["month"] = tTime.month
		tUsers[user.sNick]["day"] = tTime.day
		tUsers[user.sNick]["hour"] = tTime.hour
		tUsers[user.sNick]["min"] = tTime.min
		tUsers[user.sNick]["sec"] = tTime.sec
	end
end

function ChatArrival(user,data)
	if tConfig.IgnoreCmd then
		local _,_,cmd = string.find(data,"%b<>%s+%p(%S+)")
		if cmd then
			-- Do Cmds
		else
			TimeChange(user)
		end
	else
		TimeChange(user)
	end
end

ToArrival = ChatArrival

function TimeChange(user)
	local tTime = os.date("*t") -- Get time
	if not tUsers[user.sNick] then -- If user not in table
		tUsers[user.sNick] = {} -- Create table
	end
	tUsers[user.sNick]["year"] = tTime.year
	tUsers[user.sNick]["month"] = tTime.month
	tUsers[user.sNick]["day"] = tTime.day
	tUsers[user.sNick]["hour"] = tTime.hour
	tUsers[user.sNick]["min"] = tTime.min
	tUsers[user.sNick]["sec"] = tTime.sec
end

function OnTimer(ID)
	if ID == timID then
		for i,_ in pairs(tUsers) do -- Loop user table
			t = tUsers[i]
			t = os.time(t)
			local c,d = Convert(t)
			if c >= tConfig.Time.Nr and d == tConfig.Time.Unit then -- Check if it's been 24 hours or more
				dead = Core.GetUser(i) -- Get online user
				if dead then
					Msg = string.gsub(tConfig.Msg,"%[action%]",tConfig.Action.."ed") -- Change [action] to the word in tConfig.Action and add ed after it
					Msg = string.gsub(Msg,"%[time%]",tConfig.Time.Nr.." "..tConfig.Time.Unit.."s") -- Change [time] to settings in tConfig.Time table
					Msg = string.gsub(Msg,"tempbaned", "tempbanned for "..tConfig.BanTime) -- If tempbaned is found correct it to tempbanned and add time
					Core.SendToUser(dead,Msg) -- Send msg
					if tConfig.Action == "drop" then
						Core.Disconnect(dead)
					elseif tConfig.Action == "tempban" then
						BanMan.TempBan(dead, tConfig.BanTime, Msg, tConfig.Bot,false)
					elseif tConfig.Action == "kick" then
						Core.Kick(dead, tConfig.Bot, Msg)
					else -- if Action is set wrong, inform to opchat
						Core.SendToOpChat(tConfig.Bot.. " has an invaild Action configed, it's set to " ..tConfig.Action.. ". It should be drop/kick or tempban, Please ask the owner to change it")
					end
				end
				tUsers[dead.sNick] = nil -- remove user from table
			else
				-- Just some test code
				--Core.SendToAll("<"..tConfig.Bot.."> It's been ["..c.." "..d.."] since " ..i.. "|")
			end
		end
	end
end

Convert = function(time)
	-- Made by Mutor
	-- EventBot 1.0b LUA 5.11 [Strict][API 2]
	-- Modded by Madman
	if time then
		local s,x,n = "",0,os.time()
		local tab = {{31556926,"year"},{2592000,"month"},{604800,"week"},
		{86400,"day"},{3600,"hour"},{60,"minute"},{1,"second"}}
		if time > 0 then
			if time < 2145876659 then
				if n > time then
					time = n - time
				elseif n < time then
					time = time - n
				end
				for i,v in ipairs(tab) do
					if time > v[1] then
						x = math.floor(time/v[1])
						--if x > 1 then v[2] = v[2].."s" end
						if x > 1 then v[2] = v[2] end
						if x > 0 then
							--s = s..x.." "..v[2]..", "
							x = x
							t = v[2]
							time = time-x*v[1]
						end
					end
				end
				collectgarbage("collect")
				return x,t--s:sub(1,-3)
			else
				return "Invalid date or time supplied. [must be pre 12/31/2037]"
			end
		else
			return "Invalid date or time supplied. [must be post 01/01/1970]"
		end
	else
		return "Invalid date or time supplied."
	end
end


This should do what you want...
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

Madman

-- K I U - Kill Inactive User
-- Made by Madman
-- Requested by uffetjur

-- Version 0.2
-- os.time now directly added to table, less code, suggested by Mutor

tConfig = {
	Bot = "KIU",
	Action = "drop", -- drops / timeban /kick
	Msg = "You have been [action] beacuse you havent written a pm or posted in main for [time]",
	-- [action] and [time] will be auto replaced with:
	-- [action] is the action written in tConfig.Action
	-- [time] is the settings written in tConfig.Time table
	BanTime = 20, -- Time in Minutes
	Time = {
		Nr = 24,
		Unit = "hour",
	},
	IgnoreCmd = nil,
	-- Set to 1 to ignore cmd's as posts in main/pm
	-- Set to nil to count cmd's as post in main/pm
}

-- Time Definition
Sec  = 1000
Min  = 60*Sec
Hour = 60*Min
Day  = 24*Hour

function OnStartup()
	timID = TmrMan.AddTimer(Min*30) -- Check every 30 min
	tUsers = {} -- Store the users...
end

function UserConnected(user)
	if tUsers[user.sNick] == nil then
		tUsers[user.sNick] = {}
		tUsers[user.sNick] = os.date("*t")
	end
end

function ChatArrival(user,data)
	if tConfig.IgnoreCmd then
		local _,_,cmd = string.find(data,"%b<>%s+%p(%S+)")
		if cmd then
			-- Do Cmds
		else
			TimeChange(user)
		end
	else
		TimeChange(user)
	end
end

ToArrival = ChatArrival

function TimeChange(user)
	if not tUsers[user.sNick] then -- If user not in table
		tUsers[user.sNick] = {} -- Create table
	end
	tUsers[user.sNick] = os.date("*t") -- Get time
end

function OnTimer(ID)
	if ID == timID then
		for i,_ in pairs(tUsers) do -- Loop user table
			t = tUsers[i]
			t = os.time(t)
			local c,d = Convert(t)
			if c >= tConfig.Time.Nr and d == tConfig.Time.Unit then -- Check if it's been 24 hours or more
				dead = Core.GetUser(i) -- Get online user
				if dead then
					Msg = string.gsub(tConfig.Msg,"%[action%]",tConfig.Action.."ed") -- Change [action] to the word in tConfig.Action and add ed after it
					Msg = string.gsub(Msg,"%[time%]",tConfig.Time.Nr.." "..tConfig.Time.Unit.."s") -- Change [time] to settings in tConfig.Time table
					Msg = string.gsub(Msg,"tempbaned", "tempbanned for "..tConfig.BanTime) -- If tempbaned is found correct it to tempbanned and add time
					Core.SendToUser(dead,Msg) -- Send msg
					if tConfig.Action == "drop" then
						Core.Disconnect(dead)
					elseif tConfig.Action == "tempban" then
						BanMan.TempBan(dead, tConfig.BanTime, Msg, tConfig.Bot,false)
					elseif tConfig.Action == "kick" then
						Core.Kick(dead, tConfig.Bot, Msg)
					else -- if Action is set wrong, inform to opchat
						Core.SendToOpChat(tConfig.Bot.. " has an invaild Action configed, it's set to " ..tConfig.Action.. ". It should be drop/kick or tempban, Please ask the owner to change it")
					end
				end
				tUsers[dead.sNick] = nil -- remove user from table
			else
				-- Just some test code
				--Core.SendToAll("<"..tConfig.Bot.."> It's been ["..c.." "..d.."] since " ..i.. "|")
			end
		end
	end
end

Convert = function(time)
	-- Made by Mutor
	-- EventBot 1.0b LUA 5.11 [Strict][API 2]
	-- Modded by Madman
	if time then
		local s,x,n = "",0,os.time()
		local tab = {{31556926,"year"},{2592000,"month"},{604800,"week"},
		{86400,"day"},{3600,"hour"},{60,"minute"},{1,"second"}}
		if time > 0 then
			if time < 2145876659 then
				if n > time then
					time = n - time
				elseif n < time then
					time = time - n
				end
				for i,v in ipairs(tab) do
					if time > v[1] then
						x = math.floor(time/v[1])
						--if x > 1 then v[2] = v[2].."s" end
						if x > 1 then v[2] = v[2] end
						if x > 0 then
							--s = s..x.." "..v[2]..", "
							x = x
							t = v[2]
							time = time-x*v[1]
						end
					end
				end
				collectgarbage("collect")
				return x,t--s:sub(1,-3)
			else
				return "Invalid date or time supplied. [must be pre 12/31/2037]"
			end
		else
			return "Invalid date or time supplied. [must be post 01/01/1970]"
		end
	else
		return "Invalid date or time supplied."
	end
end
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

uffetjur

thanks for a great and fast help to cover my kneed!

- Then Sir, what has chat or pm have to do with it?

Only reason for users to get into that hub is to get in contact with our private hub crew for registrering purposals, and if they dont do that via pm or post in main they have nothing to do their!
Somewhere in Cyberspace

SMF spam blocked by CleanTalk