Hi
I need a bot that would delete users that have not logged in for 4 weeks.
But I also need it to have a immune user list, MODs should be able to edit this list.
Thank you very much
Supporting this request, but is very hard to do it, is a question for plop or tezlo or for all scripters together, probaly it can not make it now because registerusers.dat does not preserve the original date when the user was registered, and also user statictics are not working good at least with last beta builds is not available.
dunno wasn't actually too hard...
its not doing by the reg date cause as you said its not in the reg.dat but it delets the account after a few days , you set it.
but not userlist.
Logger does it :)
hmm, you don't catch the point
you need to know what accounts delete and for this you need to know that the account have been not used by XX days so, for this you need to have an statistic file to compares last date of user connection to current date in hosted machine. With both values you have to do something like:
If (currentdate - last connectiondate) >= time then
delete user account
display op message
end
For do this you need to work in the following 3 ways:
1.- Using statistics generated by ptokax
Some problems are implyed here because statistics in public releases are buggy and in the betas is temporarily disable besides you need to retrieve the info stored in a .mdb database and is not easy all time.
2.- Using a file generated through lua script to store statistics. Could be a temporal solution.
Problems: High resources consuming, in busy hubs long txt file is generated.
3.- Using registeredusers.dat.
Problem: currently imposible because date of creation the account is not stored actually to work with lua support.
A feature request for new ptokax could be this, perhaps something like:
frmHub:GetAccountDate(NickName)
Ptacek is the only one for take care about point 3.
QuoteOriginally posted by [ES]latinmusic
Supporting this request, but is very hard to do it, is a question for plop or tezlo or for all scripters together, probaly it can not make it now because registerusers.dat does not preserve the original date when the user was registered, and also user statictics are not working good at least with last beta builds is not available.
am i that good ????? lol
it's posible if you use the !seen bot, but i won't suggest 2 make it run on a timer because it can be using a lot of resources.
using a normal command wich can be triggered on your request (moments when the hub is quiet/sleeping) is much better.
just go thru the regusers file step for step and check the date from !seen and if older then the time you want delete the account.
like chilla said, it's not that hard 2 do.
gone put it on my 2 do list for a.i. bot and when done i'll release it as stand alone script.
when i don't know, bit busy here but i sure love the idea.
plop
QuoteOriginally posted by plop
i won't suggest 2 make it run on a timer because it can be using a lot of resources. using a normal command which can be triggered on your request (moments when the hub is quiet/sleeping) is much better.
It would be great if it could run once a day (say midnight with an option to turn the timer off) and by command.
But I really need the 'immune user list', this list is for users that have informed a MOD that they will be away from the hub for longer than 4 weeks. The MOD then adds user's nick to the 'immune user list'.
So when the bot is running and finds a user that has not connected for over 4 weeks, it would check against the 'immune user list' before deleting that user.
Thank you very much for all your help!!!!! :D :D
es, sorry must disagree..
if i say it does it then it does ;).
and there are easier ways to do it.. well.
okey since you can't get the regged date.. and I don't work with the user stat i did it a other simpler way.
plop I use a timer, but it only triggers once a day.. and I calculated the time used to run though a table with like 1000000 entries.. its not much compared to one day. around 10 seconds.. okey the kernel fucks it up anyways, but its around that time...
QuoteOriginally posted by c h i l l a
es, sorry must disagree..
if i say it does it then it does ;).
and there are easier ways to do it.. well.
okey since you can't get the regged date.. and I don't work with the user stat i did it a other simpler way.
plop I use a timer, but it only triggers once a day.. and I calculated the time used to run though a table with like 1000000 entries.. its not much compared to one day. around 10 seconds.. okey the kernel fucks it up anyways, but its around that time...
i should take a close look @ your logger bot, only had a quick look @ it so far.
sure want 2 see how you solved this.
for me personaly if something lasts 10 secs i'm gone get some complaining hub owners in pm. lol
plop
well plop i did it simply... i just tiggers once a day.. and if the user isn't there then he geth +1 in Inactive...
if he does log in again then Inactive = -1 again...
but if you think then I guess the table wouldn't really get bigger than 100.000 entries.. and that only with really big hubs holding ore than 1000 users, so it would take 1 second maximum....
but that is just my script cause it loggs the user as well so I have hold all logged users + regged users... but if you only hold regged useres in your table then... it will be smaller for sure...
QuoteOriginally posted by c h i l l a
well plop i did it simply... i just tiggers once a day.. and if the user isn't there then he geth +1 in Inactive...
if he does log in again then Inactive = -1 again...
but if you think then I guess the table wouldn't really get bigger than 100.000 entries.. and that only with really big hubs holding ore than 1000 users, so it would take 1 second maximum....
but that is just my script cause it loggs the user as well so I have hold all logged users + regged users... but if you only hold regged useres in your table then... it will be smaller for sure...
thats indeed a nice and simple way, not full proof but working.
the time it takes can easely be checked.
put this on the 1st line on the function.
check = clock()
and this on the last.
SendToAll(Bot, clock()-check)
1 of our hub's has 600 - 1400 users and yes i got a table for the regged users.
also got 1 if the bot has 2 calculate how long a user has/is in the hub.
this last 1 is better 2 be disabled on hub's with that amount of users.
the julian day is not a light thing 2 use.
for the way 2 clean the reg users i have in mind i'm gone need the same function.
got some other nifty idea in my head wich i have 2 check 1st, but if that works like i hope the hub won't have any lag/load from it @ all.
but you'll see later.
yashov: that imune list is the easy part.
but for now i suggest you use chilla's logger bot.
plop
QuoteOriginally posted by plop
yashov: that imune list is the easy part.
but for now i suggest you use chilla's logger bot.
plop
OK, thank you :)
plop, just remeber.. that it does depend on the cpu, I was testing my test, readable here
http://board.univ-angers.fr/thread.php?threadid=393&boardid=17&styleid=1&sid=e16c1d866bccc75fa2d0336afda579c5 (http://board.univ-angers.fr/thread.php?threadid=393&boardid=17&styleid=1&sid=e16c1d866bccc75fa2d0336afda579c5)
on a 2,4 GHz P4
and well as winxp isn't a realtime system the clock() function won't work, you will need to run, it like 1000send of times to get a chance of how long it really takes and even then it's hard to tell since the times are so small, as I said the kernel fucks it up.
but plop you must tell whats not proof in the way of the logger, so I can improve the script.
Can this be done with Date?
then you can put the Registerd user that goes offline in a table with that date.
Then make a command that checks the table and compares the dates with the current date.
If more then 3 weeks then delete/remove acount
some like that duno for sure
QuoteOriginally posted by Optimus
Can this be done with Date?
then you can put the Registerd user that goes offline in a table with that date.
Then make a command that checks the table and compares the dates with the current date.
If more then 3 weeks then delete/remove acount
some like that duno for sure
thats why i had the seen command in mind, i allready store the latest date/time a user left the hub in that.
on my a.i. bot the seen and reg users are both an associative array so it's easy 2 compair the dates and find the users who haven't been in the hub for x weeks.
i allready do the same 2 remove the logs older then x weeks.
i'll check if i can make this 2morrow but can't promise anything.
chilla: sorry still haven't looked @ your logger bot closely.
i'm a bit sick here and had a busy weekend.
plop
cool, i will be waiting for a example Plop. It's a good discussion.
btw, got that code to work you gave me. verry happy with it. thx
Optimus, truly I think its no use to compare dates, because, you would need to run throug the table anyways, only if your hub is like offline for a week and you still want to delete the account after 20 days. else a running number( i = i +1) is less cpu intense, than cpmapring 2 dates.
well plop no worries, but then you can't say its not proof if you didn't check it.
mm, didn't thought about that for beeing offline for 2 weeks. You got a point there.
That's indeed not Proof *lol*
well me got to think again
QuoteOriginally posted by c h i l l a
Optimus, truly I think its no use to compare dates, because, you would need to run throug the table anyways, only if your hub is like offline for a week and you still want to delete the account after 20 days. else a running number( i = i +1) is less cpu intense, than cpmapring 2 dates.
well plop no worries, but then you can't say its not proof if you didn't check it.
just from your story, have 2 check it fully 2 be sure.
i gues your smart enough 2 reset the vallue 2 -1 instead of subtracting the counter by 1.
this wasn't really clear 2 me.
nearly done with my way, only have 2 add the imune users.
and indeed if the hub has been offline for 2 weeks there is a problem with my way.
but that can be solved, just change the cleaner 2 6 weeks. lol
if the last hub uptime date is saved 2 file this be can fixed automaticly, just this has 2 go on for 2 weeks.
tricky but posible, have 2 think how 2 solve that nicely. lol
plop
i hope i stripped it without bugs. lol
here it is.
-- auto 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
--------------------------------------------------------------------- config
WEEKS = 4 -- every1 older then x weeks
Bot = "The_Cleaner"
--------------------------------------------------------------------- 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 = floor(y/100)
b = 2 - a + floor(a/4)
end
if y <= 0 then c = 0.75 end
return floor(365.25*y - c) + floor(30.6001*(m+1) + d + 1720994 + b)
end
--------------------------------------------------------------------- loading the last seen database
function LoadLastSeen()
readfrom("userinfo/lastseen.lst")
while 1 do
local line = read()
if line == nil then
break
end
local s,e,name,date = strfind(line, "(.+)$(.+)")
if name ~= nil then
Seen[name]=date
end
end
readfrom()
end
--------------------------------------------------------------------- saving last seen date
function SaveSeen()
writeto("userinfo/lastseen.lst")
for a,b in Seen do
Seen[a]=b
write(a.."$"..b.."\n")
end
writeto()
end
--------------------------------------------------------------------- call the garbage man
function Clear()
collectgarbage()
flush()
end
--------------------------------------------------------------------- opening the registered users file from ptokax and inserting the users into the table
function OpenRegisterdUsersFile()
readfrom("../RegisteredUsers.dat")
UsersTable = nil
Clear()
UsersTable = {}
while 1 do
local line = read()
local name, level
if line == nil then
readfrom()
break
end
s,e,name,level = strfind(line,"(.+)|.+|(.+)")
if tonumber(level) == 3 then
UsersTable[name] = 1
end
end
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)|")
OpenRegisterdUsersFile()
local s,e,month,day,year = strfind(date("%x"), "(%d+)%/(%d+)%/(%d+)")
year = "20"..year
local juliannow = jdate(tonumber(day), tonumber(month), tonumber(year))
local oldest = WEEKS*7
for a,b in UsersTable do
if Seen[a] then
local s,e,monthu,dayu,yearu = strfind(Seen[a], "(%d+)%/(%d+)%/(%d+)")
yearu = "20"..yearu
local julianu = jdate(tonumber(dayu), tonumber(monthu), tonumber(yearu))
if (juliannow - julianu) > oldest then
SendToAll(Bot, a.." has been cleaned")
Seen[a] = nil
DelRegUser(a)
end
else
Seen[a] = date("%x")
end
end
SaveSeen()
OpenRegisterdUsersFile()
end
--------------------------------------------------------------------- don't clean this users adding/removing
function NoCleanUser(user, data)
local who, addrem = Get2ArgsML(data)
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
--------------------------------------------------------------------- save no clean users 2 file
function SaveNoClean()
writeto("userinfo/noclean.lst")
for a,b in NoClean do
write(a.."\n")
end
writeto()
end
--------------------------------------------------------------------- load no clean users from file
function LoadNoClean()
readfrom("userinfo/noclean.lst")
while 1 do
local line = read()
if line == nil then
readfrom()
break
end
NoClean[line] = 1
end
end
--------------------------------------------------------------------- do i need 2 explain this ?????
function DataArrival(user, data)
if CleanDay ~= date("%x") then -- user cleaning trigger, works as a timer without a timer
CleanDay = date("%x")
CleanUsers()
end
if( strsub(data, 1, 1) == "<" ) then
if user.bOperator then
data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data,"%b<>%s+(%S+)")
if cmd == "!noclean" then
NoCleanUser(user, data)
return 1
end
end
end
end
--------------------------------------------------------------------- stuff done when a user/vip leaves
function UserDisconnected(user)
if UsersTable[user.sName] then
Seen[user.sName]=date("%x")
SaveSeen()
end
end
--------------------------------------------------------------------- stuff done on bot startup
function Main()
OpenRegisterdUsersFile()
LoadNoClean()
LoadLastSeen()
end
plop
plop,
I get:
Syntax Error: attempt to call global `Get2ArgsML' (a nil value)
When I enter:
!noclean Yashov add
or
!noclean who
Thank you
QuoteOriginally posted by YASHOV
plop,
I get:
Syntax Error: attempt to call global `Get2ArgsML' (a nil value)
When I enter:
!noclean Yashov add
or
!noclean who
Thank you
sorry forgot 2 strip a tiny piece.
solved it now.
-- auto 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
--------------------------------------------------------------------- config
WEEKS = 4 -- every1 older then x weeks
Bot = "The_Cleaner"
--------------------------------------------------------------------- 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 = floor(y/100)
b = 2 - a + floor(a/4)
end
if y <= 0 then c = 0.75 end
return floor(365.25*y - c) + floor(30.6001*(m+1) + d + 1720994 + b)
end
--------------------------------------------------------------------- loading the last seen database
function LoadLastSeen()
readfrom("userinfo/lastseen.lst")
while 1 do
local line = read()
if line == nil then
break
end
local s,e,name,date = strfind(line, "(.+)$(.+)")
if name ~= nil then
Seen[name]=date
end
end
readfrom()
end
--------------------------------------------------------------------- saving last seen date
function SaveSeen()
writeto("userinfo/lastseen.lst")
for a,b in Seen do
Seen[a]=b
write(a.."$"..b.."\n")
end
writeto()
end
--------------------------------------------------------------------- call the garbage man
function Clear()
collectgarbage()
flush()
end
--------------------------------------------------------------------- opening the registered users file from ptokax and inserting the users into the table
function OpenRegisterdUsersFile()
readfrom("../RegisteredUsers.dat")
UsersTable = nil
Clear()
UsersTable = {}
while 1 do
local line = read()
local name, level
if line == nil then
readfrom()
break
end
s,e,name,level = strfind(line,"(.+)|.+|(.+)")
if tonumber(level) == 3 then
UsersTable[name] = 1
end
end
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)|")
OpenRegisterdUsersFile()
local s,e,month,day,year = strfind(date("%x"), "(%d+)%/(%d+)%/(%d+)")
year = "20"..year
local juliannow = jdate(tonumber(day), tonumber(month), tonumber(year))
local oldest = WEEKS*7
for a,b in UsersTable do
if Seen[a] then
local s,e,monthu,dayu,yearu = strfind(Seen[a], "(%d+)%/(%d+)%/(%d+)")
yearu = "20"..yearu
local julianu = jdate(tonumber(dayu), tonumber(monthu), tonumber(yearu))
if (juliannow - julianu) > oldest then
SendToAll(Bot, a.." has been cleaned")
Seen[a] = nil
DelRegUser(a)
end
else
Seen[a] = date("%x")
end
end
SaveSeen()
OpenRegisterdUsersFile()
end
--------------------------------------------------------------------- don't clean this users adding/removing
function NoCleanUser(user, data)
local who, addrem = strfind(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
--------------------------------------------------------------------- save no clean users 2 file
function SaveNoClean()
writeto("userinfo/noclean.lst")
for a,b in NoClean do
write(a.."\n")
end
writeto()
end
--------------------------------------------------------------------- load no clean users from file
function LoadNoClean()
readfrom("userinfo/noclean.lst")
while 1 do
local line = read()
if line == nil then
readfrom()
break
end
NoClean[line] = 1
end
end
--------------------------------------------------------------------- do i need 2 explain this ?????
function DataArrival(user, data)
if CleanDay ~= date("%x") then -- user cleaning trigger, works as a timer without a timer
CleanDay = date("%x")
CleanUsers()
end
if( strsub(data, 1, 1) == "<" ) then
if user.bOperator then
data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data,"%b<>%s+(%S+)")
if cmd == "!noclean" then
NoCleanUser(user, data)
return 1
end
end
end
end
--------------------------------------------------------------------- stuff done when a user/vip leaves
function UserDisconnected(user)
if UsersTable[user.sName] then
Seen[user.sName]=date("%x")
SaveSeen()
end
end
--------------------------------------------------------------------- stuff done on bot startup
function Main()
OpenRegisterdUsersFile()
LoadNoClean()
LoadLastSeen()
end
plop
Thank you!
No syntax errors :)
But, I get:
1 isn't a registered user.
When I enter: !noclean Yashov add
Also, I get: RTFM ;). it's !noclean
When I enter: !noclean who <--- is this a valid command??
Is there a way to see who is on the imune list???
And is there a way to triger the cleaner manually??
Thank you very much!!
QuoteOriginally posted by YASHOV
Thank you!
No syntax errors :)
But, I get: 1 isn't a registered user.
When I enter: !noclean Yashov add
i bet you are a operator. you can only add users who are registered.
QuoteOriginally posted by YASHOV
Also, I get: RTFM ;). it's !noclean
When I enter: !noclean who <--- is this a valid command??
thats not a valid command.
QuoteOriginally posted by YASHOV
Is there a way to see who is on the imune list???
And is there a way to triger the cleaner manually??
Thank you very much!!
i'll see if i can add those 2 2morrow.
adding a user who is allready on the imune list can't be done, you'll get a msg about that.
plop
QuoteOriginally posted by plop
QuoteThank you!
No syntax errors :)
But, I get: 1 isn't a registered user.
When I enter: !noclean Yashov add
i bet you are a operator. you can only add users who are registered.
No, [OP]Yashov is an operator, Yashov is a registered user, I have also tried other users and I always get same message :(
Quotei'll see if i can add those 2 2morrow.
adding a user who is allready on the imune list can't be done, you'll get a msg about that.
plop
Thank you very much!!!!
i'll also add a command 2 show all the registered users.
maby that can help 2 find out whats going wrong on your hub as here it's working fine.
plop
QuoteOriginally posted by plop
i'll also add a command 2 show all the registered users.
maby that can help 2 find out whats going wrong on your hub as here it's working fine.
plop
Great :)
Question: Do I need to have any other files in the Scripts folder for this bot to work??
I am running two scripts: Channel_Bot.v4.3c_fix.lua and The_Cleaner.lua
Thank you
a folder named userinfo is needed, thats where the list of imune users is stored.
without that folder the list is always lost after a restart.
the file with the list is automaticly generated.
plop
I created a folder "userinfo"
After I restarted the scripts, "lastseen.lst" has been created and it contains all registered users and the time they have been last seen.
The entries look like this "Yashov$12/04/03"
But I still get:
1 isn't a registered user.
The cleaner has been called. Every registered user who hasn't been in the hub for 4 weeks will be deleted. (contact the OP's if your gone be away for a period longer then that)
The first time I enter "!noclean Yashov add"
The second time I get: 1 isn't a registered user.
I also get 1 isn't a registered user.
When I enter "!noclean Yashov remove"
Thank you
bright moment i had, are you running testdrive as the script is made for that????
otherwise the user levels are wrong and no users can be found.
plop
QuoteOriginally posted by plop
bright moment i had, are you running testdrive as the script is made for that????
otherwise the user levels are wrong and no users can be found.
I've tried the script also and I get the same error/msg. I have the correct dirs/files made for the script and I'm using the PtokaX-0.326.TestDrive4 HUB software....
Btw, Thanx for the cool script, hopw it'll work for me :)
I am running PtokaX-0.326.TestDrive4
found a stupid mistake.
believe i added all i promised i would add, and it's tested this time.
-- 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
-- !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
-- a folder named userinfo is needed for this bot 2 work
--------------------------------------------------------------------- config
WEEKS = 4 -- every1 older then x weeks is deleted
Bot = "The_Cleaner"
AUTO = 1 -- use 1 for automode, 0 for manual
--------------------------------------------------------------------- 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 = floor(y/100)
b = 2 - a + floor(a/4)
end
if y <= 0 then c = 0.75 end
return floor(365.25*y - c) + floor(30.6001*(m+1) + d + 1720994 + b)
end
--------------------------------------------------------------------- loading the last seen database
function LoadLastSeen()
readfrom("userinfo/lastseen.lst")
while 1 do
local line = read()
if line == nil then
break
end
local s,e,name,date = strfind(line, "(.+)$(.+)")
if name ~= nil then
Seen[name]=date
end
end
readfrom()
end
--------------------------------------------------------------------- saving last seen date
function SaveSeen()
writeto("userinfo/lastseen.lst")
for a,b in Seen do
Seen[a]=b
write(a.."$"..b.."\n")
end
writeto()
end
--------------------------------------------------------------------- call the garbage man
function Clear()
collectgarbage()
flush()
end
--------------------------------------------------------------------- opening the registered users file from ptokax and inserting the users into the table
function OpenRegisterdUsersFile()
readfrom("../RegisteredUsers.dat")
UsersTable = nil
Clear()
UsersTable = {}
while 1 do
local line = read()
local name, level
if line == nil then
readfrom()
break
end
s,e,name,level = strfind(line,"(.+)|.+|(.+)")
if tonumber(level) == 3 then
UsersTable[name] = 1
end
end
end
--------------------------------------------------------------------- extracting the time/date when a user was last seen from the database
function SeenUser(user, data)
s,e,who = strfind(data, "%b<>%s%S+%s(.+)")
if who == nil then
user:SendPM(Bot, "Syntax error, can't read your mind, pls tell me wich user you wanne check|")
elseif Seen[who] then
user:SendPM(Bot, who.." was last seen on: "..Seen[who].."|")
else
user:SendPM(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
tinsert(lines, a)
end
sort(lines)
for i=1,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
tinsert(lines, a)
end
sort(lines)
for i=1,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)|")
OpenRegisterdUsersFile()
local s,e,month,day,year = strfind(date("%x"), "(%d+)%/(%d+)%/(%d+)")
year = "20"..year
local juliannow = jdate(tonumber(day), tonumber(month), tonumber(year))
local oldest = WEEKS*7
for a,b in UsersTable do
if Seen[a] then
local s,e,monthu,dayu,yearu = strfind(Seen[a], "(%d+)%/(%d+)%/(%d+)")
yearu = "20"..yearu
local julianu = jdate(tonumber(dayu), tonumber(monthu), tonumber(yearu))
if (juliannow - julianu) > oldest then
SendToAll(Bot, a.." has been cleaned")
Seen[a] = nil
DelRegUser(a)
end
else
Seen[a] = date("%x")
end
end
SaveSeen()
OpenRegisterdUsersFile()
end
--------------------------------------------------------------------- don't clean this users adding/removing
function NoCleanUser(user, data)
local s,e,who, addrem = strfind(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
--------------------------------------------------------------------- save no clean users 2 file
function SaveNoClean()
writeto("userinfo/noclean.lst")
for a,b in NoClean do
write(a.."\n")
end
writeto()
end
--------------------------------------------------------------------- load no clean users from file
function LoadNoClean()
readfrom("userinfo/noclean.lst")
while 1 do
local line = read()
if line == nil then
readfrom()
break
end
NoClean[line] = 1
end
end
--------------------------------------------------------------------- do i need 2 explain this ?????
function DataArrival(user, data)
if AUTO == 1 then
if CleanDay ~= date("%x") then -- user cleaning trigger, works as a timer without a timer
CleanDay = date("%x")
CleanUsers()
end
end
if( strsub(data, 1, 1) == "<" ) then
if user.bOperator then
data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(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]=date("%x")
SaveSeen()
end
end
--------------------------------------------------------------------- stuff done on bot startup
function Main()
OpenRegisterdUsersFile()
LoadNoClean()
LoadLastSeen()
CleanDay = date("%x")
end
plop
I've tested it and it works fine....
I have a question though: It seems like only users that have the profile "REG" can be added/cleaned and not OPs or VIPs... Anyway to change that so they can be cleaned too?
Thanx for the cool script
Thank you very much!!! :)
I just noticed that users that heve not been seen for over 4 weeks are not deleted after I enter "!cleanusers" ;(
cHiNgAcHg00k: yep posible.
i'll fix it for ya soon.
YASHOV: when you 1st launch it the seen list is all empty.
on that 1st launch it fixes that by filling it with the date/time of the moment you triggered !cleanusers.
in 4 weeks they will definatly be deleted if they don't visit the hub.
plop
Great!!! :)
Thank you very much!!!! :D
QuoteOriginally posted by cHiNgAcHg00k
I've tested it and it works fine....
I have a question though: It seems like only users that have the profile "REG" can be added/cleaned and not OPs or VIPs... Anyway to change that so they can be cleaned too?
Thanx for the cool script
add this.
function OpDisconnected(user)
if UsersTable[user.sName] then
Seen[user.sName]=date("%x")
SaveSeen()
end
end
and replace this.
function OpenRegisterdUsersFile()
readfrom("../RegisteredUsers.dat")
UsersTable = nil
Clear()
UsersTable = {}
while 1 do
local line = read()
local name, level
if line == nil then
readfrom()
break
end
s,e,name,level = strfind(line,"(.+)|.+|(.+)")
if tonumber(level) ~= 0 then
UsersTable[name] = 1
end
end
end
then all but masters are cleaned.
sorry for the quick job, really busy here on other things.
plop
You mean I should replace the last (longer) piece of code with the first (shorter) one?
Or should I delete the last code from the script and add the first one?
QuoteOriginally posted by cHiNgAcHg00k
You mean I should replace the last (longer) piece of code with the first (shorter) one?
Or should I delete the last code from the script and add the first one?
the 1st piece of code (the small thingy) has 2 be added so seen also looks for the op's who leave.
the 2de piece (the big piece) is a modified function and has 2 replace the function wich is in the original script.
you'll find a function wich has excatly the same name.
change the old for this new 1 and it's working like you requested.
plop
Hi Plop
i did the op/vip mod but now if i try to add an op to the immune list i get :-
" [20:59] User isn't a registered user. "
How Can I add them to the immune list ?????
Thx
??????Hawk??????
Just tryed it works fine
did you made the folder asked by plop in script
-- a folder named userinfo is needed for this bot 2 work
sorry T?M??r?V?ll?R i forgot to mention its the ops that i can't immune .......
gettin message
" [20:59] User isn't a registered user. "
??????Hawk??????
QuoteOriginally posted by ??????Hawk??????
sorry T?M??r?V?ll?R i forgot to mention its the ops that i can't immune .......
gettin message
" [20:59] User isn't a registered user. "
??????Hawk??????
you need 2 do the same as cHiNgAcHg00k.
currently the bot only holds users, not vips/ops.
if a user is not in the userstable you get that error.
plop
Heya Plop
I did the Mods to the script before i put it in.
ive also got the directory userinfo in the scripts directory.
but still get that message when i try immune the op's
??????Hawk??????
QuoteOriginally posted by ??????Hawk??????
Heya Plop
I did the Mods to the script before i put it in.
ive also got the directory userinfo in the scripts directory.
but still get that message when i try immune the op's
??????Hawk??????
i tested this 1 for you, here it works.
-- auto/manual user cleaner if user hasn't been in the hub for x weeks
-- cleans all levels but master level
-- made by plop
-- julian day function made by the guru tezlo
-- code stripped from artificial insanety bot
-- !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
-- a folder named userinfo is needed for this bot 2 work
--------------------------------------------------------------------- config
WEEKS = 4 -- every1 older then x weeks is deleted
Bot = "The_Cleaner"
AUTO = 1 -- use 1 for automode, 0 for manual
--------------------------------------------------------------------- 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 = floor(y/100)
b = 2 - a + floor(a/4)
end
if y <= 0 then c = 0.75 end
return floor(365.25*y - c) + floor(30.6001*(m+1) + d + 1720994 + b)
end
--------------------------------------------------------------------- loading the last seen database
function LoadLastSeen()
readfrom("userinfo/lastseen.lst")
while 1 do
local line = read()
if line == nil then
break
end
local s,e,name,date = strfind(line, "(.+)$(.+)")
if name ~= nil then
Seen[name]=date
end
end
readfrom()
end
--------------------------------------------------------------------- saving last seen date
function SaveSeen()
writeto("userinfo/lastseen.lst")
for a,b in Seen do
Seen[a]=b
write(a.."$"..b.."\n")
end
writeto()
end
--------------------------------------------------------------------- call the garbage man
function Clear()
collectgarbage()
flush()
end
--------------------------------------------------------------------- opening the registered users file from ptokax and inserting the users into the table
function OpenRegisterdUsersFile()
readfrom("../RegisteredUsers.dat")
UsersTable = nil
Clear()
UsersTable = {}
while 1 do
local line = read()
local name, level
if line == nil then
readfrom()
break
end
s,e,name,level = strfind(line,"(.+)|.+|(.+)")
if tonumber(level) ~= 0 then
UsersTable[name] = 1
end
end
end
--------------------------------------------------------------------- extracting the time/date when a user was last seen from the database
function SeenUser(user, data)
s,e,who = strfind(data, "%b<>%s%S+%s(.+)")
if who == nil then
user:SendPM(Bot, "Syntax error, can't read your mind, pls tell me wich user you wanne check|")
elseif Seen[who] then
user:SendPM(Bot, who.." was last seen on: "..Seen[who].."|")
else
user:SendPM(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
tinsert(lines, a)
end
sort(lines)
for i=1,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
tinsert(lines, a)
end
sort(lines)
for i=1,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)|")
OpenRegisterdUsersFile()
local s,e,month,day,year = strfind(date("%x"), "(%d+)%/(%d+)%/(%d+)")
year = "20"..year
local juliannow = jdate(tonumber(day), tonumber(month), tonumber(year))
local oldest = WEEKS*7
for a,b in UsersTable do
if Seen[a] then
local s,e,monthu,dayu,yearu = strfind(Seen[a], "(%d+)%/(%d+)%/(%d+)")
yearu = "20"..yearu
local julianu = jdate(tonumber(dayu), tonumber(monthu), tonumber(yearu))
if (juliannow - julianu) > oldest then
SendToAll(Bot, a.." has been cleaned")
Seen[a] = nil
DelRegUser(a)
end
else
Seen[a] = date("%x")
end
end
SaveSeen()
OpenRegisterdUsersFile()
end
--------------------------------------------------------------------- don't clean this users adding/removing
function NoCleanUser(user, data)
local s,e,who, addrem = strfind(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
--------------------------------------------------------------------- save no clean users 2 file
function SaveNoClean()
writeto("userinfo/noclean.lst")
for a,b in NoClean do
write(a.."\n")
end
writeto()
end
--------------------------------------------------------------------- load no clean users from file
function LoadNoClean()
readfrom("userinfo/noclean.lst")
while 1 do
local line = read()
if line == nil then
readfrom()
break
end
NoClean[line] = 1
end
end
--------------------------------------------------------------------- do i need 2 explain this ?????
function DataArrival(user, data)
if AUTO == 1 then
if CleanDay ~= date("%x") then -- user cleaning trigger, works as a timer without a timer
CleanDay = date("%x")
CleanUsers()
end
end
if( strsub(data, 1, 1) == "<" ) then
if user.bOperator then
data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(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]=date("%x")
SaveSeen()
end
end
function OpDisconnected(user)
if UsersTable[user.sName] then
Seen[user.sName]=date("%x")
SaveSeen()
end
end
--------------------------------------------------------------------- stuff done on bot startup
function Main()
OpenRegisterdUsersFile()
LoadNoClean()
LoadLastSeen()
CleanDay = date("%x")
end
plop
Hi Plop
i think ive found the problem but i dont know how to fix it.
the script only imunises users that are in the userinfo directory, but the ops dont get listed in there untill they leave the hub...
anyway its not a problem ill wait for them to leave and then put the ones i want in the immune list...
Thx for all your help...
??????Hawk??????
An account in the immune list got deleted :(
Could you fix it please?
Thank you
QuoteOriginally posted by YASHOV
An account in the immune list got deleted :(
Could you fix it please?
Thank you
damn that was caused by a real dumb thing, forgot 2 do the check if a user is imune.
sorry for the trouble.
-- 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
-- version 1.1
-- tiny bug fix on imune users
-- !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
-- a folder named userinfo is needed for this bot 2 work
--------------------------------------------------------------------- config
WEEKS = 4 -- every1 older then x weeks is deleted
Bot = "The_Cleaner"
AUTO = 1 -- use 1 for automode, 0 for manual
--------------------------------------------------------------------- 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 = floor(y/100)
b = 2 - a + floor(a/4)
end
if y <= 0 then c = 0.75 end
return floor(365.25*y - c) + floor(30.6001*(m+1) + d + 1720994 + b)
end
--------------------------------------------------------------------- loading the last seen database
function LoadLastSeen()
readfrom("userinfo/lastseen.lst")
while 1 do
local line = read()
if line == nil then
break
end
local s,e,name,date = strfind(line, "(.+)$(.+)")
if name ~= nil then
Seen[name]=date
end
end
readfrom()
end
--------------------------------------------------------------------- saving last seen date
function SaveSeen()
writeto("userinfo/lastseen.lst")
for a,b in Seen do
Seen[a]=b
write(a.."$"..b.."\n")
end
writeto()
end
--------------------------------------------------------------------- call the garbage man
function Clear()
collectgarbage()
flush()
end
--------------------------------------------------------------------- opening the registered users file from ptokax and inserting the users into the table
function OpenRegisterdUsersFile()
readfrom("../RegisteredUsers.dat")
UsersTable = nil
Clear()
UsersTable = {}
while 1 do
local line = read()
local name, level
if line == nil then
readfrom()
break
end
s,e,name,level = strfind(line,"(.+)|.+|(.+)")
if tonumber(level) == 3 then
UsersTable[name] = 1
end
end
end
--------------------------------------------------------------------- extracting the time/date when a user was last seen from the database
function SeenUser(user, data)
s,e,who = strfind(data, "%b<>%s%S+%s(.+)")
if who == nil then
user:SendPM(Bot, "Syntax error, can't read your mind, pls tell me wich user you wanne check|")
elseif Seen[who] then
user:SendPM(Bot, who.." was last seen on: "..Seen[who].."|")
else
user:SendPM(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
tinsert(lines, a)
end
sort(lines)
for i=1,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
tinsert(lines, a)
end
sort(lines)
for i=1,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)|")
OpenRegisterdUsersFile()
local s,e,month,day,year = strfind(date("%x"), "(%d+)%/(%d+)%/(%d+)")
year = "20"..year
local juliannow = jdate(tonumber(day), tonumber(month), tonumber(year))
local oldest = WEEKS*7
for a,b in UsersTable do
if Seen[a] then
if NoClean[a]== nil then
local s,e,monthu,dayu,yearu = strfind(Seen[a], "(%d+)%/(%d+)%/(%d+)")
yearu = "20"..yearu
local julianu = jdate(tonumber(dayu), tonumber(monthu), tonumber(yearu))
if (juliannow - julianu) > oldest then
SendToAll(Bot, a.." has been cleaned")
Seen[a] = nil
DelRegUser(a)
end
end
else
Seen[a] = date("%x")
end
end
SaveSeen()
OpenRegisterdUsersFile()
end
--------------------------------------------------------------------- don't clean this users adding/removing
function NoCleanUser(user, data)
local s,e,who, addrem = strfind(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
--------------------------------------------------------------------- save no clean users 2 file
function SaveNoClean()
writeto("userinfo/noclean.lst")
for a,b in NoClean do
write(a.."\n")
end
writeto()
end
--------------------------------------------------------------------- load no clean users from file
function LoadNoClean()
readfrom("userinfo/noclean.lst")
while 1 do
local line = read()
if line == nil then
readfrom()
break
end
NoClean[line] = 1
end
end
--------------------------------------------------------------------- do i need 2 explain this ?????
function DataArrival(user, data)
if AUTO == 1 then
if CleanDay ~= date("%x") then -- user cleaning trigger, works as a timer without a timer
CleanDay = date("%x")
CleanUsers()
end
end
if( strsub(data, 1, 1) == "<" ) then
if user.bOperator then
data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(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]=date("%x")
SaveSeen()
end
end
--------------------------------------------------------------------- stuff done on bot startup
function Main()
OpenRegisterdUsersFile()
LoadNoClean()
LoadLastSeen()
CleanDay = date("%x")
end
plop
Thank you very much!!! :)
i copy and paste the script and i have this error
QuoteSyntax Error: function arguments expected;
last token read: `=' at line 19 in file `C:\Program Files\PtokaX-0.326.TestDrive4\scripts\The_Cleaner.lua'
i run testdrive 4
and i make a folder userinfo in the script folder
did i mist something ???
any help will be apreciate
Riouel :D
and this was the error
Syntax Error: function arguments expected;
last token read: `=' at line 17 in string "code:----------------------------------------------------------..."
??????????
Riouel
QuoteOriginally posted by Riouel
and this was the error
Syntax Error: function arguments expected;
last token read: `=' at line 17 in string "code:----------------------------------------------------------..."
??????????
Riouel
try copying it again, here that line 19 is a comment (-- or more -----------).
(i'll check if i can upload the scripts on the golden angel website 2night).
plop
thanx plop
i will try again
Riouel
Download it here you can to:
Download (http://swenorth.myftp.org/network/nightlitch/files/regcleaner.rar)
it was the code: when i copy it ;(
thanx for building this one
all is good now
Riouel
good 2 hear that Riouel.
and thx NightLitch.
plop
i have a question. am i need to add the Registerd users name manually or the bot will automatically detect the registered user?
i canot see the registered users list when i type
!showusers in the mainchat
QuoteOriginally posted by sajy2k
i canot see the registered users list when i type
!showusers in the mainchat
it grabs all registered users from the registered users file from ptokax 0.3.2.6+ on startup.
so my gues it that you are running an older version of ptokax.
plop
--------------------------------------------------------------------- julian day function 2 calcute the time users spend in the hub --------------------------------------------------------------------- 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 = floor(y/100)
b = 2 - a + floor(a/4)
end
if y <= 0 then c = 0.75 end
return floor(365.25*y - c) + floor(30.6001*(m+1) + d + 1720994 + b)
what is the cmd command to see how much time the user is in the hub
thanx plop and i can't find your -Artificial Insanety- bot or script
Riouel ;)
QuoteOriginally posted by Riouel
what is the cmd command to see how much time the user is in the hub
thanx plop and i can't find your -Artificial Insanety- bot or script
Riouel ;)
that command your talking about is in the userinfo database from a.i..
the same julian day function is used 2 calculate that.
you got a pm where 2 find a.i..
plop
i have been read the pm before i read this one :P
it pop up when i log in :]
thanx for all your help in this fine board
Riouel 8)
QuoteOriginally posted by Riouel
i have been read the pm before i read this one :P
it pop up when i log in :]
thanx for all your help in this fine board
Riouel 8)
yw
plop
Well it seems that the script works but it only scans user with the userlevel 3 (Reg).
But i have some extra user level 4 and 5. Can someone rewrite the script so that it scanns ALL userlevels exept Operators (1) and Masters (0)?
Thanks in advance...
Download it here you can to:
Download
__________________
/NightLitch
quick job, haen't had the time 2 test it, so pls don't kill me if it doesn't work.
but if all goes as planed it now should be posible 2 clean every level you would like.
just stuff the level numbers you want 2 have cleaned in the CleanLevels table, just like the script shows.
-- 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
-- !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
-- a folder named userinfo is needed for this bot 2 work
--------------------------------------------------------------------- config
WEEKS = 4 -- every1 older then x weeks is deleted
Bot = "The_Cleaner"
AUTO = 1 -- use 1 for automode, 0 for manual
CleanLevels = {[3]=1,[4]=1,[5]=1} -- levels it needs 2 clean
--------------------------------------------------------------------- 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 = floor(y/100)
b = 2 - a + floor(a/4)
end
if y <= 0 then c = 0.75 end
return floor(365.25*y - c) + floor(30.6001*(m+1) + d + 1720994 + b)
end
--------------------------------------------------------------------- loading the last seen database
function LoadLastSeen()
readfrom("userinfo/lastseen.lst")
while 1 do
local line = read()
if line == nil then
break
end
local s,e,name,date = strfind(line, "(.+)$(.+)")
if name ~= nil then
Seen[name]=date
end
end
readfrom()
end
--------------------------------------------------------------------- saving last seen date
function SaveSeen()
writeto("userinfo/lastseen.lst")
for a,b in Seen do
Seen[a]=b
write(a.."$"..b.."\n")
end
writeto()
end
--------------------------------------------------------------------- call the garbage man
function Clear()
collectgarbage()
flush()
end
--------------------------------------------------------------------- opening the registered users file from ptokax and inserting the users into the table
function OpenRegisterdUsersFile()
readfrom("../RegisteredUsers.dat")
UsersTable = nil
Clear()
UsersTable = {}
while 1 do
local line = read()
local name, level
if line == nil then
readfrom()
break
end
s,e,name,level = strfind(line,"(.+)|.+|(.+)")
if CleanLevels[tonumber(level)] then
UsersTable[name] = 1
end
end
end
--------------------------------------------------------------------- extracting the time/date when a user was last seen from the database
function SeenUser(user, data)
s,e,who = strfind(data, "%b<>%s%S+%s(.+)")
if who == nil then
user:SendPM(Bot, "Syntax error, can't read your mind, pls tell me wich user you wanne check|")
elseif Seen[who] then
user:SendPM(Bot, who.." was last seen on: "..Seen[who].."|")
else
user:SendPM(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
tinsert(lines, a)
end
sort(lines)
for i=1,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
tinsert(lines, a)
end
sort(lines)
for i=1,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)|")
OpenRegisterdUsersFile()
local s,e,month,day,year = strfind(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 = strfind(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] = 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 = strfind(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
--------------------------------------------------------------------- save no clean users 2 file
function SaveNoClean()
writeto("userinfo/noclean.lst")
for a,b in NoClean do
write(a.."\n")
end
writeto()
end
--------------------------------------------------------------------- load no clean users from file
function LoadNoClean()
readfrom("userinfo/noclean.lst")
while 1 do
local line = read()
if line == nil then
readfrom()
break
end
NoClean[line] = 1
end
end
--------------------------------------------------------------------- do i need 2 explain this ?????
function DataArrival(user, data)
if AUTO == 1 then
if CleanDay ~= date("%x") then -- user cleaning trigger, works as a timer without a timer
CleanDay = date("%x")
CleanUsers()
end
end
if( strsub(data, 1, 1) == "<" ) then
if user.bOperator then
data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(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]=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]=date("%x")
SaveSeen()
end
end
--------------------------------------------------------------------- stuff done on bot startup
function Main()
OpenRegisterdUsersFile()
LoadNoClean()
LoadLastSeen()
CleanDay = date("%x")
end
plop
Great script, thanks for using so much time:D If I want to test if the user is deleted after X weeks, in which way would that be posible rather than waiting 1 week minimum...?
QuoteOriginally posted by Smulf
Great script, thanks for using so much time:D If I want to test if the user is deleted after X weeks, in which way would that be posible rather than waiting 1 week minimum...?
manualy change the date in the seen file and restart the script.
plop
At this time in my hub the cleaner comes on midnight
ani way i can make it that it cleans on a different time when more users are online to see it like around 20.00
TiMe :)
QuoteOriginally posted by T?M??r?V?ll?R
At this time in my hub the cleaner comes on midnight
ani way i can make it that it cleans on a different time when more users are online to see it like around 20.00
TiMe :)
try replacing function main for this 1.
--------------------------------------------------------------------- stuff done on bot startup
function Main()
OpenRegisterdUsersFile()
LoadNoClean()
LoadLastSeen()
CleanDay = 20 -- the hour it should clean (24 style clock)
onetime = 0
end
and replace this part from dataarival.
function DataArrival(user, data)
if AUTO == 1 then
if CleanDay == date("%H") and onetime == 0 then -- user cleaning trigger, works as a timer without a timer
CleanUsers()
onetime = 1
elseif (CleanDay+1) == date("%H") then
onetime = 0
end
end
plop
oki changed it see what happens now
Thanks :)
Last change you gave me in pm plop dident worked nothing happend at 20.00
TiMe
[20:00:02] The cleaner has been called. Every registered user who hasn't been in the hub for 2 weeks will be deleted. (contact the OP's if your gone be away for a period longer then that)
After last changes you told me in pm it works fine now m8 Thanks :)
But can eny one post the script that works!
I see that there was problem whit the script that is posted at the topp!
And now you have get it to work!
//WickeD
No NO no probs i just wanted the cleaner to come on a different time than it is standaart on 24.00 but most users dont see that here are already to bed
most users are online around 20.00 so i asked for that to plop zo i can set time as i please thats all script posted here works just fine dont worry
TiMe :)
QuoteOriginally posted by T?M??r?V?ll?R
No NO no probs i just wanted the cleaner to come on a different time than it is standaart on 24.00 but most users dont see that here are already to bed
most users are online around 20.00 so i asked for that to plop zo i can set time as i please thats all script posted here works just fine dont worry
TiMe :)
can you still post the full changed script here, maby there are more ppl who would like 2 have this version.
i frooze windows yesterday and lost the changed code i send you.
btw the version you have now can trigger on every hour you want except 23 o'clock.
plop
Sure :)
-- 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
-- !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
-- a folder named userinfo is needed for this bot 2 work
--------------------------------------------------------------------- config
WEEKS = 2 -- every1 older then x weeks is deleted
Bot = "The_Cleaner"
AUTO = 1 -- use 1 for automode, 0 for manual
CleanLevels = {[1]=1,[2]=1,[3]=1} -- levels it needs 2 clean
--------------------------------------------------------------------- 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 = floor(y/100)
b = 2 - a + floor(a/4)
end
if y <= 0 then c = 0.75 end
return floor(365.25*y - c) + floor(30.6001*(m+1) + d + 1720994 + b)
end
--------------------------------------------------------------------- loading the last seen database
function LoadLastSeen()
readfrom("userinfo/lastseen.lst")
while 1 do
local line = read()
if line == nil then
break
end
local s,e,name,date = strfind(line, "(.+)$(.+)")
if name ~= nil then
Seen[name]=date
end
end
readfrom()
end
--------------------------------------------------------------------- saving last seen date
function SaveSeen()
writeto("userinfo/lastseen.lst")
for a,b in Seen do
Seen[a]=b
write(a.."$"..b.."\n")
end
writeto()
end
--------------------------------------------------------------------- call the garbage man
function Clear()
collectgarbage()
flush()
end
--------------------------------------------------------------------- opening the registered users file from ptokax and inserting the users into the table
function OpenRegisterdUsersFile()
readfrom("../RegisteredUsers.dat")
UsersTable = nil
Clear()
UsersTable = {}
while 1 do
local line = read()
local name, level
if line == nil then
readfrom()
break
end
s,e,name,level = strfind(line,"(.+)|.+|(.+)")
if CleanLevels[tonumber(level)] then
UsersTable[name] = 1
end
end
end
--------------------------------------------------------------------- extracting the time/date when a user was last seen from the database
function SeenUser(user, data)
s,e,who = strfind(data, "%b<>%s%S+%s(.+)")
if who == nil then
user:SendPM(Bot, "Syntax error, can't read your mind, pls tell me wich user you wanne check|")
elseif Seen[who] then
user:SendPM(Bot, who.." was last seen on: "..Seen[who].."|")
else
user:SendPM(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
tinsert(lines, a)
end
sort(lines)
for i=1,getn(lines) do
info = info.." "..lines.."\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
tinsert(lines, a)
end
sort(lines)
for i=1,getn(lines) do
info = info.." "..lines.."\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)|")
OpenRegisterdUsersFile()
local s,e,month,day,year = strfind(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 = strfind(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] = 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 = strfind(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
--------------------------------------------------------------------- save no clean users 2 file
function SaveNoClean()
writeto("userinfo/noclean.lst")
for a,b in NoClean do
write(a.."\n")
end
writeto()
end
--------------------------------------------------------------------- load no clean users from file
function LoadNoClean()
readfrom("userinfo/noclean.lst")
while 1 do
local line = read()
if line == nil then
readfrom()
break
end
NoClean[line] = 1
end
end
--------------------------------------------------------------------- do i need 2 explain this ?????
function DataArrival(user, data)
if AUTO == 1 then
if CleanDay == tonumber(date("%H")) and onetime == 0 then -- user cleaning trigger, works as a timer without a timer
CleanUsers()
onetime = 1
elseif (CleanDay+1) == tonumber(date("%H")) then
onetime = 0
end
end
if( strsub(data, 1, 1) == "<" ) then
if user.bOperator then
data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(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]=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]=date("%x")
SaveSeen()
end
end
--------------------------------------------------------------------- stuff done on bot startup
function Main()
OpenRegisterdUsersFile()
LoadNoClean()
LoadLastSeen()
CleanDay = 20 -- the hour it should clean (24 style clock)
onetime = 0
end
One simple error i think when I restart ptokax registred users in noclean list are erased ...please modifie and post a version that save in a txt file the list ..