PtokaX forum

Archive => Archived 4.0 boards => Finished Lua 4 scripts => Topic started by: GaMeFaNaTiC on 01 January, 2004, 20:06:34

Title: Freshstuff 3.0 (rewritten by plop)
Post by: GaMeFaNaTiC on 01 January, 2004, 20:06:34
-- FreshStuff v.3.0
-- original idea/script by chilla
-- completely rewriten by plop


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

-- This command shows the stuff, syntax : +albums
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"

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

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

-- The file storing the stuff
file = "txt/AlbumsAll.txt"

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

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

function Main()
   frmHub:RegBot(Bot)
   Reload()
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 DataArrival(user,data)
   if (strsub(data, 1, 1) == "<") then
      data = strsub(data,1,strlen(data)-1)
      s,e,cmd,tune = strfind(data, "%b<>%s+(%S+)%s*(.*)")
      if cmd == cmd2 then
         user:SendPM(Bot, MsgAll.."|")
         return 1
      elseif cmd == cmd4 then
         user:SendPM(Bot, MsgNew.."|")
         return 1
      elseif user.bOperator then
         if cmd == cmd3 then
            if tune ~= "" then
               DelStuff(user, tune)
            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 ~= "" then
               AddStuff(user, tune)
            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!|")
            return 1
         end
      end
   end
end

function OpenStuff()
   AllStuff = nil
   NewestStuff = nil
   AllStuff = {}
   NewestStuff = {}
   Count = 0
   Count2 = 0
   readfrom(file)
   while 1 do
      local line = read()
      if ( line == nil ) then
         break
      else
         Count = Count +1
         AllStuff[Count]=line
      end
   end
   readfrom()
   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 SaveStuff()
   writeto(file)
   for i=1,Count do
      if AllStuff[i] then
         write(AllStuff[i].."\n")
      end
   end
   writeto()
end

function ShowAlbums(table)
   Msg = "\r\n"
   if table == NewestStuff then
      if Count2 == 0 then
         MsgNew = "\r\n\r\n".." --------- The Latest Albums -------- \r\nNo albums on the list yet\r\n --------- The Latest Albums -------- \r\n\r\n"
      else
         for i=1, Count2 do
            Msg = Msg..NewestStuff[i].."\r\n"
         end
         MsgNew = "\r\n\r\n".." --------- The Latest Albums -------- \r\n"..Msg.."\r\n --------- The Latest Albums -------- \r\n\r\n"
      end
   else
      if Count == 0 then
         MsgAll = "\r\n\r\r\n".." --------- All The Albums -------- \r\nNo albums on the list yet\r\n --------- All The Albums -------- \r\n\r\n"
      else
         for i=1, Count do
            Msg = Msg..AllStuff[i].."\r\n"
         end
         MsgAll = "\r\n\r\r\n".." --------- All The Albums -------- \r\n"..Msg.."\r\n --------- All The Albums -------- \r\n\r\n"
      end
   end
end

function AddStuff(user, what)
   Count = Count + 1
   AllStuff[Count]=what
   user:SendData(Bot, what.." is added to the albums|")
   SaveStuff()
   Reload()
end

function DelStuff(user, what)
   Okie = nil
   for a,b in AllStuff do
      if b == what then
         AllStuff[a]=nil
         user:SendData(Bot, what.." is removed from the albums|")
         Okie = 1
         break
      end
   end
   if Okie then
      SaveStuff()
      Reload()
   else
      user:SendData(Bot, what.." wasn't found in the albums|")
   end
end

function Reload()
   OpenStuff()
   ShowAlbums(NewestStuff)
   ShowAlbums(AllStuff)
end


+albums -- shows the full list
+newalbums -- shows the latest xx
+reloadalbums -- reloads the txt file (incase you manualy edit the file)
it uses only 1 file (AlbumsAll.txt)

An improved version of freshstuff.. rewriten by plop. i think this is an awsme script to use and mde a new post about it. enjoy !
Title: Freshstuff
Post by: [[SU]]Special-Ops on 01 January, 2004, 21:03:07
nice script, i converted it so i can use for movies in my hub. good work

HAPPY 2004    ;)
Title:
Post by: plop on 02 January, 2004, 03:14:00
i'm modding this script some more, but gotta do some other stuff 1st.
expect a update in the near future.
tiny preview.



 --------- All The Releases --------

  12/26/03 -- [TGA-OP]plop -- movie -- zusenzo
  12/26/03 -- [TGA-OP]plop -- music -- snap - cult of snap
  12/26/03 -- [TGA-OP]plop -- music -- herrie
  12/29/03 -- [TGA-OP]plopop -- warez -- tvtool v9.5.5.2 + v9.5.5.3
  12/29/03 -- [TGA-OP]plopop -- warez -- pixopedia 24 v1.0.4
  12/29/03 -- [TGA-OP]plopop -- warez -- SFV checker v1.10
  12/29/03 -- [TGA-OP]plopop -- warez -- trail doctor tdv131.zip

 --------- All The Releases --------
  use +albums to see only the selected types
plop
Title:
Post by: [SWE]henrik on 02 January, 2004, 10:21:08
thanks ill use this;) the realy great thing is that i not only made it work, i also understand it all:)
Title:
Post by: plop on 05 January, 2004, 00:33:08
here it is, freshstuff 3.2.
if you have been running 3.0 then i got the sad news that you have 2 delete the old file.
this 1 is using a diferent way of saving, but it sure looks a lot better.
-- FreshStuff v.3.2
-- 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

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

-- 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 = "txt/AlbumsAll.txt"

-- 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 DataArrival(user,data)
   if (strsub(data, 1, 1) == "<") then
      data = strsub(data,1,strlen(data)-1)
      s,e,cmd,type,tune = strfind(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!|")
            return 1
         end
      end
   end
end

function OpenRel()
   AllStuff = nil
   NewestStuff = nil
   AllStuff = {}
   NewestStuff = {}
   Count = 0
   Count2 = 0
   readfrom(file)
   while 1 do
      local line = read()
      if ( line == nil ) then
         break
      else
         Count = Count +1
         AllStuff[Count]=line
      end
   end
   readfrom()
   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=strfind(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.."          for a,b in Types do
            MsgHelp = MsgHelp.."/"..a
         end
         MsgHelp = MsgHelp.."> to see only the selected types"
         for i=1, Count do
            s,e,type,who,when,title=strfind(AllStuff[i], "(.+)$(.+)$(.+)$(.+)")
            if title then
               Msg = Msg.."  "..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 "..strlower(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=strfind(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 "..strlower(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.."$"..date("%x").."$"..what)
   user:SendData(Bot, what.." is added to the releases as "..type.."|")
   SaveRel()
   ReloadRel()
end

function DelRel(user, what)
   Okie = nil
   for a,b in AllStuff do
      s,e,title=strfind(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 SaveRel()
   writeto(file)
   for i=1,Count do
      if AllStuff[i] then
         write(AllStuff[i].."\n")
      end
   end
   writeto()
end

function ReloadRel()
   OpenRel()
   ShowRel(NewestStuff)
   ShowRel(AllStuff)
end
plop
Title:
Post by: BlazeXxX on 05 January, 2004, 02:43:20
Good work plop ;) Will it have control of who is allowed to add etc..?

for e.g. Only ops and above can add new releases or some kind?
Title:
Post by: plop on 05 January, 2004, 03:11:25
QuoteOriginally posted by BlazeXxX
Good work plop ;) Will it have control of who is allowed to add etc..?

for e.g. Only ops and above can add new releases or some kind?
yep only op's can add and delete stuff.

plop
Title:
Post by: DEEP-GOA on 07 January, 2004, 11:18:51
yauuuuu works fine - thanks!
Title:
Post by: plop on 19 January, 2004, 19:58:35
version 3.3.
change the way of deleting things.
+albums now shows an id number per entry, that number is used 2 delete things.
-- FreshStuff v.3.3
-- 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

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

-- 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 = "txt/AlbumsAll.txt"

-- 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 DataArrival(user,data)
   if (strsub(data, 1, 1) == "<") then
      data = strsub(data,1,strlen(data)-1)
      s,e,cmd,type,tune = strfind(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
            ReloadRel()
            user:SendData(Bot, "Albums reloaded!|")
            return 1
         end
      end
   end
end

function OpenRel()
   AllStuff = nil
   NewestStuff = nil
   AllStuff = {}
   NewestStuff = {}
   Count = 0
   Count2 = 0
   readfrom(file)
   while 1 do
      local line = read()
      if ( line == nil ) then
         break
      else
         Count = Count +1
         AllStuff[Count]=line
      end
   end
   readfrom()
   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=strfind(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.."          for a,b in Types do
            MsgHelp = MsgHelp.."/"..a
         end
         MsgHelp = MsgHelp.."> to see only the selected types"
         for i=1, Count do
            s,e,type,who,when,title=strfind(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 "..strlower(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=strfind(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 "..strlower(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.."$"..date("%x").."$"..what)
   user:SendData(Bot, what.." is added to the releases as "..type.."|")
   SaveRel()
   ReloadRel()
end

function DelRel(user, what)
   if tonumber(what) then
      what = tonumber(what)
      if AllStuff[what] then
         local s,e,which=strfind(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()
   writeto(file)
   for i=1,Count do
      if AllStuff[i] then
         write(AllStuff[i].."\n")
      end
   end
   writeto()
end

function ReloadRel()
   OpenRel()
   ShowRel(NewestStuff)
   ShowRel(AllStuff)
end
plop
Title:
Post by: GaMeFaNaTiC on 20 January, 2004, 19:42:21
kool plop  :D
Title: Mistake
Post by: Trust_in_Trance on 30 January, 2004, 10:04:36
Hi i found a small mistake in the last script you post
plob.

The manually reload of the list brings you an error.

Correct this
         elseif cmd == cmd5 then
            Reload()
            user:SendData(Bot, "Albums reloaded!|")
            return 1
         end

to:
         elseif cmd == cmd5 then
            ReloadRel()
            user:SendData(Bot, "Albums reloaded!|")
            return 1
         end


and there won`t be a problem any more.
Title:
Post by: Me?alCas?le? on 30 January, 2004, 10:43:39
Nice work Plop this is what we did talk about before cristmas if you remember !tday

Dam GOOD work Plop  8)
Title:
Post by: Trust_in_Trance on 30 January, 2004, 13:00:13
One question!
How i have to modify the bot that when a user tipes +allhubtime  that this is shown to all users in the main chat not only to the one who wrote it?
Title:
Post by: plop on 30 January, 2004, 15:39:52
QuoteOriginally posted by Trust_in_Trance
Hi i found a small mistake in the last script you post
plob.

The manually reload of the list brings you an error.

Correct this
         elseif cmd == cmd5 then
            Reload()
            user:SendData(Bot, "Albums reloaded!|")
            return 1
         end

to:
         elseif cmd == cmd5 then
            ReloadRel()
            user:SendData(Bot, "Albums reloaded!|")
            return 1
         end


and there won`t be a problem any more.
thx, that error must have slipped in when i converted this 2 work inside a.i.

plop
Title:
Post by: plop on 30 January, 2004, 15:45:15
QuoteOriginally posted by Trust_in_Trance
One question!
How i have to modify the bot that when a user tipes +allhubtime  that this is shown to all users in the main chat not only to the one who wrote it?
if i get your idea you want 2 replace this part.
     elseif cmd == cmd4 then
         user:SendPM(Bot, MsgNew.."|")
         return 1
      elseif user.bOperator then
for this.
     elseif cmd == cmd4 then
         user:SendPM(Bot, MsgNew.."|")
         return 1
      elseif cmd == cmd6 then
         SendToAll(Bot, MsgNew.."|")
         return 1
      elseif user.bOperator then
cmd6 becomes your +allhubtime, don't forget 2 add that 2 the config part of the script.

plop
Title: A lil bit of help
Post by: DoN on 04 March, 2004, 09:40:05
Wonder if someone could offer some help..

At the mo FreshshStuff has Categories such as..

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

I was just wondering if there will be a way to implement Sub Categories like for example for
Quote["music"]="Music",
you could have like POP, ROCK, JAZZ. As sub cats.


PLOP or any 1 willing to help?


Brgs
Title:
Post by: plop on 07 March, 2004, 19:38:52
QuoteOriginally posted by DoN
Wonder if someone could offer some help..

At the mo FreshshStuff has Categories such as..

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

I was just wondering if there will be a way to implement Sub Categories like for example for
Quote["music"]="Music",
you could have like POP, ROCK, JAZZ. As sub cats.


PLOP or any 1 willing to help?


Brgs
posible but how do you want it ??

+albums rock --- shows all rock albums

or

+albums music rock -- shows all rock albums from the catagory music
so +albums music -- would show all music catagory's.

gues the last as the 1st can be done by yourself.

plop
Title:
Post by: DoN on 07 March, 2004, 19:54:10
Well I wouldn't mind neither. As for the 1st idea as you said I could do that myself. I've already tried by just having loads of categories. So if I was to do +albums pop then in my categories I had already setted a "Types = {["pop"] = "Pop", But if I had the 2nd if you could make it better or the 2nd option of having +albums music pop is not 2 much to ask then I would appreciate whatever I end up with. :)

Is it possible so you could also have the content added formatted as...

Item ID - [DD/MM/YY] Category added by [Nick]        ::  Added Content

Brgs
Title:
Post by: plop on 07 March, 2004, 20:31:36
QuoteOriginally posted by DoN
Well I wouldn't mind neither. As for the 1st idea as you said I could do that myself. I've already tried by just having loads of categories. So if I was to do +albums pop then in my categories I had already setted a "Types = {["pop"] = "Pop", But if I had the 2nd if you could make it better or the 2nd option of having +albums music pop is not 2 much to ask then I would appreciate whatever I end up with. :)

Is it possible so you could also have the content added formatted as...

Item ID - [DD/MM/YY] Category added by [Nick]        ::  Added Content

Brgs
the id's are added the moment the script is running, you'll see that the number change the moment you add/delete something.
this makes it a bit useless 2 save them also.
the order it shows things like catagory/time/thingy can be changed by yourself.
just modify lines like this.
Msg = Msg.."  ID: "..i.." -- "..when.." -- "..who.." -- "..type.." -- "..title.."\r\n"i'll try 2 add the sub catagory's later, it's a nifty idea.

plop
Title:
Post by: DoN on 07 March, 2004, 21:16:54
QuoteOriginally posted by plop
the id's are added the moment the script is running, you'll see that the number change the moment you add/delete something.
this makes it a bit useless 2 save them also.
the order it shows things like catagory/time/thingy can be changed by yourself.
just modify lines like this.
Msg = Msg.."  ID: "..i.." -- "..when.." -- "..who.." -- "..type.." -- "..title.."\r\n"i'll try 2 add the sub catagory's later, it's a nifty idea.

plop

Thanx I didnt mean to have them saved in that format. Just meant to have it displayed like that but you have pasted the bit of code I can play about with to get looking like the way I may want it. Looking forward to the implement of sub cats. Thanx in advance :)

Brgs
Title:
Post by: [DK]DjBent on 20 April, 2004, 15:22:26
is there any way to change the prefix from + to !..as the other scripts i use are using ! in prefix.. and the sub catogoryes will be great...

Looking forward to your next update Plop
Title:
Post by: plop on 20 April, 2004, 17:26:28
QuoteOriginally posted by [DK]DjBent
is there any way to change the prefix from + to !..as the other scripts i use are using ! in prefix.. and the sub catogoryes will be great...

Looking forward to your next update Plop
you can change them in the top of the script.

version 4.2 is currently tested by some ppl.
but i got some questions for all of you.
---------------------------------------
  @show [option] - option can be (sub)catagory name or ID number.
  @add - add's a entry's to the given catagory name.
  @del - deletes the given id.
  @comment - adds your comment to the given id number.
  @decomment - deletes the given comment on the given ID.
  @addartist - adds the given artist name to the ID.
  @delartist - deletes the artist from the given ID.
  @addfilename - adds the given filename to the ID.
  @delfilename - deletes the filename from the given ID.
  @addurl - adds the given url to the ID.
  @delurl - deletes the url from the given ID.
  @addcat [subcat] - adds a (sub)catagory.
  @delcat - deletes a (sub)catagory.
  @search - searches the database for the given string.
  @config [ ] - shows the current config, more info is shown when no options are given!
---------------------------------------
not the most handy commands as you can see, my question is there for simple.
any1 got a better idea for them ?
i ask because it's really hard 2 change them yourself.

all left 2 do for the rest is something i kept forgetting, the showing of the latest x things 2 the users who enter the hub.

plop
Title:
Post by: [DK]DjBent on 20 April, 2004, 17:31:28
Looks Great... can't wait to get my hands on that script
Title:
Post by: Habalua on 13 August, 2004, 01:58:33
Can't you add so that it writes in mainchat that a new release is added not just to the bot. And can you update it for bcdc++ to?

Maybe a switch on/off on this funktion
Title:
Post by: plop on 13 August, 2004, 06:47:24
QuoteOriginally posted by [DK]DjBent
Looks Great... can't wait to get my hands on that script
there are some beta's avail on my site, aslong as you don't delete things the latest versions are pretty stable.

plop
Title:
Post by: plop on 13 August, 2004, 06:49:08
QuoteOriginally posted by Habalua
Can't you add so that it writes in mainchat that a new release is added not just to the bot. And can you update it for bcdc++ to?

Maybe a switch on/off on this funktion
don't they allready anounce it in mainchat??
i'm gone make a bcdc version of 4.x when the ptokax version is finished.
this way it safes me a lot of work.

plop
Title:
Post by: UwV on 22 August, 2004, 01:56:40
yup they do .. plop .. message in mian ..
but not the current bcdc version :0(
.. possible you add this still to the current version ?  :D

it might save us a lot of time waitning .. i mean no offence and all respect to busy you and the busy developpers of ptokax .. but the next version might be  a "while" ..
Title:
Post by: daveP on 22 August, 2004, 18:38:17
is there a way to set this script so that anyone can add stuff to the list not just ops

thanks dave
Title:
Post by: plop on 23 August, 2004, 06:32:01
QuoteOriginally posted by daveP
is there a way to set this script so that anyone can add stuff to the list not just ops

thanks dave
replace dataarival for this 1.
function DataArrival(user,data)
   if (strsub(data, 1, 1) == "<") then
      data = strsub(data,1,strlen(data)-1)
      s,e,cmd,type,tune = strfind(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.."|")
            return 1
         end
      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 == 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 == cmd5 then
            Reload()
            user:SendData(Bot, "Albums reloaded!|")
            return 1
         end
      end
   end
end
plop
Title:
Post by: daveP on 25 August, 2004, 13:29:58
yeh thats good m8 cheers :) but is there anyway you can get it so send to main chat screen what the bot says to the person adding so that everyone can see when a new release is added

chairs,

dave
Title:
Post by: plop on 25 August, 2004, 20:14:00
QuoteOriginally posted by daveP
yeh thats good m8 cheers :) but is there anyway you can get it so send to main chat screen what the bot says to the person adding so that everyone can see when a new release is added

chairs,

dave
freshstuff 3.4 allready does this.

plop
Title:
Post by: Robban on 13 September, 2004, 01:05:29
QuoteOriginally posted by plop
QuoteOriginally posted by daveP
yeh thats good m8 cheers :) but is there anyway you can get it so send to main chat screen what the bot says to the person adding so that everyone can see when a new release is added

chairs,

dave
freshstuff 3.4 allready does this.

plop






First 3.4 does not do this...

I use it for DCDM and it have work good until now I can only add 56 ID:s then I can't add any more. Nothing happning...

// Robban
Title:
Post by: plop on 13 September, 2004, 21:01:14
QuoteOriginally posted by Robban
First 3.4 does not do this...

I use it for DCDM and it have work good until now I can only add 56 ID:s then I can't add any more. Nothing happning...

// Robban
thats a different version of freshstuff.
the limit of 56 you encounter isn't due 2 the script or dcdm, it's the hub.
aka the chat limit.

plop
Title:
Post by: Robban on 14 September, 2004, 02:25:51
It's working now... It only needed a reload
Title:
Post by: Robban on 15 September, 2004, 18:21:03
Plop can't you make this work so that everyone can add.




Quotedcpp:setListener( "pm", "releases",
   function( hub, user, text )   
        local s = string.lower( text )
      d,e,cmd,typ,tune = string.find(s, "^(%S+)%s*(%S*)%s*(.*)")
        if cmd == cmd2 then
            if typ == "" then
                SendPMMsg( hub, user, MsgAll )
                --user:sendPrivMsgFmtNoWin( MsgAll )
                return 1
            elseif typ == "new" then
                SendPMMsg( hub, user, MsgNew )
                --user:sendPrivMsgFmtNoWin( MsgNew )
                return 1
            elseif Types[typ] then
                SendPMMsg( hub, user, ShowRelType(typ) )
                --user:sendPrivMsgFmtNoWin( MsgType )
                return 1
            end
        elseif cmd == cmd4 then
            SendPMMsg( hub, user, MsgNew )
            --user:sendPrivMsgFmtNoWin( MsgNew )  
            return 1
        elseif user:isOp() then
            if cmd == cmd3 then
                if typ ~= "" then
                    SendPMMsg( hub, user, DelRel(user, typ) )
                    --user:sendPrivMsgFmtNoWin( DelRel(user, typ) )
                else
                    SendPMMsg( hub, user, "yea right, like i know what i got 2 delete when you don't tell me!" )
                    --user:sendPrivMsgFmtNoWin( "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[typ] then
                    SendPMMsg( hub, user, AddRel(user, tune, typ) )
                    --user:sendPrivMsgFmtNoWin( AddRel(user, tune, typ) )
                elseif Types[typ] == nil then
                    SendPMMsg( hub, user, "I need to know the catagory to add it to!" )
                    --user:sendPrivMsgFmtNoWin( "I need to know the catagory to add it to!" )
                else
                    SendPMMsg( hub, user, "yea right, like i know what you got 2 add when you don't tell me!" )
                    --user:sendPrivMsgFmtNoWin(  "yea right, like i know what you got 2 add when you don't tell me!" )
                end
                return 1
            elseif cmd == cmd5 then
                ReloadRel()
                SendPMMsg( hub, user, "Reloaded!" )
                --user:sendPrivMsgFmtNoWin( "Reloaded!" )
                return 1
            end
   return 1 -- make bcdc++ forget the original message
end
Title:
Post by: plop on 17 September, 2004, 06:36:28
use this 1.
dcpp:setListener( "pm", "releases",
function( hub, user, text )
        local s = string.lower( text )
d,e,cmd,typ,tune = string.find(s, "^(%S+)%s*(%S*)%s*(.*)")
        if cmd == cmd2 then
            if typ == "" then
                SendPMMsg( hub, user, MsgAll )
                --user:sendPrivMsgFmtNoWin( MsgAll )
                return 1
            elseif typ == "new" then
                SendPMMsg( hub, user, MsgNew )
                --user:sendPrivMsgFmtNoWin( MsgNew )
                return 1
            elseif Types[typ] then
                SendPMMsg( hub, user, ShowRelType(typ) )
                --user:sendPrivMsgFmtNoWin( MsgType )
                return 1
            end
        elseif cmd == cmd4 then
            SendPMMsg( hub, user, MsgNew )
            --user:sendPrivMsgFmtNoWin( MsgNew )  
            return 1
        elseif cmd == cmd1 then
            if tune ~= "" and Types[typ] then
                SendPMMsg( hub, user, AddRel(user, tune, typ) )
                --user:sendPrivMsgFmtNoWin( AddRel(user, tune, typ) )
            elseif Types[typ] == nil then
                SendPMMsg( hub, user, "I need to know the catagory to add it to!" )
                --user:sendPrivMsgFmtNoWin( "I need to know the catagory to add it to!" )
            else
                SendPMMsg( hub, user, "yea right, like i know what you got 2 add when you don't tell me!" )
                --user:sendPrivMsgFmtNoWin(  "yea right, like i know what you got 2 add when you don't tell me!" )
            end
            return 1
        elseif user:isOp() then
            if cmd == cmd3 then
                if typ ~= "" then
                    SendPMMsg( hub, user, DelRel(user, typ) )
                    --user:sendPrivMsgFmtNoWin( DelRel(user, typ) )
                else
                    SendPMMsg( hub, user, "yea right, like i know what i got 2 delete when you don't tell me!" )
                    --user:sendPrivMsgFmtNoWin( "yea right, like i know what i got 2 delete when you don't tell me!" )
                end
                return 1
            elseif cmd == cmd5 then
                ReloadRel()
                SendPMMsg( hub, user, "Albums reloaded!" )
                --user:sendPrivMsgFmtNoWin( "Albums reloaded!" )
                return 1
            end
return 1 -- make bcdc++ forget the original message
end
end
)

pls next time ask in the client side scripting part of the board.

plop
Title: hellloloo..
Post by: mOrrI on 17 September, 2004, 12:45:11
hellooo, my hub is mainly to exchange music....

and i could use this script for anouncing new albuns and stuff....

but i whould like to know what's the latest version :D

thanks in advance :D
Title:
Post by: Sarpanch on 06 July, 2005, 12:59:39
Im Running Ptokax 0.3.3.1 and this script obviosuly isnt going to work is there any way of making it work? im willing 2 make chages myself if i can  :)  or wud i have to get a whole new script?
Title:
Post by: Sarpanch on 08 July, 2005, 16:24:47
Can anyone help plz?
Title:
Post by: mOrrI on 08 July, 2005, 16:30:12
i have it running fine in the  PtokaX 0.3.3.0 17.02 or higher can't remember....

what changed ???? isn't  lua 5
Title:
Post by: Sarpanch on 08 July, 2005, 21:11:02
could u plz paste what you have got? as what ive got doesnt seem 2 work
Title:
Post by: plop on 11 July, 2005, 12:08:41
bastya elvtars  continued on this script.
so check his version as i didn't add any features since then.
working on some bigger script @ the moment.

plop
Title:
Post by: mOrrI on 11 July, 2005, 13:09:16
QuoteOriginally posted by Sarpanch
could u plz paste what you have got? as what ive got doesnt seem 2 work

i will when i get home :p
Title: hmm
Post by: Pr?sten on 13 September, 2005, 01:50:21
I haved fixed the rigthklicks commands.
it was not wrong but i make it little more nice och cleaner.

but i cant post it here.. to long msg.

Can someone please add Request to, so there is one request lika freshbot 2.6

PLZ

Tnx

Pr?sten

-----------------------
Crasy swede with bad english
Title: freshstuff 4.4. by plop
Post by: tortilla on 06 November, 2005, 16:13:12
-- freshstuff 4.4.  by plop

don,t work

this its de message of ptokax

[17:07] Syntax ...e\0.3.3.21.nt.ibiza.dreams\scripts\freshstuff4.4.lua:1366: attempt to call global `readfrom' (a nil value)

i create de directory and de file manually but the file are empty
Title:
Post by: bastya_elvtars on 06 November, 2005, 16:37:08
You are trying to run a LUA4 script. Try FreshStuff3 of FreshStuff 2.6 since they are the only LUA5 vfersions.
Title:
Post by: tortilla on 06 November, 2005, 16:54:38
the freshstuff3.4.3.lua  not work

this its the error :

[17:49] Syntax ...:\Archivos Software\0.3.3.21.nt.ibiza.dreams\scripts\freshstuff3.4.3.lua:225: unexpected symbol near `then'

this is the script

  this is the ultimate for lua 5?
Title: the script 1 part
Post by: tortilla on 06 November, 2005, 16:56:12
code:-----------------------------------------------------------------
FreshStuff={Commands={},Levels={},AllStuff = {},NewestStuff = {},TopAdders={}} -- do not touch this line
--[[ FreshStuff 3 - 4.2
---------------------------------------------------------------------------------------
original idea/script by chilla,
anuncia novedades en el mainchat
---------------------------------------------------------------------------------------
------------------------- 3.7 -----------------------------
converted to lua5 and added search function by bastya_elvtars
also taken over with permission by plop. :P
rewrote the metadata routine: pattern matching is applied upon opening, using nested arrays ---> faster.
added ability to delete multiple releases with a single line.
--------------------------- 3.7.5 -----------------------------
-- added choice between showing in main or PM on entry
-- new stuff is shown by real ID (idea by LiqUiD~TrolL)
-- security fixes have been made, corrupt entries are ignored
-- added debug too.
fixed search case sensitivity bug, thx LiqUiD~TrolL
categories can remotely be added, no deletion/listing possible yet.
command levels are enabled, can be added here
rewrote command parsing totally
rewrote reload with a dirty trick
releases file and category config are arranged to a separate folder
commented some places that needed it ;)
---------------- --------------- 4.0 pre3 ------------------------------------------------
added showing and deleting of a category
fixed ugly bugs hopefully, please test
---------------- --------------- 4.0 pre4 ------------------------------------------------
the script is now standalone lua file again. if the freshstuff file is not found or corrupt, it remakes. also makes dir.
fixed the ShowOnEntry bug and the addcat typo, thx oldman
-------------------------------- 4.1 t1 ------------------------------------------------
made time format to MM/DD/YYYY, added backward compatibility with old file
rewrote PM sending, it sends items categorized.
rewrote search for new format
-- configurar datos del bot.

Bot = {
        name="-Novedator-",
        email="pegamento.tortilla@gmail.com",
        desc="Release bot",
      }
     
userlevels={ [-1] = 1,
-- No prefix for commands! It is automatically added. (<--- multiple prefixes)
 
FreshStuff.Commands.Add="addrel"

-- This command shows the stuff, syntax : +albums with options new/game/warez/music/movie
FreshStuff.Commands.Show="releases"

-- This command deletes an entry, syntax : +delalbum THESTUFF2DELETE
FreshStuff.Commands.Delete="delrel"

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

-- This is for searching inside releases.
FreshStuff.Commands.Search="searchrel"

-- For adding a category
FreshStuff.Commands.AddCatgry="addcat"

-- For deleting a category
FreshStuff.Commands.DelCatgry="delcat"

-- For showing categories
FreshStuff.Commands.ShowCtgrs="showcats"

-- Pruning releases (removing old entries)
FreshStuff.Commands.Prune="prunerel"

-- Showing top adders
FreshStuff.Commands.TopAdders="topadders"

-- what is this? :-o
FreshStuff.Commands.Help="relhelp"

-- You set the userlevels according to... you know what :P

-- adding
FreshStuff.Levels.Add=4

-- showing all
FreshStuff.Levels.Show=1

-- deleting
FreshStuff.Levels.Delete=4

-- reload
FreshStuff.Levels.ReLoad=4

-- search
FreshStuff.Levels.Search=1

-- add category
FreshStuff.Levels.AddCatgry=4

-- delete category
FreshStuff.Levels.DelCatgry=4

-- show categories
FreshStuff.Levels.ShowCtgrs=1

-- delete old releases
FreshStuff.Levels.Prune=5

-- show top release-adders
FreshStuff.Levels.TopAdders=1

-- guess :-P
FreshStuff.Levels.Help=1

-- maximum age of items
FreshStuff.MaxItemAge=30 --IN DAYS

-- shows top-adders on command, this is the number how many it should show
FreshStuff.TopAddersCount=5

-- Show latest stuff on entry 1=PM, 2=mainchat, 0=no
FreshStuff.ShowOnEntry = 2

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

-- Timed release announcing. You can specify a category name, or "all" or "new"
-- (like if you used the command ;-D)
FreshStuff.WhenAndWhatToShow=
  {
    ["18:01"]="Musica",
    ["19:00"]="Programas",
    ["20:12"]="Novedades",
  }
 
-- ====================================================================================
-- please do not edit below ===========================================================
-- ====================================================================================

rightclick,commandtable={},{}

FreshStuff.Timer=0

Bot.version="Novedades beta (by_Pegamento)"

function Main()
  frmHub:RegBot(Bot.name,1,Bot.desc,Bot.email)
  if loadfile("freshstuff/categories.dat") then
    dofile("freshstuff/categories.dat")
  else
      FreshStuff.Types={
         ["warez"]="Programas",
         ["game"]="Juegos",
         ["music"]="Musica",
         ["movie"]="Peliculas",
       }
    os.execute("md \""..frmHub:GetPtokaXLocation().."/scripts/freshstuff\"")
    SendToOps(Bot.name,"The categories file is corrupt or missing! Creating a new one...")
    SendToOps(Bot.name,"If this is the first time you run this script, or newly installed it, please copy releases.dat to the folder called freshstuff (located inside scripts folder, and restart your scripts. Thank you!")
    local f=io.open("freshstuff/categories.dat","w+")
    f:write(
  [[FreshStuff.Types={
  ["warez"]="Programas",
  ["game"]="Juegos",
  ["music"]="Musica",
  ["movie"]="Peliculas",
  }]])
    f:close()
  end
  RegCmd("relhelp",help,{},1,"\t\t\t\t\t\tShows the text you are looking at.")
  for a,b in FreshStuff.Types do
    RegRC(FreshStuff.Levels.Add,"1 3","Releases\\Add an item to the\\"..b,"!"..FreshStuff.Commands.Add.." "..a.." %[line:Name:]")
    RegRC(FreshStuff.Levels.Show,"1 3","Releases\\Show items of type\\"..b,"!"..FreshStuff.Commands.Show.." "..a)
    RegRC(FreshStuff.Levels.Help,"1 3","Releases\\Help",FreshStuff.Commands.Help)
  end
  FreshStuff.ReloadRel()
  SetTimer(1000)
  StartTimer()
end

function ChatArrival(user,data)
  data=string.sub(data,1,string.len(data)-1)
  local _,_,cmd=string.find(data,"%b<>%s+[%!%+%#%?%-](%S+)")
  if commandtable[cmd] then
    parsecmds(user,data,"MAIN",string.lower(cmd))
    return 1
  end
end

function ToArrival(user,data)
  data=string.sub(data,1,string.len(data)-1)
  local _,_,whoto,cmd = string.find(data,"$To:%s+(%S+)%s+From:%s+%S+%s+$%b<>%s+[%!%+%#%?%-](%S+)")
  if commandtable[cmd] then
    parsecmds(user,data,"PM",string.lower(cmd),whoto)
    return 1
  end
end

function NewUserConnected(user)
  if  user.bUserCommand then -- if login is successful, and usercommands can be sent
    -- let's alphabetize
    local rctosend={} -- create an array
    for a,b in rightclick do -- run thru the rightclick table
      if userlevels[user.iProfile] >= b then -- if user is allowed to use
        table.insert(rctosend,a) -- then put to the array
      end
    end
    table.sort(rctosend) -- sort the array
    user:SendData(table.concat(rctosend,"|")) -- and send all the data in one bolus :)
    user:SendData(Bot.name,"You just got "..table.getn(rctosend).." rightclick commands, please try them! :)")
  end
  if FreshStuff.ShowOnEntry ~=0 then
    if FreshStuff.ShowOnEntry==1 then
      SendTxt(user,"PM",Bot.name, FreshStuff.MsgNew)
    else
      SendTxt(user,"MAIN",Bot.name, FreshStuff.MsgNew)
    end
  end
end

function OnTimer()
  if FreshStuff.Timer < 60 then
    FreshStuff.Timer=FreshStuff.Timer+1
  else
    if FreshStuff.WhenAndWhatToShow[os.date("%H:%M")] then
      --if FreshStuff.Types[FreshStuff.WhenAndWhatToShow[os.date("%H:%M")]] then
        SendToAll(Bot.name, FreshStuff.ShowRelType(FreshStuff.WhenAndWhatToShow[os.date("%H:%M")]))
      else
        if FreshStuff.Types[FreshStuff.WhenAndWhatToShow[os.date("%H:%M")]] then
          SendToAll(Bot.name, FreshStuff.MsgNew)
        elseif FreshStuff.WhenAndWhatToShow[os.date("%H:%M")]=="new" then
          SendToAll(Bot.name, FreshStuff.ShowRelType(cat))
        else
          SendToOps(Bot.name,"Some fool added something to my timed ad list that I never heard of. :-)")
        end
      end
    end
    FreshStuff.Timer=0
  end
end

OpConnected=NewUserConnected
OpDisconnected=UserDisconnected

function parsecmds(user,data,env,cmd,bot)
  whoto=whoto or Bot.name
  if commandtable[cmd] then -- if it exists
    if commandtable[cmd]["level"]~=0 then -- and enabled
      if userlevels[user.iProfile] >= commandtable[cmd]["level"] then -- and user has enough rights
        commandtable[cmd]["func"](user,data,env,unpack(commandtable[cmd]["parms"])) -- user,data,env and more params afterwards
      else
        SendTxt(user,env,bot,"You are not allowed to use this command.")
      end
    else
      SendTxt(user,env,bot,"The command you tried to use is disabled now. Contact the hubowner if you want it back.")
    end
  end
end

function RegCmd(cmnd,func,parms,level,help) -- regs a command, parsed on ToArrival and ChatArrival
  commandtable[cmnd]={["func"]=func,["parms"]=parms,["level"]=level,["help"]=help}
end

function RegRC(level,context,name,command,PM)
  if level==0 then return 1 end
  if not PM then
    rightclick["$UserCommand "..context.." "..name.."$<%[mynick]> "..command.."|"]=level
  else
    rightclick["$UserCommand "..context.." "..name.."$$To: "..Bot.name.." From: %[mynick] $<%[mynick]> "..command.."|"]=level
  end
end

function SendTxt(user,env,bot,text) -- sends message according to environment (main or pm)
  if env=="PM" then
    user:SendPM(bot,text)
  else
    user:SendData(bot,text)
  end
end

function help(user,data,env)
  local count=0
  local hlptbl={}
  local hlp="\r\nCommands available to you are:\r\n=================================================================================================================================\r\n"
  for a,b in commandtable do
    if b["level"]~=0 then
      if userlevels[user.iProfile] >= b["level"] then
        count=count+1
        table.insert(hlptbl,"!"..a.." "..b["help"])
      end
    end
  end
  table.sort(hlptbl)
  hlp=hlp..table.concat(hlptbl,"\r\n").."\r\n\r\nAll the "..count.." commands you can use can be typed in main or in PM session with anyone, and the available prefixes are:"..
  " ! # + - ?\r\n================================================================================================================================="..Bot.version
  user:SendPM(Bot.name,hlp)
end
code:-----------------------------------------------------------
Title: the script part 2
Post by: tortilla on 06 November, 2005, 16:57:26
code:--------------------------------------------------------------
function FreshStuff.ShowCrap(user,data,env)
  local _,_,type= string.find(data, "%b<>%s+%S+%s+(%S+)")
  if not type then
    user:SendPM(Bot.name, FreshStuff.MsgAll)
  else
    if type == "new" then
      user:SendPM(Bot.name, FreshStuff.MsgNew)
    elseif FreshStuff.Types[type] then
      user:SendPM(Bot.name, FreshStuff.ShowRelType(type))
    else
      SendTxt(user,env,Bot.name,"No such type.")
    end
  end
end

function FreshStuff.AddCrap (user,data,env)
  local _,_,cat,tune= string.find(data, "%b<>%s+%S+%s+(%S+)%s+(.+)")
  if cat then
    if FreshStuff.Types[cat] then
      if string.find(tune,"%$") then SendTxt(user,env,Bot.name, "The release name must NOT contain dollar sign ($)!") return 1 end
      SendTxt(user,env,Bot.name, tune.." is added to the releases as "..cat)
      SendToAll(Bot.name, user.sName.." added to the "..cat.." releases: "..tune)
      FreshStuff.Count = FreshStuff.Count + 1
      FreshStuff.AllStuff[FreshStuff.Count]={cat,user.sName,os.date("%m/%d/%Y"),tune}
      FreshStuff.SaveRel()
      FreshStuff.ReloadRel()
    else
      SendTxt(user,env,Bot.name, "Unknown category: "..cat)
    end
  else
    SendTxt(user,env,Bot.name, "yea right, like i know what you got 2 add when you don't tell me!")
  end
end

function FreshStuff.OpenRel()
  FreshStuff.AllStuff,FreshStuff.NewestStuff = nil,nil
  collectgarbage(); io.flush()
  FreshStuff.AllStuff,FreshStuff.NewestStuff = {},{}
  FreshStuff.Count,FreshStuff.Count2 = 0,0
  local f=io.open("freshstuff/releases.dat","r")
  if f then
    for line in f:lines() do
      local _,_,cat,who,when,title=string.find(line, "(.+)$(.+)$(.+)$(.+)")
      if cat then
   if not FreshStuff.TopAdders[who] then FreshStuff.TopAdders[who]=1 else FreshStuff.TopAdders[who]=FreshStuff.TopAdders[who]+1 end
   if string.find(when,"%d+/%d+/0%d") then -- compatibility with old file format
     local _,_,m,d,y=string.find(when,"(%d+)/(%d+)/(0%d)")
     when=m.."/"..d.."/".."20"..y
   end
        FreshStuff.Count = FreshStuff.Count +1
   FreshStuff.AllStuff[FreshStuff.Count]={cat,who,when,title}
      else
   SendToOps(Bot.name, "Releases file is corrupt, failed to load all items.")
      end
    end
    f:close()
  end
  if FreshStuff.Count > FreshStuff.MaxNew then
    local tmp = FreshStuff.Count - FreshStuff.MaxNew + 1
    FreshStuff.Count2=FreshStuff.Count - FreshStuff.MaxNew + 1
    for i = tmp, FreshStuff.Count do
      FreshStuff.Count2=FreshStuff.Count2 + 1
      if FreshStuff.AllStuff[FreshStuff.Count2] then
   FreshStuff.NewestStuff[FreshStuff.Count2]=FreshStuff.AllStuff[FreshStuff.Count2]
      end
    end
  else
    for i=1, FreshStuff.Count do
      FreshStuff.Count2 = FreshStuff.Count2 + 1
      if FreshStuff.AllStuff then
   FreshStuff.NewestStuff[FreshStuff.Count2]=FreshStuff.AllStuff
      end
    end
  end
end

function FreshStuff.ShowRel(tab)
  local Msg = "\r\n"
  local cat,who,when,title
  local tmptbl={}
  if tab == FreshStuff.NewestStuff then
    if FreshStuff.Count2 == 0 then
      FreshStuff.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, FreshStuff.Count2 do
   if FreshStuff.NewestStuff then
     cat,who,when,title=unpack(FreshStuff.NewestStuff)
     if title then
       if FreshStuff.Types[cat] then cat=FreshStuff.Types[cat] end
       if not tmptbl[cat] then tmptbl[cat]={} end
       table.insert(tmptbl[cat],Msg.."ID: "..i.."\t"..title.." // (Added by "..who.." at "..when..")")
     end
   end
      end
    end
    for a,b in pairs (tmptbl) do
      Msg=Msg.."\r\n"..a.."\r\n"..string.rep("-",33).."\r\n"..table.concat(b).."\r\n"
    end      
    FreshStuff.MsgNew = "\r\n\r\n".." --------- The Latest "..FreshStuff.MaxNew.." Releases -------- "..Msg.."\r\n\ --------- The Latest "..FreshStuff.MaxNew.."  Releases -------- \r\n\r\n"
  else
    if FreshStuff.Count == 0 then
      FreshStuff.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
      FreshStuff.MsgHelp  = "  use "..FreshStuff.Commands.Show.." "
      for a,b in FreshStuff.Types do
   FreshStuff.MsgHelp  = FreshStuff.MsgHelp .."/"..a
      end
      FreshStuff.MsgHelp  = FreshStuff.MsgHelp .."> to see only the selected types"
      for i=1, FreshStuff.Count do
   if FreshStuff.AllStuff then
     cat,who,when,title=unpack(FreshStuff.AllStuff)
     if title then
       if FreshStuff.Types[cat] then cat=FreshStuff.Types[cat] end
       if not tmptbl[cat] then tmptbl[cat]={} end
       table.insert(tmptbl[cat],Msg.."ID: "..i.."\t"..title.." // (Added by "..who.." at "..when..")")
     end
   end
      end
      for a,b in pairs (tmptbl) do
   Msg=Msg.."\r\n"..a.."\r\n"..string.rep("-",33).."\r\n"..table.concat(b).."\r\n"
      end      
      FreshStuff.MsgAll = "\r\n\r\r\n".." --------- All The Releases -------- "..Msg.."\r\n --------- All The Releases -------- \r\n"..FreshStuff.MsgHelp .."\r\n"
    end
  end
end

function FreshStuff.ShowRelType(what)
  local cat,who,when,title
  local Msg,MsgType,tmp = "\r\n",nil,0
  if FreshStuff.Count == 0 then
    MsgType = "\r\n\r\n".." --------- All The "..FreshStuff.Types[what].." -------- \r\n\r\n  No "..string.lower(FreshStuff.Types[what]).." yet\r\n\r\n --------- All The "..FreshStuff.Types[what].." -------- \r\n\r\n"
  else
    for i=1, FreshStuff.Count do
      cat,who,when,title=unpack(FreshStuff.AllStuff)
      if cat == what then
   tmp = tmp + 1
   Msg = Msg.."ID: "..i.."\t"..title.." // (Added by "..who.." at "..when..")\r\n"
      end
    end
    if tmp == 0 then
      MsgType = "\r\n\r\n".." --------- All The "..FreshStuff.Types[what].." -------- \r\n\r\n  No "..string.lower(FreshStuff.Types[what]).." yet\r\n\r\n --------- All The "..FreshStuff.Types[what].." -------- \r\n\r\n"
    else
      MsgType= "\r\n\r\n".." --------- All The "..FreshStuff.Types[what].." -------- \r\n"..Msg.."\r\n --------- All The "..FreshStuff.Types[what].." -------- \r\n\r\n"
    end
  end
  return MsgType
end

function FreshStuff.DelCrap(user,data,env)
  local _,_,what=string.find(data,"%b<>%s+%S+%s+(.+)")
  if what then
    local cnt,x=0,os.clock()
    local tmp={}
    for w in string.gfind(what,"(%d+)") do
      table.insert(tmp,tonumber(w))
    end
    table.sort(tmp)
    for k=table.getn(tmp),1,-1 do
      if FreshStuff.AllStuff[k] then
   SendTxt(user,env,Bot.name, FreshStuff.AllStuff[tmp[k]][4].." is deleted from the releases.")
   FreshStuff.AllStuff[tmp[k]]=nil
   cnt=cnt+1
      else
   SendTxt(user,env,Bot.name, "release numbered "..wht.." wasn't found in the releases.")
      end
    end
    if cnt>0 then
      FreshStuff.SaveRel()
      FreshStuff.ReloadRel()
      SendTxt(user,env,Bot.name, "Deletion of "..cnt.." item(s) took "..os.clock()-x.." seconds.")
    end
  else
    SendTxt(user,env,Bot.name, "yea right, like i know what i got 2 delete when you don't tell me!.")
  end
end

function FreshStuff.SaveRel()
  local f= io.open("freshstuff/releases.dat","w+")
  for i=1,FreshStuff.Count do
    if FreshStuff.AllStuff then
      f:write(table.concat(FreshStuff.AllStuff,"$").."\n")
    end
  end
  f:flush()
  f:close()
end

function FreshStuff.ReloadRel(user,data,env)
  local x=os.clock()
  FreshStuff.OpenRel()
  FreshStuff.ShowRel(FreshStuff.NewestStuff)
  FreshStuff.ShowRel(FreshStuff.AllStuff)
  if user then SendTxt(user,env,Bot.name,"Releases reloaded, took "..os.clock()-x.." seconds.") end
end
code:-----------------------------------------------------------
Title: script 3
Post by: tortilla on 06 November, 2005, 17:01:47
code:----------------------------------------------------------------
function FreshStuff.SearchRel(user,data,env)
  local _,_,what=string.find(data,"%b<>%s+%S+%s+(.+)")
  if what then
    local res,rest=0,{}
    local _,_,bdc=string.find(what,"([%%%[%]%(%)%*%+%-%?%^%$])")
    local msg="\r\n---------- You searched for keyword \""..what.."\". The results: ----------\r\n\r\n"
    if bdc then
      SendTxt(user,env,Bot.name,"you cannot use the character "..bdc)
      return 1
    end
    for a,b in FreshStuff.AllStuff do
      if string.find(string.lower(b[4]),string.lower(what)) then
   table.insert(rest,{b[1],b[2],b[3],b[4]})
      end
    end
    if table.getn(rest)~=0 then
      for i=1,table.getn(rest) do
   local type,who,when,title=unpack(rest)
   res= res + 1
   msg = msg.."ID: "..i.."\t"..title.." // (Added by "..who.." at "..when..")\r\n"
      end
      msg=msg..string.rep("-",20).."\r\n"..res.." results."
    else
      msg=msg.."\r\nSearch string "..what.." was not found in releases database."
    end
    user:SendPM(Bot.name,msg)
  else
    SendTxt(user,env,Bot.name, "yea right, like i know what you got 2 search when you don't tell me!|")
  end
end

function FreshStuff.AddCatgry(user,data,env)
  local _,_,what1,what2=string.find(data,"%b<>%s+%S+%s+(%S+)%s+(.+)")
  if what1 then
    if string.find(what1,"%$") then SendTxt(user,env,Bot.name, "The dollar sign is not allowed.") return 1 end
    if not FreshStuff.Types[what1] then
      FreshStuff.Types[what1]=what2
      FreshStuff.SaveCt()
      SendTxt(user,env,Bot.name,"The category "..what1.." has successfully been added.")
    else
      if FreshStuff.Types[what1]==what2 then
   SendTxt(user,env,Bot.name,"Already having the type "..what1)
      else
   FreshStuff.Types[what1]=what2
   FreshStuff.SaveCt()
   SendTxt(user,env,Bot.name,"The category "..what1.." has successfully been changed.")
      end
    end
  else
    SendTxt(user,env,Bot.name,"Category should be added properly: +"..FreshStuff.Commands.AddCatgry.." ")
  end
end

function FreshStuff.DelCatgry(user,data,env)
  local _,_,what=string.find(data,"%b<>%s+%S+%s+(%S+)")
  if what then
    if not FreshStuff.Types[what] then
      SendTxt(user,env,Bot.name,"The category "..what.." does not exist.")
    else
      FreshStuff.Types[what]=nil
      FreshStuff.SaveCt()
      SendTxt(user,env,Bot.name,"The category "..what.." has successfully been deleted.")
    end
  else
    SendTxt(user,env,Bot.name,"Category should be deleted properly: +"..FreshStuff.Commands.DelCatgry.." ")
  end
end

function FreshStuff.ShowCatgries(user,data,env)
  local msg="\r\n======================\r\nAvilable categories:\r\n======================\r\n"
  for a,b in FreshStuff.Types do
    msg=msg.."\r\n"..a
  end
  user:SendPM(Bot.name,msg)
end

function FreshStuff.SaveCt()
  local f=io.open("freshstuff/categories.dat","w+")
  f:write("FreshStuff.Types={\n")
  for a,b in FreshStuff.Types do
    f:write("[\""..a.."\"]=\""..b.."\",\n")
  end
  f:write("}")
  f:close()
end

function FreshStuff.PruneRel(user,data,env)
  local _,_,days=string.find(data,"%b<>%s+%S+%s+(%d+)")
  days=days or FreshStuff.MaxItemAge
  local cnt=0
  local x=os.clock()
  SendToAll(Bot.name,"Release prune prodcess started, all releases older than "..days.." days will be deleted from the database.")
  local now=JulianDate(SplitTimeString(os.date("%m/%d/%Y".." 00:00:00")))
  local oldest=days*1440
  for i=FreshStuff.Count,1,-1 do
    local old=JulianDate(SplitTimeString(FreshStuff.AllStuff[3].." 00:00:00"))
    local diff=now-old
    local hours, mins= math.floor(diff) * 24 + math.floor(frac(diff) * 24), math.floor(frac(frac(diff)*24)*60)
    local tempus=hours*60+mins
    if tempus > oldest then
      FreshStuff.AllStuff=nil
      cnt=cnt+1
    end
  end
  SendToAll(Bot.name,FreshStuff.Count.." items were parsed and "..cnt.." were removed.")
  if cnt ~=0 then
    FreshStuff.SaveRel()
    FreshStuff.ReloadRel()
  end
end

function FreshStuff.ShowTopAdders(user,data,env)
  local tmp,numtbl,msg={},{},"\r\nThe top "..FreshStuff.TopAddersCount.." release-addders are:\r\n"..string.rep("-",33).."\r\n"
  for a,b in FreshStuff.TopAdders do
    table.insert(numtbl,b)
    tmp = tmp or {}
    table.insert(tmp,a)
  end
  table.sort(numtbl)
  local e
  if table.getn(numtbl) <= FreshStuff.TopAddersCount then e=1 else e=table.getn(numtbl)-FreshStuff.TopAddersCount end
  for k=table.getn(numtbl),e,-1 do
    for n,c in tmp[numtbl[k]] do
      msg=msg..c..": "..numtbl[k].."\r\n"
    end
  end
  user:SendPM(Bot.name,msg)
end
code:---------------------------------------------------------------