Regcleaner for ptokax 16.09
 

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

Regcleaner for ptokax 16.09

Started by [_XStaTiC_], 30 March, 2005, 14:36:58

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

[_XStaTiC_]

Ok guy's.. I have modyfied Plop's Regcleaner for myself, but i post it here also. Hope you like it

I removed the seen part from the script.. don't use it.

You have to make a directory named "logs" in the directory scripts.



-- auto/manual registered user cleaner if user hasn't been in the hub for x weeks
-- made by plop
-- julian day function made by the guru tezlo
-- code stripped from artificial insanety bot
-- updated to LUA 5 by Pothead
-- updated to PtokaX 16.09 by [_XStaTiC_]  Removed the seen part sorry :) i don't use it :)

-- !noclean  add/remove  - adds/removes users from/to the list which aren't cleaned
-- !showusers - shows all registered users
-- removed ----!seen  - shows the last time the user left the hub
-- !shownoclean - shows all names wich are on the noclean list
-- !cleanusers - manualy start the usercleaner

--------------------------------------------------------------------- config
WEEKS = 2    -- every1 older then x weeks is deleted
Bot = "Plop" -- the bot Name...
AUTO = 1   -- use 1 for automode, 0 for manual
CleanLevels = {[3]=1,[2]=1} -- levels it needs 2 clean 3=reg 2=vip

--------------------------------------------------------------------- the needed tables
CleanUser = {}
NoClean = {}
--------------------------------------------------------------------- julian day function 2 calcute the time users spend in the hub
function jdate(d, m, y)
	local a, b, c = 0, 0, 0
	if m <= 2 then
		y = y - 1
		m = m + 12
	end
	if (y*10000 + m*100 + d) >= 15821015 then
		a = math.floor(y/100)
		b = 2 - a + math.floor(a/4)
	end
	if y <= 0 then c = 0.75 end
	return math.floor(365.25*y - c) + math.floor(30.6001*(m+1) + d + 1720994 + b)
end

--------------------------------------------------------------------- loading the CleanUser database
function LoadCleanUser()
	filename = "logs/CleanUser.lst"
	if not io.open(filename, "r") then
		local File = io.open( filename, "w" )
		File:flush();
		File:close();   
	end	
	local file = io.open(filename, "r")
	for line in file:lines() do
		local s,e,name,date = string.find(line, "(.+)$(.+)")
		if name ~= nil then
			CleanUser[name]=date
		end
	end
	file:flush()	
	file:close()	
end

--------------------------------------------------------------------- saving CleanUser date
function SaveCleanUser()
	filename = "logs/CleanUser.lst"
	local file = io.open(filename, "w+")
	for a,b in CleanUser do
		CleanUser[a]=b
		file:write(a.."$"..b.."\n")
	end
	file:flush()
	file:close()
end

--------------------------------------------------------------------- call the garbage man
function Clear() 
	collectgarbage() 
end 

--------------------------------------------------------------------- shows all the nicks of all registered users
function NewShowUsers(user,data)
	local s,e,Profile = string.find(data, "%b<>%s+%S+%s+(%S+)")
        if Profile == nil then 
	user:SendData(Bot, "RTFM ;). it's !showusers |")
        return 1
        end
	local lines = {}
	local info = "\r\n\r\n"
	info = info.."  Here are the registered users with Profile ("..Profile..")\r\n"
	info = info.."=====================================\r\n"
        UsersTable = GetUsersByProfile(Profile)
	for a,b in UsersTable do
		table.insert(lines, b)
	end
	table.sort(lines)
	for i=1,table.getn(lines) do 
		info = info.."  "..lines[i].."\r\n"
	end
	info = info.."=====================================\r\n"
	user:SendPM(Bot, info.." |")
	Clear()
end

--------------------------------------------------------------------- shows all the nicks on the no clean list
function ShowNoClean(user)
	local lines =  {}
	local info = "\r\n\r\n"
	info = info.." Here are the users who aren't cleaned\r\n"
	info = info.."=====================================\r\n"
	for a,b in NoClean do
		table.insert(lines, a)
	end
	table.sort(lines)
	for i=1,table.getn(lines) do 
		info = info.."  "..lines[i].."\r\n"
	end
	info = info.."=====================================\r\n"
	user:SendPM(Bot, info.." |")
	Clear()
end

--------------------------------------------------------------------- cleanup old users
function CleanUsers()
	SendToAll(Bot, "The_Cleaner has been called. Every registered user who hasn't been in the hub for "..WEEKS.." weeks will be deleted. (contact the OP's if your gone be away for a period longer then that)|")
	local s,e,month,day,year = string.find(os.date("%x"), "(%d+)%/(%d+)%/(%d+)")
	year = "20"..year
	local juliannow = jdate(tonumber(day), tonumber(month), tonumber(year))
	local oldest = WEEKS*7
	local Count2,Count = 0,0
	for a,b in CleanLevels do
        clean = GetProfileName(a)
        UsersTable = GetUsersByProfile(clean)
	for a,b in UsersTable do
		Count = Count+1
		if CleanUser[b] then
			if NoClean[b]== nil then 
				local s,e,monthu,dayu,yearu = string.find(CleanUser[b], "(%d+)%/(%d+)%/(%d+)")
				yearu = "20"..yearu
				local julianu = jdate(tonumber(dayu), tonumber(monthu), tonumber(yearu))
				if (juliannow - julianu) > oldest then
					Count2 = Count2 +1
					CleanUser[b] = nil
					DelRegUser(b)
				end
			end 
     
		else
			CleanUser[b] = os.date("%x")
		end
	   end 
     end
 
	if Count ~= 0 then
		SendToAll(Bot, Count.." users were procest, "..Count2.." of them were deleted.|")
                else
                SendToAll(Bot,"Nobody 2clean :(")
	end
	SaveCleanUser()
        UsersTable = ""
end

--------------------------------------------------------------------- don't clean this users adding/removing
function NoCleanUser(user, data)
	local s,e,who, addrem = string.find(data, "%b<>%s+%S+%s+(%S+)%s+(%S+)%s*")
	if (who or addrem) == nil then
		user:SendData(Bot, "RTFM ;). it's !noclean  |")
	elseif frmHub:isNickRegged(who) ~= nil then
		if addrem == "add" then
			if NoClean[who] then
				user:SendData(Bot, who.." is allready on the imune list.|")
			else
				NoClean[who] = 1
				user:SendData(Bot, who.." is added to the imune list and won't be cleaned.|")
				SaveNoClean()
			end
		elseif addrem == "remove" then
			if NoClean[who] then
				NoClean[who] = nil
				user:SendData(Bot, who.." is removed from the imune list.|")
				SaveNoClean()
			else
				user:SendData(Bot, who.." was not on the imune list.|")
			end
		else
			user:SendData(Bot, "RTFM ;). it's !noclean  |")
		end
	else
		user:SendData(Bot, who.." isn't a registered user.|")
	end
end

--------------------------------------------------------------------- saving CleanUser date
function SaveNoClean()
	filename = "logs/noclean.lst"
	local file = io.open(filename, "w+") 
	for a,b in NoClean do
		file:write(a.."\n")
	end
	file:flush()
	file:close()
end

--------------------------------------------------------------------- load no clean users from file
function LoadNoClean()
	filename = "logs/noclean.lst"
	if not io.open(filename, "r") then
		local File = io.open( filename, "w" )
		File:flush();
		File:close();   
	end
   	local file = io.open(filename, "r") 
	for line in file:lines() do   	
		NoClean[line] = 1   	   
	end 
	file:flush()	
	file:close()   
end

--------------------------------------------------------------------- do i need 2 explain this ?????
function ChatArrival(user, data) 
	if AUTO == 1 then
		if CleanDay ~= os.date("%x") then -- user cleaning trigger, works as a timer without a timer
			CleanDay = os.date("%x")
			CleanUsers()
		end
	end
	if( string.sub(data, 1, 1) == "<" ) then 
		if user.bOperator then
			data=string.sub(data,1,string.len(data)-1) 
			s,e,cmd = string.find(data,"%b<>%s+(%S+)") 
			if cmd == "!noclean" then
				NoCleanUser(user, data)
				return 1
			elseif cmd == "!showusers" then
				NewShowUsers(user, data)
				return 1
			elseif cmd == "!shownoclean" then
				ShowNoClean(user)
				return 1
			elseif cmd =="!cleanusers" then
				CleanUsers()
				return 1

			end
		end
	end
end
--------------------------------------------------------------------- stuff done when a user/vip leaves or come
 

function NewUserConnected(user)
	if CleanUser[user.sName] then
		CleanUser[user.sName] = nil
		SaveCleanUser()
	end
end

function UserDisconnected(user) 
	if CleanLevels[user.iProfile]==1 then
		CleanUser[user.sName]=os.date("%x")
		SaveCleanUser()
	end
end

OpConnected = NewUserConnected
OpDisconnected = UserDisconnected

--------------------------------------------------------------------- stuff done on bot startup
function Main()
	LoadNoClean()
	LoadCleanUser()
	CleanDay = os.date("%x")
end

Herodes

done another version based on this one .. it is in the L5 Finished Scripts section ..

SMF spam blocked by CleanTalk