REQ: Need a bot to delete unused accounts - Page 2
 

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

REQ: Need a bot to delete unused accounts

Started by YASHOV, 25 November, 2003, 10:48:28

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

YASHOV

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

plop

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

YASHOV

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

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.

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

cHiNgAcHg00k

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

YASHOV

I am running PtokaX-0.326.TestDrive4

plop

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

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

YASHOV

#33
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" ;(

plop

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

YASHOV

Great!!! :)

Thank you very much!!!!  :D

plop

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

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?

plop

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

??????Hawk??????

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

TiMeTrAVelleR

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

??????Hawk??????

#41
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??????

plop

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

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

plop

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

??????Hawk??????

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

YASHOV

An account in the immune list got deleted :(

Could you fix it please?

Thank you

plop

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

YASHOV

Thank you very much!!! :)

Riouel

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

SMF spam blocked by CleanTalk