Author Topic: Freshstuff 3.0 (rewritten by plop)  (Read 16649 times)

0 Members and 1 Guest are viewing this topic.

Offline plop

  • Forum God
  • ****
  • Posts: 2 464
  • Karma: +37/-0
(No subject)
« Reply #25 on: 13 August, 2004, 06:49:08 »
Quote
Originally 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
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 <----<<

PtokaX forum

(No subject)
« Reply #25 on: 13 August, 2004, 06:49:08 »

Offline UwV

  • Scripter
  • Lord
  • ******
  • Posts: 321
  • Karma: +38/-0
  • Music = Love
    • homepages
(No subject)
« Reply #26 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" ..
« Last Edit: 22 August, 2004, 01:59:02 by UwV »
\NL   The knowledge and skills you have achieved are meant to be forgotten so you can float comfortably in emptiness, without obstruction.
" Holly loves me,...  . "      ;o)

 & don't forget, the motto is :
  -- SUPPORT YOUR LOCAL DJ'S --

Offline daveP

  • Newbie
  • *
  • Posts: 4
  • Karma: +0/-0
(No subject)
« Reply #27 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

Offline plop

  • Forum God
  • ****
  • Posts: 2 464
  • Karma: +37/-0
(No subject)
« Reply #28 on: 23 August, 2004, 06:32:01 »
Quote
Originally 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.
Code: [Select]
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
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 <----<<

Offline daveP

  • Newbie
  • *
  • Posts: 4
  • Karma: +0/-0
(No subject)
« Reply #29 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

Offline plop

  • Forum God
  • ****
  • Posts: 2 464
  • Karma: +37/-0
(No subject)
« Reply #30 on: 25 August, 2004, 20:14:00 »
Quote
Originally 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
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 <----<<

Offline Robban

  • Member
  • ***
  • Posts: 26
  • Karma: +0/-0
(No subject)
« Reply #31 on: 13 September, 2004, 01:05:29 »
Quote
Originally posted by plop
Quote
Originally 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

Offline plop

  • Forum God
  • ****
  • Posts: 2 464
  • Karma: +37/-0
(No subject)
« Reply #32 on: 13 September, 2004, 21:01:14 »
Quote
Originally 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
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 <----<<

Offline Robban

  • Member
  • ***
  • Posts: 26
  • Karma: +0/-0
(No subject)
« Reply #33 on: 14 September, 2004, 02:25:51 »
It's working now... It only needed a reload

Offline Robban

  • Member
  • ***
  • Posts: 26
  • Karma: +0/-0
(No subject)
« Reply #34 on: 15 September, 2004, 18:21:03 »
Plop can't you make this work so that everyone can add.




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

Offline plop

  • Forum God
  • ****
  • Posts: 2 464
  • Karma: +37/-0
(No subject)
« Reply #35 on: 17 September, 2004, 06:36:28 »
use this 1.
Code: [Select]
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
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 <----<<

Offline mOrrI

  • Triple Ace
  • **
  • Posts: 150
  • Karma: +3/-0
    • Online Casino Tips
hellloloo..
« Reply #36 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

Offline Sarpanch

  • Member
  • ***
  • Posts: 37
  • Karma: +0/-0
(No subject)
« Reply #37 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?

Offline Sarpanch

  • Member
  • ***
  • Posts: 37
  • Karma: +0/-0
(No subject)
« Reply #38 on: 08 July, 2005, 16:24:47 »
Can anyone help plz?

Offline mOrrI

  • Triple Ace
  • **
  • Posts: 150
  • Karma: +3/-0
    • Online Casino Tips
(No subject)
« Reply #39 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

Offline Sarpanch

  • Member
  • ***
  • Posts: 37
  • Karma: +0/-0
(No subject)
« Reply #40 on: 08 July, 2005, 21:11:02 »
could u plz paste what you have got? as what ive got doesnt seem 2 work

Offline plop

  • Forum God
  • ****
  • Posts: 2 464
  • Karma: +37/-0
(No subject)
« Reply #41 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
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 <----<<

Offline mOrrI

  • Triple Ace
  • **
  • Posts: 150
  • Karma: +3/-0
    • Online Casino Tips
(No subject)
« Reply #42 on: 11 July, 2005, 13:09:16 »
Quote
Originally 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

Offline Pr?sten

  • Newbie
  • *
  • Posts: 9
  • Karma: +0/-0
hmm
« Reply #43 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
dvdr / Mp3 hub--> pentagon.no-ip.info

Offline tortilla

  • Member
  • ***
  • Posts: 25
  • Karma: +0/-0
freshstuff 4.4. by plop
« Reply #44 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

Offline bastya_elvtars

  • Forum God
  • ****
  • Posts: 3 725
  • Karma: +173/-7
  • The rock n' roll doctor
    • The FreshStuff3 Site
(No subject)
« Reply #45 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.
Everything could have been anything else and it would have just as much meaning.

Offline tortilla

  • Member
  • ***
  • Posts: 25
  • Karma: +0/-0
(No subject)
« Reply #46 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?

Offline tortilla

  • Member
  • ***
  • Posts: 25
  • Karma: +0/-0
the script 1 part
« Reply #47 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, [0] = 5, [1] = 4, [2] = 3, [3] = 2 } -- rights management, edit if you are using a bot that has default profiles

-- 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:-----------------------------------------------------------
« Last Edit: 06 November, 2005, 17:04:16 by tortilla »

Offline tortilla

  • Member
  • ***
  • Posts: 25
  • Karma: +0/-0
the script part 2
« Reply #48 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:-----------------------------------------------------------

Offline tortilla

  • Member
  • ***
  • Posts: 25
  • Karma: +0/-0
script 3
« Reply #49 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:---------------------------------------------------------------

PtokaX forum

script 3
« Reply #49 on: 06 November, 2005, 17:01:47 »