FreshStuff 3.5
 

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

FreshStuff 3.5

Started by bastya_elvtars, 11 March, 2005, 02:34:03

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

bastya_elvtars

Finally debugged and converted, also added a search function, as i got the idea from someone from here. If you have any requests please post, seems I have taken over this 3.x version.

-- FreshStuff v.3.5
-----------------------------------------------------------------------------------------
-- original idea/script by chilla
-- completely rewriten by plop
-- if you were running 3.0 then you gotta delete the old file
-- it's incompatible with this version
-- deleting now goes by id number
-- anounces the new releas in mainchat
-----------------------------------------------------------------------------------------
-- converted to lua5 and added search function by bastya_elvtars

-- Name the commands to what U like 
-- This command adds stuff, syntax : +addalbum TYPE/CATAGORY THESTUFF2ADD 
cmd1 = "+addalbum" 

-- This command shows the stuff, syntax : +albums with options new/game/warez/music/movie
cmd2 = "+albums" 

-- This command deletes an entry, syntax : +delalbum THESTUFF2DELETE 
cmd3 = "+delalbum" 

-- This command shows the latest stuff, syntax : +newalbums
cmd4 = "+newalbums"

-- This command reloads the txt file. syntax : +reloadalbums 
-- (this command is needed if you manualy edit the text file)
cmd5 = "+reloadalbums"


-- This is for searching inside releases.

cmd6="+searchalbum"

-- Show latest stuff on entry 1=yes, 0=no
ShowOnEntry = 0

-- Max stuff shown on newalbums/entry
MaxNew = 20

-- The file storing the stuff
file = "releases.dat"


-- Name of the bot
Bot = "post-it_memo"

-- you can add catagory's yourself ["trigger_name"]="catagory_name"
Types = {["movie"] = "Movies", ["music"]="Music", ["warez"]="Warez", ["game"]="Games"}

--------------------- don't change anything below here
AllStuff = {}
NewestStuff = {}

function Main() 
   frmHub:RegBot(Bot)
   ReloadRel()
end

function NewUserConnected(user) 
   if ShowOnEntry == 1 then
      user:SendPM(Bot, MsgNew.."|")
   end
end 

function OpConnected(user) 
   if ShowOnEntry == 1 then
      user:SendPM(Bot, MsgNew.."|")
   end
end 


function ChatArrival(user,data)
      data = string.sub(data,1,string.len(data)-1) 
      s,e,cmd,type,tune = string.find(data, "%b<>%s+(%S+)%s*(%S*)%s*(.*)")
      if cmd == cmd2 then
         if type == "" then
            user:SendPM(Bot, MsgAll.."|")
         elseif type == "new" then
            user:SendPM(Bot, MsgNew.."|")
         elseif Types[type] then
            ShowRelType(type)
            user:SendPM(Bot, MsgType.."|")
         end
         return 1
      elseif cmd == cmd4 then
         user:SendPM(Bot, MsgNew.."|")
         return 1
      elseif user.bOperator then
         if cmd == cmd3 then
            if type ~= "" then
               DelRel(user, type)
            else
               user:SendData(Bot, "yea right, like i know what i got 2 delete when you don't tell me!|")
            end
            return 1
         elseif cmd == cmd1 then
            if tune ~= "" and Types[type] then
               AddRel(user, tune, type)
            elseif Types[type] == nil then
               user:SendData(Bot, "I need to know the catagory to add it to!|")
            else
               user:SendData(Bot, "yea right, like i know what you got 2 add when you don't tell me!|")
            end
            return 1
         elseif cmd == cmd5 then
            Reload()
            user:SendData(Bot, "Albums reloaded!|")
	  elseif cmd==cmd6 then 
		if type~="" and tune=="" then
			SearchRel(user,type)
		else
			user:SendData(Bot, "yea right, like i know what you got 2 search when you don't tell me!|")
		end
		
            return 1
         end
      end
   end


function OpenRel()
   AllStuff = nil
   NewestStuff = nil
   AllStuff = {}
   NewestStuff = {}
   Count = 0
   Count2 = 0
	local f=io.open(file,"r")
	if f then
		for line in f:lines() do
			 Count = Count +1
			 AllStuff[Count]=line
		end
	end
   if Count > MaxNew then
      local temp = Count - MaxNew + 1
      for i=temp, Count do
         Count2 = Count2 + 1
         NewestStuff[Count2]=AllStuff[i]
      end
   else
      for i=1, Count do
         Count2 = Count2 + 1
         NewestStuff[Count2]=AllStuff[i]
      end
   end
end

function ShowRel(table)
   Msg = "\r\n"
   if table == NewestStuff then
      if Count2 == 0 then 
         MsgNew = "\r\n\r\n".." --------- The Latest Releases -------- \r\n\r\n  No releases on the list yet\r\n\r\n --------- The Latest Releases -------- \r\n\r\n"
      else
         for i=1, Count2 do
            s,e,type,who,when,title=string.find(NewestStuff[i], "(.+)$(.+)$(.+)$(.+)")
            if title then
               Msg = Msg.."  "..when.." -- "..who.." -- "..type.." -- "..title.."\r\n"
            else
               Msg = Msg..NewestStuff[i].."\r\n"
            end
         end
         MsgNew = "\r\n\r\n".." --------- The Latest "..MaxNew.." Releases -------- "..Msg.."\r\n --------- The Latest "..MaxNew.."  Releases -------- \r\n\r\n"
      end
   else
      if Count == 0 then
         MsgAll = "\r\n\r\r\n".." --------- All The Releases -------- \r\n\r\n  No releases on the list yet\r\n\r\n --------- All The Releases -------- \r\n\r\n"
      else
         MsgHelp = "  use "..cmd2.."  to see only the selected types"
         for i=1, Count do
            s,e,type,who,when,title=string.find(AllStuff[i], "(.+)$(.+)$(.+)$(.+)")
            if title then
               Msg = Msg.."  ID: "..i.." -- "..when.." -- "..who.." -- "..type.." -- "..title.."\r\n"
            else
               Msg = Msg..AllStuff[i].."\r\n"
            end
         end
         MsgAll = "\r\n\r\r\n".." --------- All The Releases -------- "..Msg.."\r\n --------- All The Releases -------- \r\n"..MsgHelp.."\r\n"
      end
   end
end

function ShowRelType(what)
   Msg = "\r\n"
   tmp = 0
   if Count == 0 then
      MsgType = "\r\n\r\n".." --------- All The "..Types[what].." -------- \r\n\r\n  No "..string.lower(Types[what]).." yet\r\n\r\n --------- All The "..Types[what].." -------- \r\n\r\n"
   else
      for i=1, Count do
         s,e,type,who,when,title=string.find(AllStuff[i], "(.+)$(.+)$(.+)$(.+)")
         if type == what then
            tmp = tmp + 1
            Msg = Msg.."  "..when.." -- "..who.." -- "..title.."\r\n"
         end
      end
      if tmp == 0 then
         MsgType = "\r\n\r\n".." --------- All The "..Types[what].." -------- \r\n\r\n  No "..string.lower(Types[what]).." yet\r\n\r\n --------- All The "..Types[what].." -------- \r\n\r\n"
      else
         MsgType= "\r\n\r\n".." --------- All The "..Types[what].." -------- \r\n"..Msg.."\r\n --------- All The "..Types[what].." -------- \r\n\r\n"
      end
   end
end

function AddRel(user, what, type)
   Count = Count + 1
   AllStuff[Count]=(type.."$"..user.sName.."$"..os.date("%x").."$"..what)
   user:SendData(Bot, what.." is added to the releases as "..type.."|")
   SendToAll(Bot, user.sName.." added to the "..type.." releases: "..what.."|")
   SaveRel()
   ReloadRel()
end

function DelRel(user, what)
   if tonumber(what) then 
      what = tonumber(what)
      if AllStuff[what] then
         local s,e,which=string.find(AllStuff[what], "([^%$]+)$")
         user:SendData(Bot, which.." is deleted from the releases|")
         AllStuff[what]=nil
         SaveRel()
         ReloadRel()
      else
         user:SendData(Bot, what.." wasn't found in the releases|")
      end
   else
      user:SendData(Bot, "I need the ID number to delete a releas|")
   end
end

function SaveRel()
   local f= io.open(file,"w+")
   for i=1,Count do
      if AllStuff[i] then
         f:write(AllStuff[i].."\n")
      end
   end
   f:flush()
   f:close(f)
end

function ReloadRel()
   OpenRel()
   ShowRel(NewestStuff)
   ShowRel(AllStuff)
end

function DelRelOld(user, what)
   Okie = nil
   for a,b in AllStuff do
      s,e,title=string.find(b, ".+$(.+)$")
      if title == what then
         AllStuff[a]=nil
         user:SendData(Bot, what.." is removed from the releases|")
         Okie = 1
         break
      end
   end
   if Okie then
      SaveRel()
      ReloadRel()
   else
      user:SendData(Bot, what.." wasn't found in the releases|")
   end
end

function SearchRel(user,what)
	local res=0
	local rest={}
	local _,_,bdc=string.find(what,"([%%%[%]%(%)%*%+%-%?%^])")
	local msg=""
	if bdc then
		user:SendData(Bot,"you cannot use the character "..bdc)
		return
	end
	for a,b in AllStuff do
		if string.find(b,what) then
			table.insert(rest,b)
		end
	end
	if table.getn(rest)~=0 then
		for a=1,table.getn(rest) do
			s,e,type,who,when,title=string.find(rest[a], "(.+)$(.+)$(.+)$(.+)")
			res = res + 1
			msg = msg.."\r\n  "..when.." -- "..who.." -- "..title
		end
		user:SendPM(Bot,msg.."\r\n\r\n"..res.." results.")
	else
		user:SendData(Bot,"Search string "..what.." was not found in releases database.")
	end
end
Everything could have been anything else and it would have just as much meaning.

QuikThinker

Gettin this error man Syntax C:\PHH-NEW\scripts\Fresh3.5.lua:207: attempt to call global `date' (a nil value)

bastya_elvtars

Thx for reporting, edited the script above.
Everything could have been anything else and it would have just as much meaning.

QuikThinker

Yer it works now man. Also in ma current version of Fresh when an item is added I've got this:
function AddRel(user, what, type)
   Count = Count + 1
   AllStuff[Count]=(type.."$"..user.sName.."$"..os.date("%x").."$"..what)
   user:SendData(Bot, what.." is added to the releases as "..type.."|")
      local msg = "|\r\n \r\n+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\r\n"
   ..what.." Has Jus' Been Added To The Pure Hip-Hop Releases As "..type..""..
   "\r\n+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\r\n"
   SendToAll(Bot, user.sName.." added to the "..type.." releases: "..what.."|")
   SaveRel()
   ReloadRel()
end

I put it in ur version but it aint workin, is it possible to adapt?

XPMAN

Tried this one out and its simply awesome!!!  Something you could help me with though is what would I have to add\change that would allow all profiles to    add   to it, instead of just Ops masters ect..?  This feature would be most excellent for the hub I run :)

Again, nicely done!

LiqUiD~TrolL

hello ppl  

this is great conversation m8
 =)

well i test it out and everything is working great


exept 1 thing   the _-->>> cmd6="+searchalbum"

this command doesnt seems to work

can you help ??
________<>________


            -=@_ psydream-land.no-ip.org _@=-


             
http://www.psychedelicdreams.bravehost.com

bastya_elvtars

QuoteOriginally posted by XPMAN
Tried this one out and its simply awesome!!!  Something you could help me with though is what would I have to add\change that would allow all profiles to    add   to it, instead of just Ops masters ect..?  This feature would be most excellent for the hub I run :)

Again, nicely done!

Yes, gonna make a complete rewrite soon. What will be in it?

    [*]Nicer listing (can be ordered by owner, name and category hopefully).
    [*]Profile-specific setting of commands.
    [*]Optimized metadata handling routine.
    [*]Flushing of releases, secured by secret code.
    [*]Autodeleting of old releases.
    [/list]
    Everything could have been anything else and it would have just as much meaning.

    plop

    QuoteOriginally posted by bastya_elvtars
    QuoteOriginally posted by XPMAN
    Tried this one out and its simply awesome!!!  Something you could help me with though is what would I have to add\change that would allow all profiles to    add   to it, instead of just Ops masters ect..?  This feature would be most excellent for the hub I run :)

    Again, nicely done!

    Yes, gonna make a complete rewrite soon. What will be in it?

      [*]Nicer listing (can be ordered by owner, name and category hopefully).
      [*]Profile-specific setting of commands.
      [*]Optimized metadata handling routine.
      [*]Flushing of releases, secured by secret code.
      [*]Autodeleting of old releases.
      [/list]
      gogogogo

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

      bastya_elvtars

      #8
      Ok, made a 3.7 version, changes are:

        [*]Metadata handling rewritten
        [*]Added ability to delete releases with one single line (i. e. +delalbum 1,3,45,6666)
        [*]Few minor bugfixes
        [*]Extended search a lil.
        [/list]

        Download here.
        Everything could have been anything else and it would have just as much meaning.

        jiten

        #9
        Great job, bastya! :)
        Btw, I was testing the FreshStuff 3.7 script and found a small "bug".
        When I add a release with more than one line like this:

        [22:04:16]  jiten added to the movie releases: sssssssssssssssssssssssss 
         
        sssssssssssssssssssssssss 
        sssssssssssssssssssssssss
        


        and then try to see the releases i get this:

        [22:04]  
        
        
         --------- All The Releases -------- 
          ID: 1 -- 03/21/05 -- jiten -- movie -- sssssssssssssssssssssssss
        
         --------- All The Releases -------- 
          use +albums  to see only the selected types
        


        It only reads the first line of the multi-line entry.
        Can u check that, please?
        Thanks in advance...

        jiten

        bastya_elvtars

        Here is a preview of 4.0, changed many-many things. You should back your files up.

        Usage:

          [*]Extract the archive to the PtokaX scripts folder
          [*]Copy your releases file to the folder named freshstuff.
          [/list]

          There can be bugs, altho kept testing it.

          Download here.
          Everything could have been anything else and it would have just as much meaning.

          jiten

          Keep it coming, bastya :]
          Gonna test it l8r.

          Cheers

          biggam

          yo can sum1 upload a easy .lua file that i can use for releases but i need one for ptokax 0.3.3.0 bulid 16.09 and robocop 10b . thank you

          bastya_elvtars

          Please tell me why this is NOT easy.

          If you mean the config, the default settings are good.
          Everything could have been anything else and it would have just as much meaning.

          bastya_elvtars

          No feedback @ all? :(
          Everything could have been anything else and it would have just as much meaning.

          Dessamator

          #15
          QuoteOriginally posted by bastya_elvtars
          No feedback @ all? :(

          hmm, feedback, really, heres some for u:::
          QuoteSyntax ....3.3.0.b16.09.nt.rls\scripts\freshstuff3.4.0pre1.lua:300: attempt to concatenate global `MsgHelp' (a nil value)
          Quoteline 300:   
          MsgAll = "\r\n\r\r\n".." --------- All The Releases -------- "..Msg.."\r\n --------- All The Releases -------- \r\n"..MsgHelp.."\r\n"

           :D
          Ignorance is Bliss.

          bastya_elvtars

          This error should NEVER occur. What brings it on? Could you please post your configuration?
          Everything could have been anything else and it would have just as much meaning.

          Dessamator

          QuoteOriginally posted by bastya_elvtars
          This error should NEVER occur. What brings it on? Could you please post your configuration?
          configuration, what configuration?, i downloaded the script, extracted to the script folder, restarted the scripts, and voila, there was the error that should "NEVER occur", NB.: i didnt change anything, and all others scripts were switched off !!
          Ignorance is Bliss.

          bastya_elvtars

          What is in your freshstuff folder?
          Everything could have been anything else and it would have just as much meaning.

          Dessamator

          QuoteWhat is in your freshstuff folder?

          well in the beginning there was only categories.dat, now there are two files namely :::
           categories.dat, releases.dat
          btw, im running ptokax 16.09, mayb thats the prob
          Ignorance is Bliss.

          bastya_elvtars

          That should not be a problem, this does not use too much of the api. However I haven't yet tested it with 16.09 as I am lazy. :)

          MsgHelp error occurs when some commands are nil or there are no categories.

          Oh, and please delete the OnExit() function and test it again.
          Everything could have been anything else and it would have just as much meaning.

          Dessamator

          #21
          nothing changed, same error ! :rolleyes: , well, ull just have to get past ur laziness, and "DOWNLOAD" ptokax 16.09 from here , there i even put a link to help with ur "laziness"
          Ignorance is Bliss.

          Dessamator

          #22
          function ShowRel(table)
          	Msg = "\r\n"
          	local type,who,when,title
          	if table == NewestStuff then
          		if Count2 == 0 then
          			MsgNew = "\r\n\r\n".." --------- The Latest Releases -------- \r\n\r\n  No releases on the list yet\r\n\r\n --------- The Latest Releases -------- \r\n\r\n"
          		else
          			for i=1, Count2 do
          				if NewestStuff[i] then
          					type,who,when,title=NewestStuff[i][1],NewestStuff[i][2],NewestStuff[i][3],NewestStuff[i][4]
          					if title then
          						Msg = Msg.."  ID: "..i.." -- "..when.." -- "..who.." -- "..type.." -- "..title.."\r\n"
          					else
          						Msg = Msg..(table.concat(NewestStuff[i])).."\r\n"
          					end
          				end
          			end
          		end
          		MsgNew = "\r\n\r\n".." --------- The Latest "..MaxNew.." Releases -------- "..Msg.."\r\n --------- The Latest "..MaxNew.."  Releases -------- \r\n\r\n"
          	else
          		if Count == 0 then
          			MsgAll = "\r\n\r\r\n".." --------- All The Releases -------- \r\n\r\n  No releases on the list yet\r\n\r\n --------- All The Releases -------- \r\n\r\n"
          		else
          			MsgHelp = "  use "..commands.cmd2.."  to see only the selected types"
          			for i=1, Count do
          				if AllStuff[i] then
          					type,who,when,title=AllStuff[i][1],AllStuff[i][2],AllStuff[i][3],AllStuff[i][4]
          					if title then
          						Msg = Msg.."  ID: "..i.." -- "..when.." -- "..who.." -- "..type.." -- "..title.."\r\n"
          					else
          						Msg = Msg..(table.concat(AllStuff[i])).."\r\n"
          					end
          				end
          			end	
          
          MsgAll = "\r\n\r\r\n".." --------- All The Releases -------- "..Msg.."\r\n --------- All The Releases -------- \r\n"..MsgHelp.."\r\n"
          
          		end
          
          	end
          end
          

          solved, i think, i just moved the:

          MsgAll = "\r\n\r\r\n".." --------- All The Releases -------- "..Msg.."\r\n --------- All The Releases -------- \r\n"..MsgHelp.."\r\n"
          


          ,upwards now its after 3 "end" and not 4!

          btw, theres only a trig to add categories, y not add 1 to delete them?
          Ignorance is Bliss.

          bastya_elvtars

          I wanna test for BUGS first, not add anything, if you do not use a category, it will not show up, altho planning to add.

          BTW yes,you found the bug, I just ignored this one, good job! :P

          The weird thing is, when I trigger saving from a normal function, it saves categories, but at OnExit() it only saves {}. Maybe the tables are flushed before OnExit(), I will ask PPK, but OnExit is not mandatory anyway, just a play-safe thing. THX again for the bug fix, gonna add category listing and deleting command.
          Also, post some more feature requests if you want to!
          Everything could have been anything else and it would have just as much meaning.

          Dessamator

          #24
          QuoteOriginally posted by bastya_elvtars
          I wanna test for BUGS first, not add anything, if you do not use a category, it will not show up, altho planning to add.

          BTW yes,you found the bug, I just ignored this one, good job! :P

          The weird thing is, when I trigger saving from a normal function, it saves categories, but at OnExit() it only saves {}. Maybe the tables are flushed before OnExit(), I will ask PPK, but OnExit is not mandatory anyway, just a play-safe thing. THX again for the bug fix, gonna add category listing and deleting command.
          Also, post some more feature requests if you want to!

          indeed it was a great job, i charge 1 dolar per word, ill expect my wage at the end of the week, :D.
          anyways, yw.
           for the testing of bugs, well u better use a good bug spray, i will bring all the bugs out, :D

          feature requests, lets c. a timer to display categories, an on or off switch for that, and something to remove automaticaly old albums , after a some days weeks or whatever !!,

          anyways hows the clone alert going, any progress?
          Ignorance is Bliss.

          SMF spam blocked by CleanTalk