-- freshstuff 4.4. -- added showing of all availeble catagory's. -- added stats. -- added showing of the latest x releases.@new -- added re-indexing. -- added table upgrade. -- changed the length of the bars, they are all the same length now. -- by plop ---------------------- config part -- snif snif no config part anymore. ---------------------- end of config part ----------------------------------------------------------------------------- -- -- DON"T EVEN LOOK BELOW THIS LINE IF YOU DON"T KNOW LUA !!!!! -- ----------------------------------------------------------------------------- ---------------------- functions table Grab = {} ------------------------------------ upgrading from 4.3 to 4.4 Grab.Upgrade44 = function() Releases._Help[16]="new" Releases._Help[17]="showcats" Releases._Help[18]="stats" Releases._MaxNew=20 Releases._Level["stats"]={ [0]=1, [1]=1, [2]=1, [3]=1, [-1]=1 } Releases._Level["new"]={ [0]=1, [1]=1, [2]=1, [3]=1, [-1]=1 } Releases._Level["showcats"]={ [0]=1, [1]=1, [2]=1, [3]=1, [-1]=1 } Releases._HelpText["new"]=" - show the latest." Releases._HelpText["stats"]=" - Shows the top 10 posters." Releases._HelpText["showcats"]=" - shows all availeble catagory's." Releases._Prefix = { ["+"]=1, ["-"]=1, ["@"]=1 } end ------------------------------------ building of the empty database Grab.BuildTable = function() Releases = nil Releases={ _Help={ [1]="show", [2]="add", [3]="del", [4]="comment", [5]="decomment", [6]="addartist", [7]="delartist", [8]="addfilename", [9]="delfilename", [10]="addurl", [11]="delurl", [12]="addcat", [13]="delcat", [14]="search", [15]="config" }, _Who={ }, _Comm={ }, _BCat={ [1]="movie", [2]="warez", [3]="game", [4]="music", [5]="rock", [6]="pop", [7]="rap", [8]="classic" }, _IsSub={ }, _Artist={ }, _IsSubOf={ [8]=4, [5]=4, [6]=4, [7]=4 }, _Cat={ ["game"]=3, ["music"]=4, ["classic"]=8, ["warez"]=2, ["movie"]=1, ["rock"]=5, ["rap"]=7, ["pop"]=6 }, _FileName={ }, _SubCat={ ["rock"]=5, ["pop"]=6, ["rap"]=7, ["classic"]=8 }, _HighID=6, _BSubCat={ [8]="classic", [5]="rock", [6]="pop", [7]="rap" }, _Level={ ["addfilename"]={ [0]=1, [1]=1, [2]=1 }, ["decomment"]={ [0]=1, [1]=1 }, ["delcat"]={ [0]=1 }, ["del"]={ [0]=1, [1]=1 }, ["help"]={ [0]=1, [1]=1, [2]=1, [3]=1, [-1]=1 }, ["addartist"]={ [0]=1, [1]=1, [2]=1 }, ["delfilename"]={ [0]=1, [1]=1 }, ["addcat"]={ [0]=1 }, ["delartist"]={ [0]=1, [1]=1 }, ["search"]={ [0]=1, [1]=1, [2]=1, [3]=1, [-1]=1 }, ["addurl"]={ [0]=1, [1]=1, [2]=1 }, ["show"]={ [0]=1, [1]=1, [2]=1, [3]=1, [-1]=1 }, ["delurl"]={ [0]=1, [1]=1 }, ["comment"]={ [0]=1, [1]=1, [2]=1, [3]=1 }, ["config"]={ [0]=1 }, ["add"]={ [0]=1, [1]=1, [2]=1 } }, _Counter=1, _HelpText={ ["delartist"]=" - deletes the artist from the given ID.", ["addcat"]=" [subcat] - adds a (sub)catagory.", ["addfilename"]=" - adds the given filename to the ID.", ["decomment"]=" - deletes the given comment on the given ID.", ["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.", ["delcat"]=" - deletes a (sub)catagory.", ["search"]=" - searches the database for the given string.", ["addurl"]=" - adds the given url to the ID.", ["show"]="[option] - option can be (sub)catagory name or ID number.", ["config"]="[ ] - shows the current config, more info is shown when no options are given!", ["addartist"]=" - adds the given artist name to the ID.", ["delurl"]=" - deletes the url from the given ID.", ["delfilename"]=" - deletes the filename from the given ID." }, _Url={ }, _Date={ }, _IsType={ }, _Name={ }, _Bot = "post-it_memo" } Grab.Save() Grab.ResetCounter() end ------------------------------------ adding of catagory's Grab.AddCat = function(args, of) if args ~= nil then if of == "" then local c=1 for a,b in Releases._Cat do if b >= c then c=b end end c= c+1 Releases._Cat[args]=c Releases._BCat[c]=args Grab.Save() return "Done, the "..args.." catagory is added!" elseif Releases._Cat[of] then local c=1 for a,b in Releases._Cat do if b >= c then c=b end end c= c+1 Releases._Cat[args]=c Releases._BCat[c]=args Releases._IsSubOf[c]=Releases._Cat[of] Releases._SubCat[args]=c Releases._BSubCat[c]=args Grab.Save() return "Done, the "..args.." sub catagory is added!" else return "Unknown catagory!" end else return "Unknown error!" end end ------------------------------------ deleting of catagory's Grab.DelCat = function(args) if Releases._SubCat[args] then local c = Releases._SubCat[args] Releases._Cat[args]=nil Releases._BCat[c]=nil Releases._IsSubOf[c]=nil Releases._BSubCat[c]=nil Releases._SubCat[args]=nil Grab.Save() return "Done, the "..args.." sub catagory has been deleted!" elseif Releases._Cat[args] then local c = Releases._Cat[args] Releases._BCat[c]=nil Releases._Cat[args]=nil Grab.Save() return "Done, the "..args.." catagory has been deleted!" else return "Unknown catagory!" end end ------------------------------------ showing of catagory's Grab.ShowCats = function() local t = {} local i for a,b in Releases._Cat do if Releases._IsSubOf[b] then i = Releases._BCat[(Releases._IsSubOf[b])] else i=a end if t[i] then t[i]=t[i].." / "..a else t[i]=a end end local line = "\r\n\r\n---------------------------------------------------------------\r\n" line = line.." catagory's\tsub catagory's\r\n" line = line.."---------------------------------------------------------------" for a,b in t do if strfind(b, "%/") then line = line.."\r\n "..(gsub(b, "%/", "\t\t", 1)) else line = line.."\r\n "..a end end line = line.."\r\n---------------------------------------------------------------\r\n" return line end ------------------------------------ delete things Grab.Del = function(args) if Releases._Name[args] then local arg = args Releases._Name[arg] = nil if Releases._FileName[arg] then Releases._FileName[arg] = nil end if Releases._Artist[arg] then Releases._Artist[arg] = nil end if Releases._Date[arg] then Releases._Date[arg] = nil end if Releases._Who[arg] then Releases._Who[arg] = nil end if Releases._IsType[arg] then Releases._IsType[arg] = nil end if Releases._IsSub[arg] then Releases._IsSub[arg] = nil end if Releases._Comm[arg] then Releases._Comm[arg] = nil end if Releases._Url[arg] then Releases._Url[arg] = nil end Grab.ReIndex() Grab.Save() Grab.ResetCounter() return "Done" else return "Unknown ID" end end ------------------------------------ deleting of comments Grab.DelComm = function(args, what) if Releases._Name[args] then if Releases._Comm[args] then if Releases._Comm[args][what] then Releases._Comm[args][what] = nil Grab.Save() return "Done!" else return "That ID has no comment number: "..what.."!" end else return "That ID has no comments!" end else return "Unknown ID!" end end ------------------------------------ deleting of filenames Grab.DelFileName = function(args) if Releases._Name[args] then if Releases._FileName[args] then Releases._FileName[args] = nil Grab.Save() return "Done!" else return "That ID has no filename!" end else return "Unknown ID!" end end ------------------------------------ deleting or artists Grab.DelArtist = function(args) if Releases._Name[args] then if Releases._Artist[args] then Releases._Artist[args] = nil Grab.Save() return "Done!" else return "That ID has no artist!" end else return "Unknown ID!" end end ------------------------------------ deleting of urls Grab.DelUrl = function(args) if Releases._Name[args] then if Releases._Url[args] then Releases._Url[args] = nil Grab.Save() return "Done!" else return "That ID has no url!" end else return "Unknown ID!" end end ------------------------------------ adding of things Grab.Add = function(user, args, what) if Releases._Cat[args] then Releases._HighID = Releases._HighID +1 Releases._Name[Releases._HighID] = what Releases._Who[Releases._HighID] = user.sName Releases._Date[Releases._HighID] = date("%x") if Releases._SubCat[args] then Releases._IsSub[Releases._HighID] = Releases._Cat[args] Releases._IsType[Releases._HighID] = Releases._IsSubOf[( Releases._Cat[args]) ] else Releases._IsType[Releases._HighID] = Releases._Cat[args] end Grab.Save() Grab.ResetCounter() return "Done" else return "Unknown catagory name" end end ------------------------------------ adding of comments Grab.AddComm = function(args, what) if Releases._Name[args] then if Releases._Comm[args] == nil then Releases._Comm[args] ={} end local t=1 for a,b in Releases._Comm[args] do if a >= t then t = a+1 end end Releases._Comm[args][t] =what Grab.Save() return "Done!" else return "Unknown ID!" end end ------------------------------------ adding of filenames Grab.AddFileName = function(args, what) if Releases._Name[args] then Releases._FileName[args] = what Grab.Save() return "Done!" else return "Unknown ID!" end end ------------------------------------ adding or artists Grab.AddArtist = function(args, what) if Releases._Name[args] then Releases._Artist[args] = what Grab.Save() return "Done!" else return "Unknown ID!" end end ------------------------------------ adding of urls Grab.AddUrl = function(args, what) if Releases._Name[args] then Releases._Url[args] = what Grab.Save() return "Done!" else return "Unknown ID!" end end ------------------------------------ retrieve things by ID Grab.ByID = function(args) if Releases._Name[args] then local a = args line = "\r\n\r\n---------------------------------------------------------------\r\n" line = line.." ID:\t\t"..a.."\r\n" line = line.." Name:\t\t"..format("%8s", (Releases._Name[a]) ).."\r\n" if Releases._IsSub[a] then line = line.." Catagory:\t"..Releases._BSubCat[(Releases._IsSub[a])].." "..Releases._BCat[(Releases._IsType[a])].."\r\n" else line = line.." Catagory:\t"..Releases._BCat[(Releases._IsType[a])].."\r\n" end if Releases._Date[a] then line = line.." Date:\t\t"..Releases._Date[a].."\r\n" end if Releases._Who[a] then line = line.." By:\t\t"..format("%8s", (Releases._Who[a]) ).."\r\n" end if Releases._FileName[a] then line = line.." Filename:\t"..format("%8s", (Releases._FileName[a]) ).."\r\n" end if Releases._Url[a] then line = line.." Url:\t\t"..format("%8s", (Releases._Url[a]) ).."\r\n" end if Releases._Comm[a] then for c,d in Releases._Comm[a] do line = line.." Comment: "..c.."\t"..format("%8s",d).."\r\n" end end line = line.."---------------------------------------------------------------\r\n" return line else return "FOOOOL. that id doesn't excist!!" end end ------------------------------------ retrieve things by type Grab.ByType = function(args) if Releases._Cat[args] then line = "\r\n\r\n---------------------------------------------------------------\r\n" if Releases._SubCat[args] then local args = Releases._SubCat[args] for id,cat in Releases._IsSub do if cat == args then line = line.." "..id.." - " if Releases._IsSub[id] then line = line..Releases._BSubCat[ (Releases._IsSub[id]) ].." "..Releases._BCat[(Releases._IsType[id])].." " else line = line..Releases._BCat[(Releases._IsType[id])].." " end if Releases._Artist[id] then line = line.."\t"..Releases._Artist[id].."\t" else line = line.."\t\t" end line = line..Releases._Name[id].."\r\n" end end return line.."---------------------------------------------------------------\r\n" else local args = Releases._Cat[args] for id,cat in Releases._IsType do if cat == args then line = line.." "..id.." - " if Releases._IsSub[id] then line = line..Releases._BSubCat[ (Releases._IsSub[id]) ].." "..Releases._BCat[(Releases._IsType[id])].." " else line = line..Releases._BCat[(Releases._IsType[id])].." " end if Releases._Artist[id] then line = line.."\t"..Releases._Artist[id].."\t" else line = line.."\t\t" end line = line..Releases._Name[id].."\r\n" end end return line.."---------------------------------------------------------------\r\n" end else return "error: "..(args or "nil" ) end end ------------------------------------ the search for items Grab.Search = function(args) c=0 T = {} for a,b in Releases._Name do if strfind(b, args) then T[a]=1 c=c+1 end end for a,b in Releases._FileName do if strfind(b, args) then T[a]=1 c=c+1 end end for a,b in Releases._Artist do if strfind(b, args) then T[a]=1 c=c+1 end end for a,b in Releases._Date do if strfind(b, args) then T[a]=1 c=c+1 end end for a,b in Releases._Who do if strfind(b, args) then T[a]=1 c=c+1 end end for a,b in Releases._Url do if strfind(b, args) then T[a]=1 c=c+1 end end for a,b in Releases._Comm do for e,f in Releases._Comm[a] do if strfind(f, args) then T[a]=1 c=c+1 end end end if c == 0 then return "Nothing found. Try again with a different search string!" else line2 = "\r\n\r\n---------------------------------------------------------------\r\n" for a,b in T do line2 = line2.." "..a.." - " if Releases._IsSub[a] then line2 = line2..Releases._BSubCat[(Releases._IsSub[a])].." "..Releases._BCat[(Releases._IsType[a])].." " else line2 = line2..Releases._BCat[(Releases._IsType[a])].." " end if Releases._Artist[a] then line2 = line2.."\t"..Releases._Artist[a].."\t" else line2 = line2.."\t\t" end line2 = line2..Releases._Name[a].."\r\n" end T = nil return line2.."--------------- Found "..c.." matches on the list ------------------------\r\n" end end ------------------------------------ saving the table Grab.Save = function() writeto("freshdata/freshdatabase.lua") write("\n--config file for freshstuff 4.x, better not edit this by hand if you don't know what your doing\n\nReleases={\n") local t = "" for a,b in Releases do write(t.."\n "..a.."=") if t == "" then t = "," end if type(b) == "string" then write(format("%q", b)) -- not used in this thing elseif type(b) == "number" then write(b) elseif type(b) == "table" then t2 = "" t3 = "" write("{") for c,d in b do if type(c) =="number" then write(t2.."\n ["..c.."]=") if t2 == "" then t2 = "," end if type(d) == "string" then write(format("%q", d)) elseif type(d) == "number" then write(d) elseif type(d) == "table" then write("{") t4 = "" for e,f in d do write(t4.."\n ["..e.."]="..format("%q", f) ) if t4 == "" then t4 = "," end end write("\n }") else SendToAll(Releases._Bot, "what the hell are you trying 2 save plop, thats no number/table or string!|") end elseif type(c) == "string" then write(t3.."\n ["..format("%q", c).."]=") if t3 == "" then t3 = "," end if type(d) == "string" then write(format("%q", d)) elseif type(d) == "number" then write(d) elseif type(d) == "table" then write("{") t5 = "" for e,f in d do write(t5.."\n ["..e.."]="..f ) if t5 == "" then t5 = "," end end write("\n }") else SendToAll(Releases._Bot, "what the hell are you trying 2 save plop, thats no number/table or string!|") end else SendToAll(Releases._Bot, "what the hell are you trying 2 save plop, thats no number or string!|") end end write("\n }") else SendToAll(Releases._Bot, "what the hell are you trying 2 save plop|") end end write("\n}\n\n--plopyrights reserved") writeto() return "Done" end ------------------------------------ the config showing part Grab.ShowConfig = function() local line2 = nil local t =1 local tmp = {} for a,b in Releases._Help do tmp[t]=b t = t + 1 end for i=1,18 do --for a,b in Releases._Level do local a = tmp[i] local b = Releases._Level[a] if line2 == nil then line2 = "\r\n\r\n---------------------------------------------------------------\r\n" else line2 = line2.."\r\n" end if strlen(a) < 9 then line2 = line2.." @"..a.."\t\t- " else line2 = line2.." @"..a.."\t- " end for c,d in b do line2 = line2.." "..c end end line2 = line2.."\r\n---------------------------------------------------------------\r\n" line2 = line2.." +\t\t- adds acces 2 the command for the given level.\r\n" line2 = line2.." -\t\t- removes acces 2 the command for the given level.\r\n" line2 = line2.." down\t\t\t- moves the command down in the help menu.\r\n" line2 = line2.." up\t\t\t- moves the command up in the help menu.\r\n" line2 = line2.." botname \t- moves the command up in the help menu.\r\n\r\n" line2 = line2.." \"@config add +2 -1\"\t- adds the vip level and removes unreged users to the add command.\r\n" line2 = line2.." \"@config add down\"\t- moves the add command 1 step down in the help menu.\r\n" return line2.."\r\n---------------------------------------------------------------\r\n" end ------------------------------------ the config modding part Grab.ModConfig = function(args, levels) if args ~= "config" then T = {} line2 = gsub(levels, "([%-%+])(%S+)", function(ms,num) return Grab.BT(ms,num) end) for a,b in T do if b == "-" then Releases._Level[args][a]=nil line2 = line2..", level "..a.." removed " else Releases._Level[args][a]=1 line2 = line2..", level "..a.." added " end end else line2 = line2.." the levels for this command can't be changed! " end T = nil local s,e,updown = strfind(levels, "(%S+)%s*$") if updown then if updown == "down" then T = Grab.Movedown(args) if line2 == "down" then line2 = args.." moved 1 step down! \r\n"..T else line2 = (gsub(line2, "down", args.." moved 1 step down ")).."\r\n"..T end elseif updown == "up" then T = Grab.MoveUp(args) if T ~="Done!" then line2 = (gsub(line2, "up", "")).."\r\n"..T elseif line2 == "up" then line2 = args.." moved 1 step up! \r\n"..T else line2 = (gsub(line2, "up", args.." moved 1 step up ")).."\r\n"..T end end end T=nil local s,e,botname = strfind((args.." "..levels), "botname%s*(%S+)") if botname then SendPmToNick("[TGA-OP]plop",Releases._Bot, botname) if line2 then SendPmToNick("[TGA-OP]plop",Releases._Bot, line2) local s,e,T= strfind(line2, "(%S+)") if T then SendPmToNick("[TGA-OP]plop",Releases._Bot, " T = "..T) line2 = gsub(line2, T, "") end SendPmToNick("[TGA-OP]plop",Releases._Bot, line2) else line2 = "" end line2 = line2.."botname is changed from "..Releases._Bot.." to "..botname frmHub:UnregBot(Releases._Bot) Releases._Bot = botname frmHub:RegBot(Releases._Bot) end Grab.Save() return "\r\n\r\n"..line2.."\r\n" end Grab.BT = function(ms, num) if tonumber(num) then num = tonumber(num) T[num] = ms return "" end end Grab.Movedown = function(args) for a,b in Releases._Help do if b == args then if a ~= 15 then Releases._Help[a] = Releases._Help[(a+1)] Releases._Help[(a+1)] =b return "Done!" elseif a == 15 then return "Can't move "..args.." down any further!" end break end end end Grab.MoveUp = function(args) for a,b in Releases._Help do if b == args then if a ~= 1 then Releases._Help[a] = Releases._Help[(a-1)] Releases._Help[(a-1)] =b return "Done!" elseif a == 1 then return "Can't move "..args.." up any further!" end break end end end ------------------------------------ reset counters and trigger build of new menu's Grab.ResetCounter = function() Releases._Counter = 0 Releases._HighID = 0 for a,b in Releases._Name do if a > Releases._HighID then Releases._HighID = a end Releases._Counter = Releases._Counter + 1 end Grab.All = nil Grab.New = nil end ------------------------------------ reindexing the ID's so they are inline again Grab.ReIndex = function() for i=1,Releases._Counter do if Releases._Name[i] == nil then -- the always excisting tables Grab.MoveIndex(Releases._Name, i) Grab.MoveIndex(Releases._IsType, i) Grab.MoveIndex(Releases._Date, i) Grab.MoveIndex(Releases._Who, i) -- the sometimes excisting tables if Releases._Comm[i] then Grab.MoveIndex(Releases._Comm, i) end if Releases._FileName[i] then Grab.MoveIndex(Releases._FileName, i) end if Releases._Artist[i] then Grab.MoveIndex(Releases._Artist, i) end if Releases._Url[i] then Grab.MoveIndex(Releases._Url, i) end end end end ------------------------------------ the actual moving of the things Grab.MoveIndex = function(tTable, i) tTable[i] = tTable[(i+1)] tTable[(i+1)] = nil end ------------------------------------ build menu's Grab.BuildAll = function() local t, line2= nil, nil for id,name in Releases._Name do if t == nil then t = 1 end if line2 == nil then line2 = "\r\n\r\n---------------------------------------------------------------\r\n" end line2 = line2.." "..id.." - " if Releases._IsSub[id] and Releases._IsType[id] and Releases._BCat[(Releases._IsType[id])] then line2 = line2..Releases._BSubCat[(Releases._IsSub[id])].." "..Releases._BCat[(Releases._IsType[id])].." " elseif Releases._IsType[id] and Releases._BCat[(Releases._IsType[id])] then line2 = line2..Releases._BCat[(Releases._IsType[id])].." " end if Releases._Artist[id] then line2 = line2.."\t"..Releases._Artist[id].."\t" else line2 = line2.."\t\t" end if Releases._Name[id] then line2 = line2..Releases._Name[id].."\r\n" else line2 = line2.."\r\n" end end if t == nil then line2 = "\r\n\r\n---------------------------------------------------------------\r\n" line2 = line2.." None found!\r\n" end return line2.."---------------there are "..Releases._Counter.." on the list ------------------------\r\n" end ------------------------------------ build latest things Grab.BuildLatest = function() local t, line2= nil, nil if Releases._Counter == 0 then line2 = "\r\n\r\n---------------------------------------------------------------\r\n" line2 = line2.." None found!\r\n" line2 = line2.."---------------------------------------------------------------\r\n" return line2 else local Max = Releases._Counter-Releases._MaxNew if Max <=0 then Max = 1 end for id=Releases._Counter, Max, -1 do if t == nil then t = 1 else t =t +1 end if line2 == nil then line2 = "\r\n\r\n---------------------------------------------------------------\r\n" end line2 = line2.." "..Releases._Date[id].." - " if Releases._IsSub[id] and Releases._IsType[id] and Releases._BCat[(Releases._IsType[id])] then line2 = line2..Releases._BSubCat[(Releases._IsSub[id])].." "..Releases._BCat[(Releases._IsType[id])].." " elseif Releases._IsType[id] and Releases._BCat[(Releases._IsType[id])] then line2 = line2..Releases._BCat[(Releases._IsType[id])].." " end if Releases._Artist[id] then line2 = line2.."\t"..Releases._Artist[id].."\t" else line2 = line2.."\t\t" end if Releases._Name[id] then line2 = line2..Releases._Name[id].."\r\n" else line2 = line2.."\r\n" end end if t == nil then line2 = "\r\n\r\n---------------------------------------------------------------\r\n" line2 = line2.." None found!\r\n" end end return line2.."---------------the latest "..t.." releases on the list ------------------------\r\n" end ------------------------------------ building the help menu Grab.BuildHelp = function(prof) local line2 = nil for i=1,18 do b = Releases._Help[i] if Releases._Level[b][prof] then if line2 == nil then line2 = "\r\n\r\n---------------------------------------------------------------\r\n" end line2 = line2.." @"..b.." "..Releases._HelpText[b].."\r\n" end end if line2 ~= nil then return line2.."---------------------------------------------------------------\r\n" else return "you may not acces this bot!" end end Grab.BuildStats = function() local line = nil local c = 0 local d = 0 local t = {} local u = {} -- 1st getting the amounts a person has released for a,b in Releases._Who do if t[b] then t[b]= t[b]+1 else t[b]=1 end if t[b] > c then c = t[b] end end -- checking matching user stats for a,b in t do if u[b] then u[b]=(u[b].." / "..a) else u[b]=a end end -- building the top 10 if c ~= 0 then for i=c,1, -1 do if line == nil then line = "\r\n\r\n---------------------------------------------------------------\r\n" line = line.."\ttop 10\r\n" line = line.."---------------------------------------------------------------\r\n" end if u[i] then line = line.." "..i.." --\t"..u[i]..".\r\n" d = d + 1 if d == 10 then break end end end line = line.."---------------------------------------------------------------\r\n" else line = "no stats yet" end return line end ----------------- commands table Commands = { ["save"] = function(user, data) user:SendPM(Releases._Bot, Grab.Save().."|") end, ["config"] = function(user, data) if Releases._Level["config"][user.iProfile] then s,e,args,args2 = strfind(data, "%b<>%s*%S+%s*(%S*)%s*(.*)$") if args == "" then user:SendPM(Releases._Bot, Grab.ShowConfig().."|" ) elseif (Releases._Level[args] or args == "botname") and args2 ~= "" then user:SendPM(Releases._Bot, Grab.ModConfig(args, args2).."|" ) elseif Releases._Level[args] == nil then user:SendPM(Releases._Bot, args.." wasn't a command!|") else user:SendPM(Releases._Bot, "I need more input!|") end end end, ["addcat"] = function(user, data) if Releases._Level["addcat"][user.iProfile] then s,e,args,of = strfind(data, "%b<>%s*%S+%s*(%S*)%s*(%S*)$") if args == "" then user:SendPM(Releases._Bot, "I need more input!|") else user:SendPM(Releases._Bot, Grab.AddCat(args, of).."|") end else user:SendPM(Releases._Bot, "Your user level may not acces this command!|") end end, ["delcat"] = function(user, data) if Releases._Level["delcat"][user.iProfile] then s,e,args = strfind(data, "%b<>%s*%S+%s*(%S*)$") if args == "" then user:SendPM(Releases._Bot, "I need more input!|") else user:SendPM(Releases._Bot, Grab.DelCat(args).."|" ) end else user:SendPM(Releases._Bot, "Your user level may not acces this command!|") end end, ["addurl"] = function(user, data) if Releases._Level["addurl"][user.iProfile] then s,e,args,what = strfind(data, "%b<>%s*%S+%s*(%S*)%s*(.*)$") if args == "" or tonumber(args) == nil then user:SendPM(Releases._Bot, "I need more input!|") elseif tonumber(args) == nil then user:SendPM(Releases._Bot, "I need an ID number!|") else args = tonumber(args) user:SendPM(Releases._Bot, Grab.AddUrl(args,what ).."|" ) user:SendPM(Releases._Bot, Grab.ByID(args).."|") end else user:SendPM(Releases._Bot, "Your user level may not acces this command!|") end end, ["delurl"] = function(user, data) if Releases._Level["delurl"][user.iProfile] then s,e,args = strfind(data, "%b<>%s*%S+%s*(%S*)$") if args == "" or tonumber(args) == nil then user:SendPM(Releases._Bot, "I need more input!|") elseif tonumber(args) == nil then user:SendPM(Releases._Bot, "I need an ID number!|") else args = tonumber(args) user:SendPM(Releases._Bot, Grab.DelUrl(args).."|" ) user:SendPM(Releases._Bot, Grab.ByID(args).."|") end else user:SendPM(Releases._Bot, "Your user level may not acces this command!|") end end, ["addartist"] = function(user, data) if Releases._Level["addartist"][user.iProfile] then s,e,args,what = strfind(data, "%b<>%s*%S+%s*(%S*)%s*(.*)$") if args == "" or tonumber(args) == nil then user:SendPM(Releases._Bot, "I need more input!|") elseif tonumber(args) == nil then user:SendPM(Releases._Bot, "I need an ID number!|") else args = tonumber(args) user:SendPM(Releases._Bot, Grab.AddArtist(args,what ).."|" ) user:SendPM(Releases._Bot, Grab.ByID(args).."|") end else user:SendPM(Releases._Bot, "Your user level may not acces this command!|") end end, ["delartist"] = function(user, data) if Releases._Level["delartist"][user.iProfile] then s,e,args = strfind(data, "%b<>%s*%S+%s*(%S*)$") if args == "" or tonumber(args) == nil then user:SendPM(Releases._Bot, "I need more input!|") elseif tonumber(args) == nil then user:SendPM(Releases._Bot, "I need an ID number!|") else args = tonumber(args) user:SendPM(Releases._Bot, Grab.DelArtist(args).."|" ) user:SendPM(Releases._Bot, Grab.ByID(args).."|") end else user:SendPM(Releases._Bot, "Your user level may not acces this command!|") end end, ["addfilename"] = function(user, data) if Releases._Level["addfilename"][user.iProfile] then s,e,args,what = strfind(data, "%b<>%s*%S+%s*(%S*)%s*(.*)$") if args == "" or tonumber(args) == nil then user:SendPM(Releases._Bot, "I need more input!|") elseif tonumber(args) == nil then user:SendPM(Releases._Bot, "I need an ID number!|") else args = tonumber(args) user:SendPM(Releases._Bot, Grab.AddFileName(args,what ).."|" ) user:SendPM(Releases._Bot, Grab.ByID(args).."|") end else user:SendPM(Releases._Bot, "Your user level may not acces this command!|") end end, ["delfilename"] = function(user, data) if Releases._Level["delfilename"][user.iProfile] then s,e,args = strfind(data, "%b<>%s*%S+%s*(%S*)$") if args == "" or tonumber(args) == nil then user:SendPM(Releases._Bot, "I need more input!|") elseif tonumber(args) == nil then user:SendPM(Releases._Bot, "I need an ID number!|") else args = tonumber(args) user:SendPM(Releases._Bot, Grab.DelFileName(args).."|" ) user:SendPM(Releases._Bot, Grab.ByID(args).."|") end else user:SendPM(Releases._Bot, "Your user level may not acces this command!|") end end, ["comment"] = function(user, data) if Releases._Level["comment"][user.iProfile] then s,e,args,what = strfind(data, "%b<>%s*%S+%s*(%S*)%s*(.*)$") if args == "" or tonumber(args) == nil then user:SendPM(Releases._Bot, "I need more input!|") elseif tonumber(args) == nil then user:SendPM(Releases._Bot, "I need an ID number!|") else args = tonumber(args) what = user.sName.." wrote: "..what user:SendPM(Releases._Bot, Grab.AddComm(args,what ).."|" ) user:SendPM(Releases._Bot, Grab.ByID(args).."|") end else user:SendPM(Releases._Bot, "Your user level may not acces this command!|") end end, ["decomment"] = function(user, data) if Releases._Level["decomment"][user.iProfile] then s,e,args,what = strfind(data, "%b<>%s*%S+%s*(%S*)%s*(%S*)$") if args == "" or tonumber(args) == nil then user:SendPM(Releases._Bot, "I need more input!|") elseif tonumber(args) == nil then user:SendPM(Releases._Bot, "I need an ID number!|") elseif tonumber(what) == nil then user:SendPM(Releases._Bot, "I need an comment number!|") else args = tonumber(args) what = tonumber(what) user:SendPM(Releases._Bot, Grab.DelComm(args,what ).."|" ) end else user:SendPM(Releases._Bot, "Your user level may not acces this command!|") end end, ["del"] = function(user,data) if Releases._Level["del"][user.iProfile] then s,e,args = strfind(data, "%b<>%s*%S+%s*(%S*)$") if args == "" or tonumber(args) == nil then user:SendPM(Releases._Bot, "I need an ID number!|") else args = tonumber(args) user:SendPM(Releases._Bot, Grab.Del(args).."|" ) end else user:SendPM(Releases._Bot, "Your user level may not acces this command!|") end end, ["add"] = function(user, data) if Releases._Level["add"][user.iProfile] then s,e,args,what = strfind(data, "%b<>%s*%S+%s*(%S*)%s*(.*)$") if args == "" or what == "" then user:SendPM(Releases._Bot, "I need more input!|") else user:SendPM(Releases._Bot, Grab.Add(user, args, what).."|" ) end else user:SendPM(Releases._Bot, "Your user level may not acces this command!|") end end, ["search"] = function(user, data) if Releases._Level["search"][user.iProfile] then s,e,args = strfind(data, "%$*%b<>%s*%S+%s*(.*)$") if args == "" then user:SendPM(Releases._Bot, "I need more input.|") else user:SendPM(Releases._Bot, Grab.Search(args).."|" ) end else user:SendPM(Releases._Bot, "Your user level may not acces this command!|") end end, ["showcats"] = function(user, data) if Releases._Level["showcats"][user.iProfile] then user:SendPM(Releases._Bot, Grab.ShowCats().."|" ) else user:SendPM(Releases._Bot, "Your user level may not acces this command!|") end end, ["show"] = function(user, data) if Releases._Level["show"][user.iProfile] then s,e,args = strfind(data, "%b<>%s*%S+%s*(%S*)$") if args == "" or args == nil then if Grab.All == nil then Grab.All = Grab.BuildAll() end user:SendPM(Releases._Bot, (Grab.All or "Nothing on the list yet!").."|") elseif tonumber(args) then args = tonumber(args) user:SendPM(Releases._Bot, Grab.ByID(args).."|") else user:SendPM(Releases._Bot, Grab.ByType(args).."|") end else user:SendPM(Releases._Bot, "Your user level may not acces this command!|") end end, ["new"] = function(user, data) if Releases._Level["new"][user.iProfile] then if Grab.New == nil then Grab.New = Grab.BuildLatest() end user:SendPM(Releases._Bot, (Grab.New or "Nothing on the list yet!").."|") end end, ["stats"] = function(user, data) if Releases._Level["stats"][user.iProfile] then user:SendPM(Releases._Bot, Grab.BuildStats().."|") else user:SendPM(Releases._Bot, "Your user level may not acces this command!|") end end, ["help"] = function(user, data) if Releases._Level["help"][user.iProfile] then user:SendPM(Releases._Bot, Grab.BuildHelp(user.iProfile).."|") else user:SendPM(Releases._Bot, "Your user level may not acces this command!|") end end } ----------------------------- the usual stuff function DataArrival(user, data) if(strsub(data, 1, 4) == "$To:") then s,e,whoTo = strfind(data,"$To:%s+(%S+)") if whoTo == Releases._Bot then data=strsub(data,1,strlen(data)-1) local s,e,cmd = strfind(data,"$To:%s+%S+%s+From:%s+%S+%s+$%b<>%s+(%S+)") cmd = strsub(cmd, 2,strlen(cmd)) if Commands[cmd] then call(Commands[cmd], {user,data}) return 1 elseif Releases._Cat[cmd] then user:SendPM(Releases._Bot, Grab.ByType(cmd).."|") return 1 else user:SendPM(Releases._Bot, "Type again, but now use a correct command!") return 1 end end elseif (strsub(data,1,1) == "<") then data=strsub(data,1,strlen(data)-1) local s,e,cmd = strfind(data,"%b<>%s+(%S+)") local pre = strsub(cmd, 1,1) cmd = strsub(cmd, 2,strlen(cmd)) if Releases._Prefix[pre] then if Commands[cmd] then call(Commands[cmd], {user,data}) return 1 elseif Releases._Cat[cmd] then user:SendPM(Releases._Bot, Grab.ByType(cmd).."|") return 1 end end end end ------------------------------------ the usual stuff done on startup function Main() if readfrom("freshdata/freshdatabase.lua") then dofile("freshdata/freshdatabase.lua") readfrom() if Releases._MaxNew == nil then Grab.Upgrade44() Grab.Save() end else execute("mkdir freshdata") Grab.BuildTable() if Releases._MaxNew == nil then Grab.Upgrade44() Grab.Save() end end Grab.ResetCounter() if not Releases._Bot then Releases._Bot = Bot end frmHub:RegBot(Releases._Bot) end