Usercleaner
 

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

Usercleaner

Started by Ajax, 03 June, 2005, 21:07:50

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Ajax

Thise is a good working usercleaner its cleant only regusers not vips ops ore master.


    -- 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
    -- usercommands support added by Plop

    -- !noclean add/remove - adds/removes users from/to the list which aren't cleaned
    -- !showusers - shows all registered users
    -- !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 = frmHub:GetHubBotName()
    AUTO = 1 -- use 1 for automode, 0 for manual
    CleanLevels = {[1]=1,[2]=1,[3]=1,[4]=1} -- levels it needs 2 clean (0=Master, 1=Operator, 2=Vip, 3=Reg, 4=Moderator, 5=Netfounder)

    -- 1=on / 0=off Send Commands
    SendTo = {
    [0] = 1, -- Masters
    [1] = 1, -- Operators
    [2] = 0, -- Vips
    [3] = 0, -- Regs
    [4] = 1, -- Moderator
    [5] = 1, -- NetFounder
    [-1] = 0, -- Users
    }

    rMenu = "-=Raptor's Cleaner=-" -- The User Cleaner

    function NewUserConnected(user)
    if (SendTo[user.iProfile]==1) then
    user:SendData("$UserCommand 0 3 |")
    customCMDs(user)
    end
    end

    OpConnected=NewUserConnected

    function customCMDs(user)
    user:SendData("$UserCommand 1 3 "..rMenu.."\\Add/Remove Users From UserCleaner List$<%[mynick]> !noclean %[nick] %[line:add/remove]||")
    user:SendData("$UserCommand 1 3 "..rMenu.."\\Show Users That Wont Be Cleaned$<%[mynick]> !shownoclean||")
    user:SendData("$UserCommand 1 3 "..rMenu.."\\Shows All Regged Users$<%[mynick]> !showusers||")
    user:SendData("$UserCommand 1 3 "..rMenu.."\\Manualy Starts The UserCleaner$<%[mynick]> !cleanusers||")
    user:SendData("$UserCommand 1 3 "..rMenu.."\\Shows The Last Time The User Left The Hub$<%[mynick]> !seen %[nick]||")
    end

    --------------------------------------------------------------------- the needed tables
    UsersTable = {}
    Seen = {}
    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 last seen database
    function LoadLastSeen()
    filename = "../logs/lastseen.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") -- "r" read
    for line in file:lines() do
    local s,e,name,date = string.find(line, "(.+)$(.+)")
    if name ~= nil then
    Seen[name]=date
    end
    end
    file:flush()
    file:close()
    end

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

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

    --------------------------------------------------------------------- opening the registered users file from ptokax and inserting the users into the table
    function OpenRegisterdUsersFile()
    filename = "../RegisteredUsers.dat"
    UsersTable = nil
    Clear()
    UsersTable = {}
    local file = io.open(filename, "r") -- "r" read
    for line in file:lines() do
    local name, level
    s,e,name,level = string.find(line,"(.+)|.+|(.+)")
    if CleanLevels[tonumber(level)] then
    UsersTable[name] = 1
    end
    end
    file:flush()
    file:close()
    end

    --------------------------------------------------------------------- extracting the time/date when a user was last seen from the database
    function SeenUser(user, data)
    s,e,who = string.find(data, "%b<>%s%S+%s(.+)")
    if who == nil then
    user:SendData(Bot, "Syntax error, can't read your mind, pls tell me wich user you wanne check|")
    elseif Seen[who] then
    user:SendData(Bot, who.." was last seen on: "..Seen[who].."|")
    else
    user:SendData(Bot, who.." is a unknown user|")
    end
    end

    --------------------------------------------------------------------- shows all the nicks of all registered users
    function NewShowUsers(user)
    local lines = {}
    local info = "\r\n\r\n"
    info = info.." Here are the registered users\r\n"
    info = info.."=====================================\r\n"
    for a,b in UsersTable do
    table.insert(lines, a)
    end
    table.sort(lines)
    for i=1,table.getn(lines) do
    info = info.." "..lines.."\r\n"
    end
    info = info.."=====================================\r\n"
    user:SendData(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.."\r\n"
    end
    info = info.."=====================================\r\n"
    user:SendData(Bot, info.." |")
    Clear()
    end

    --------------------------------------------------------------------- cleanup old users
    function CleanUsers()
    SendToAll(Bot, "The Usercleaner 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)|")
    OpenRegisterdUsersFile()
    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 UsersTable do
    Count = Count+1
    if Seen[a] then
    if NoClean[a]== nil then
    local s,e,monthu,dayu,yearu = string.find(Seen[a], "(%d+)%/(%d+)%/(%d+)")
    yearu = "20"..yearu
    local julianu = jdate(tonumber(dayu), tonumber(monthu), tonumber(yearu))
    if (juliannow - julianu) > oldest then
    Count2 = Count2 +1
    Seen[a] = nil
    DelRegUser(a)
    end
    end
    else
    Seen[a] = os.date("%x")
    end
    end
    if Count ~= 0 then
    SendToAll(Bot, Count.." users were procest, "..Count2.." of them were deleted.|")
    end
    SaveSeen()
    OpenRegisterdUsersFile()
    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 UsersTable[who] 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 last seen date
    function SaveNoClean()
    filename = "../logs/noclean.lst"
    local file = io.open(filename, "w+") -- "w" write
    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") -- "r" read
    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)
    return 1
    elseif cmd == "!shownoclean" then
    ShowNoClean(user)
    return 1
    elseif cmd == "!seen" then
    SeenUser(user, data)
    return 1
    elseif cmd =="!cleanusers" then
    CleanUsers()
    return 1
    end
    end
    end
    end

    --------------------------------------------------------------------- stuff done when a user/vip leaves
    function UserDisconnected(user)
    if UsersTable[user.sName] then
    Seen[user.sName]=os.date("%x")
    SaveSeen()
    end
    end

    --------------------------------------------------------------------- do the same stuff for op's if needed
    function OpDisconnected(user)
    if UsersTable[user.sName] then
    Seen[user.sName]=os.date("%x")
    SaveSeen()
    end
    end

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





:evil:

bastya_elvtars

What the fuck is going on this week? All of my friends and me failed on exams, hublist.org stuff, and now stealing of code. this was originally writteny by [size=18]plop[/size].

This is not normal. A cataclism is to come. Please save all your data.
Everything could have been anything else and it would have just as much meaning.

Ajax

#2
yes
:evil:

plop

QuoteOriginally posted by Ajax
yes

then keep my name in it.
thats all i ask, or is that 2 much ?

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

Dessamator

well in theory it says it was stripped from a.i, which was made by plop, :),
Ignorance is Bliss.

Ajax

#5
so good
:evil:

plop

#6
QuoteOriginally posted by Ajax
so good

thx, just the user commands aren't my work.
i made the original lua 4 version and pothead converted it to lua 5.

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

sneaky

UserCleaner.lua:114: attempt to index local `file' (a nil value)

i get this error when i was running the UserCleaner lua. anyone can help me? plz

SMF spam blocked by CleanTalk