HELP: Need some Scripts
 

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

HELP: Need some Scripts

Started by Jorgesc, 09 May, 2005, 08:15:44

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Jorgesc

Hi to all,

I need the this scritps for PtokaX 0.3.3.0 build 17.03 [debug], that I have it in Ptokax 0.3.3.0 build 15.25 [debug].

Sorry my english.

NAME: Mass to Unreg Users Only
QuotesBot = "No_Registrados"

unRegUsers = {}
unRegUserFile = "unRegUsers.txt"

function Main()
   frmHub:RegBot(sBot)
   doloadTable(unRegUserFile)
   if frmHub:GetUsersCount() == 0 then unRegUsers = {}
      dosaveTable(user,data)
   end
end

function NewUserConnected(user)
   if user.iProfile == -1 then
      doLog_unRegUsers(user, data)
   end
end

function UserDisconnected(user)
   if unRegUsers[user.sName] then
      unRegUsers[user.sName] = nil
      dosaveTable(user,data)
   end
end

function DataArrival(user, data)
   if (strsub(data, 1, 1) == "<" ) then
      data=strsub(data,1,strlen(data)-1)
      _,_,cmd=strfind(data, "%b<>%s+(%S+)")

      if user.bOperator then
         if (cmd == "!xmass") then            
            s,e,cmd,message = strfind(data,"%b<>%s+(%S+)%s+(.+)")
            if message then
               tosend = ""
               if (strlen ( message)*2/3+2) < 76 then
               border = strrep ("-", strlen (message)*2/3+2)
               else
               border = strrep ("-", 75)
               end
               tosend = "\r\n\r\n"..border.."\r\n"..message.."\r\n"..border.."\r\n"
               if unRegUsers then
                  for name,_ in unRegUsers do
                     SendPmToNick(name,sBot, tosend)
                  end
               end
            else
               user:SendData(sBot, "*** Ingresa un mensaje!")
            end
         end
      end
   end
end

function doLog_unRegUsers(user, data)
   if unRegUsers[user.sName] == nil then
      unRegUsers[user.sName] = 1
      dosaveTable(user,data)
   end
end

function doloadTable(unRegUserFile)
   assert(readfrom(unRegUserFile))
   dostring(read("*all"))
   readfrom()
end

function dosaveTable(user,data)
   writeto(unRegUserFile)
   write("unRegUsers = {")
   for a,b in unRegUsers do
   if b then
   write(format("[%q]=",a)..b..",")
   end
   end
   write("}" )
   writeto()
end

NAME: Block PM from Unreg to Reg users
Quote-- Allow PM by unregistered users to select profiles
--
--User Settings-------------------------------------------------------------------------------------
Bot = frmHub:GetHubBotName()
-- Which profiles may an unregistered user send a PM to? '1=yes/0=no'
-- Adjust to your profiles
CanPM = {[0]=1,[1]=1,[2]=1,[3]=0,[4]=1,[5]=1,[6]=1}    

--End User Settings----------------------------------------------------------------------------------
function DataArrival(user, data)
   if (strsub(data,1,4) == "$To:") and (user.iProfile == -1) then
      local s,e,who = strfind(data,"$To:%s+(%S+)%s+From:")
      local nick = GetItemByName(who)
         if CanPM[nick.iProfile] ~= 1 then
            user:SendPM(who,Bot.." ***No puedes enviale PM a los usuarios Registrados "..who)
            return 1
         else
            user:SendPM(Bot.." ***Si te quieres registrar, solo espera respuesta. ")
         end
   end
end

NAME: Anti Leechers
QuotesBot = "Musica_BOT"

pmnotif=1 -- set to 1 if you wanna notify a user in PM

arrRC = {}

function Main()

    frmHub:EnableFullData(1)
--    frmHub:UnRegBot(sBot)

    if pmnotif==1 then
  --      frmHub:RegBot(sBot)
    end
end

function DataArrival(curUser, data)

   if (strsub(data, 1, 15) == "$RevConnectToMe") then
      local _,_,towho = strfind(data, "$RevConnectToMe%s+%S+%s+(%S+)|")

      if (curUser.iProfile == -1 and GetItemByName(towho) ~= nil and GetItemByName(towho).iProfile ~= -1) then
         curUser:SendData(sBot, curUser.sName.." - Sin estar registrado, solo le puedes descargar a los no registrados.")
            return 1
           elseif (towho ~= nil) then
         arrRC[towho] = 1
      end

   elseif (strsub(data, 1, 12) == "$ConnectToMe" and curUser.iProfile == -1) then
      local _,_,towho = strfind(data, "$ConnectToMe%s+(%S+)%s+.*|")

      if (arrRC[curUser.sName] ~= nil) then
         arrRC[curUser.sName] = nil
      elseif (GetItemByName(towho) ~= nil and GetItemByName(towho).iProfile ~= -1) then
         curUser:SendData(sBot, curUser.sName.." - Sin estar registrado, solo le puedes descargar a los no registrados.")
            return 1
           end
      end
end

NAME: User Cleaner
Quote-- auto/manual registered user cleaner if user hasn't been in the hub for x weeks
-- 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 = "Borrador"
AUTO = 0   -- 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

--------------------------------------------------------------------- shows all the nicks on the no clean list
function ShowNoClean(user)
   local lines =  {}
   local info = "\r\n\r\n"
   info = info.." Usuarios en la lista de No Borrar\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, "Si te vas a ausentar del HUB por mas de "..WEEKS.." semanas, contactate con un OP. Para que tu registro no sea borrado.|")
   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.." Seran Procesados, "..Count2.." fueron borrados.|")
   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, " El comando es: !noclean !!!|")
   elseif UsersTable[who] then
      if addrem == "add" then
         if NoClean[who] then
            user:SendData(Bot, who.." Esta en la lista de No Borrar!!!|")
         else
            NoClean[who] = 1
            user:SendData(Bot, who.." Esta en la lista de No Borrar y no sera borrado!!!|")
            SaveNoClean()
         end
      elseif addrem == "remove" then
         if NoClean[who] then
            NoClean[who] = nil
            user:SendData(Bot, who.." Fue borrado de la lista de No Borrar|")
            SaveNoClean()
         else
            user:SendData(Bot, who.." No esta en la lista de No Borrar|")
         end
      else
         user:SendData(Bot, " El comando es: !noclean |")
      end
   else
      user:SendData(Bot, who.." No es un usuario registrado!!!|")
   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 == "!shownoclean" then
            ShowNoClean(user)
            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

jiten

Have you searched the Lua 5 section for those scripts?
If I'm not wrong, you can find three of them there.

Cheers

jiten

This is the missing one:
-- Lua 5 version by jiten
-- Allow PM by unregistered users to select profiles 
-- 
--User Settings------------------------------------------------------------------------------------- 
Bot = frmHub:GetHubBotName()
-- Which profiles may an unregistered user send a PM to? '1=yes/0=no' 
-- Adjust to your profiles 
CanPM = {[0]=1,[1]=1,[2]=1,[3]=0,[4]=1,[5]=1,[6]=1}

--End User Settings---------------------------------------------------------------------------------- 
function ToArrival(user, data) 
	if (user.iProfile == -1) then 
		local s,e,who = string.find(data,"$To:%s+(%S+)%s+From:") 
		local nick = GetItemByName(who) 
		if CanPM[nick.iProfile] ~= 1 then 
			user:SendPM(who,Bot.." ***No puedes enviale PM a los usuarios Registrados "..who) 
			return 1 
		else 
			user:SendPM(Bot.." ***Si te quieres registrar, solo espera respuesta. ") 
		end 
	end
end
Cheers

Jorgesc

Thanks,

Do you can tell me, where I can find this scripts pls.

Write the address here.

Cheers

jiten

QuoteOriginally posted by Jorgesc
Thanks,

Do you can tell me, where I can find this scripts pls.

Write the address here.

Cheers
Just use the "Search" button up there, and look for "regcleaner", "leech bot" and "mass unreg".

Cheers

Jorgesc

QuoteOriginally posted by jiten
Just use the "Search" button up there, and look for "regcleaner", "leech bot" and "mass unreg".

Cheers

Thanks, I find it and try.

 :]

jiten

QuoteOriginally posted by Jorgesc
QuoteOriginally posted by jiten
Just use the "Search" button up there, and look for "regcleaner", "leech bot" and "mass unreg".

Cheers

Thanks, I find it and try.

 :]
You're welcome m8.

SMF spam blocked by CleanTalk