READ THE RULES
0 Members and 1 Guest are viewing this topic.
----------------------------------------------------------------------------------------------------------- Mlink.Library.v2.0.LUA5.X-PtokaX [ by: St0ne db ]------------------------------------------------------------------------------------------------------------- A new kind of release and request bot.------[ Tested With ]------------------------------------------------------------------------------------------ PtokaX v0.3.5.1c & PtokaX v0.3.5.1d - [ Lua 5.0.3 and Lua 5.1.1 ]------[ Version 2.0 Change Log ]------------------------------------------------------------------ Added, Completely rewrote all code from v1.2, new faster wizard system-- Added, Quick commands are provided for faster entrys-- Added, Completely skinable interface---- -[ Version 1.2 ]----- Completely rewrote all code from v1.2, new faster wizard system-- Release and Request functions-- Internal 'Nuker' for bad releases-- Ability to hold optional info;-- i. Links to websites-- ii. Magnet links-- iii. Additional notes about the release / request-- iv. Users comments-- v. Release rank-- Auto cleaning-- Poster ranking system-- Tasks are done through the use of wizards-- Quick commands are provided for faster entrys-- Administrative only commands-- Full Right-Click command menu-- Duplicate checker-- Latest releases sent to PM or Main-- Completely skinable interface------[ Included Skins ]--------------------------------------------------------------------------------------- Default - The same skin built into the bot, use this as a guide to creating your own skins.-- Simple - Created by: St0ne_db-- White Widow - Created by: Stormbringer-- Citral - Created by: Stormbringer-- Durban Poison - Created by: Stormbringer (French)-- Text Only - Created by: St0ne_db---- - All skins are designed in Tahoma 8 point, The text only skin provides the highest font compatability.------[ Credit ]----------------------------------------------------------------------------------------------- The Serialize and SaveToFile functions from: 'Entry Bot v1.1e' ( by jiten )-- All other code by St0ne db.<the-westside crew> Best Viewed in LUAEdit v3 [ www.luaedit.net ]-- Thanks: Stormbringer [ Beta Tester and Skin Designer ]---- Support your LUA Community"-- LUA Language Board: http://luaboard.sytes.net-- UK LUA Language Board : http://lua.uknnet.com-- PtokaX Resources' Site: http://ptxscriptdb.psycho-chihuahua.net-- PtokaX Wiki: http://ptxwiki.psycho-chihuahua.net/doku.php------------------------------------------------------------------------------------------------------------- [ Updates, Bug Reports.. other LUA scripts for PtokaX.. http://the-westside.no-ip.info ] ------------------------------------------------------------------------------------------------------------- Global Library Settings, Set Library specific options.cls = string.rep("\n",20) -- size of clear screendate = "%m/%d/%y %H:%M:%S" -- date format [ mm/dd/yy hh:mm:ss ]-- Bot VariablestVar = { -- Bot Settings, Customize various options for the Library bots. ---------------------------------- sBot = "Library", -- Bot name [Wizards] sBotD = "Library Wizard", -- Bot Description sBotE = "lib@px.net", -- Bot Email Address sIsOP = 1, -- Bot is OP (1=yes,0=no) nBot = "Lib-NFO", -- Bot name [Notifications] nBotD = "Library NFO", -- Bot Description nBotE = "libn@px.net", -- Bot Email Address nIsOP = 1, -- Bot is OP (1=yes,0=no) ---------------------------------- sTrig = "!", -- Prefix for commands from main chat ---------------------------------- sLibFile = "Library.mll",-- Main Library file sLibData = "LibData.mll",-- Temporary Library data file sLibLast = "LibLast.mll",-- Latest releases data file sFolder = "MLinkLib", -- Script data folder ---------------------------------- sRC = "on", -- Send Right-Click menu [on,off] sRCMenu = "Library", -- Right-Click menu name ---------------------------------- sSkin = "default", -- Default skin folder name, all users start with this skin ---------------------------------- sNotify = "pm", -- Send info about newly added releases / requests [main,pm,off] sOnConnect = "pm", -- Send latest releases on connect [main,pm,off] sLastRel = 25, -- Maximum number of items in the history of new added releases ---------------------------------- sRating = "no", -- Show the Rating on connect, if provided [yes,no] sMag = "no", -- Show the Mlink on connect, if provided [yes,no] sUrl = "no", -- Show the URL on connect, if provided [yes,no]}; -- Poster Ranking, You can add more ranks and ranges at anytime.tRank = { [10] = "Newbie", -- 0-10 Post Points [100] = "Ace", -- 10-100 Post Points [1000] = "Hero", -- 100-1000 Post Points [10000] = "Legend", -- 1000-10000 Post Points [100000] = "God", -- 10000-99999~ Post Points};-- Commands, Choose the triggers you want for the wizards and quick commands.tCmd = { -- Wizards ---------------------------------- sAddRel = "new", -- Add a new release sAddCat = "newcat", -- Add a new category sDelRel = "del", -- Delete a release (users can only delete their own release) sDelCat = "delcat", -- Delete a category sReq = "newreq", -- Request a release sShowRel = "show", -- Browse through the release list -- Quick Commands ---------------------------------- qAddRel = "qnew", -- Add a new release qAddCat = "qnewcat", -- Add a new category qDelRel = "qdel", -- Delete a release (users can only delete their own release) qDelCat = "qdelcat", -- Delete a category qReq = "qnewreq", -- Request a release qShow = "qshow", -- Show release details qSkin = "chskin", -- Change your prefered skin qRank = "myrank", -- Show your rank and number of posts qComment = "mycom", -- Show your posts that have comments qMag = "mags", -- Show all the available magnet links qWeb = "urls", -- Show all the available web links qClean = "clean", -- Force the cleaner to run qAddSkin = "newskin", -- Add a skin to the database};-- Profile Access, Allow or deny access by profile number. -- -- Allow = 1 -- Deny = 0 -- -- Admin AccesspAdmin = { [-1] = 0, -- Un-Reg -- / \ [0] = 1, -- Master -- / PtokaX \ [1] = 1, -- OP -- / Built-in \ [2] = 0, -- ViP -- \ Profiles / [3] = 0, -- Reg -- \ / --[4] = 1, -- Moderator -- ** Robocop/Leviathan users must uncomment ** --[5] = 1, -- Netfounder -- ** Robocop/Leviathan users must uncomment ** --[6] = 1, -- Owner -- ** Leviathan users must uncomment **}; -- User Access.pUser = { [-1] = 0, -- Un-Reg -- / \ [0] = 1, -- Master -- / PtokaX \ [1] = 1, -- OP -- / Built-in \ [2] = 1, -- ViP -- \ Profiles / [3] = 1, -- Reg -- \ / --[4] = 1, -- Moderator -- ** Robocop/Leviathan users must uncomment ** --[5] = 1, -- Netfounder -- ** Robocop/Leviathan users must uncomment ** --[6] = 1, -- Owner -- ** Leviathan users must uncomment **};-- Command access, Assign access types for the commands and wizards.wAccess = { -- Admin Access = pAdmin, -- User Access = pUser -- -- Wizards ---------------------------------- ["AddRel"] = pUser, -- Add a new release ["AddCat"] = pAdmin, -- Add a new category ["DelRel"] = pUser, -- Delete a release (users can only delete their own release) ["DelCat"] = pAdmin, -- Delete a category ["AddReq"] = pUser, -- Request a release ["ShowRel"] = pUser, -- Browse through the release List};tAccess = { -- Quick Commands ---------------------------------- [tCmd.qAddRel] = pUser, -- Add a new release [tCmd.qAddCat] = pAdmin, -- Add a new category [tCmd.qDelRel] = pUser, -- Delete a release (users can only delete their own release) [tCmd.qDelCat] = pAdmin, -- Delete a category [tCmd.qReq] = pUser, -- Request a release [tCmd.qShow] = pUser, -- Show release details [tCmd.qSkin] = pUser, -- Change your prefered skin [tCmd.qRank] = pUser, -- Show your rank and number of posts [tCmd.qComment] = pUser, -- Show your posts that have comments [tCmd.qMag] = pUser, -- Show all the available magnet links [tCmd.qWeb] = pUser, -- Show all the available web links [tCmd.qClean] = pAdmin, -- Force the cleaner to run [tCmd.qAddSkin] = pAdmin, -- Add a skin to the database };---------------------------------------------------------------------------------------------------------if (_VERSION == "Lua 5.1") then package.path = "./"..tVar.sFolder.."/?.lua;"..package.path require "Wizard"; TableMaxSize = table.maxn; StringMatch = string.gmatch; CollectTrash = function() collectgarbage("collect"); end elseif (_VERSION == "Lua 5.0.3") or (_VERSION == "Lua 5.0.2") then require(tVar.sFolder.."/Wizard.lua"); TableMaxSize = table.getn; StringMatch = string.gfind; CollectTrash = function() collectgarbage(); end else SendToAll(tVar.sBot,"*** This bot requires Lua 5.1 or Lua 5.0.X.... your version is ".._VERSION);endLibTask = { ["Start"] = function() WizTemp = {}; if loadfile(tVar.sFolder.."/"..tVar.sLibData) then dofile(tVar.sFolder.."/"..tVar.sLibData); else LibData = {}; end local users = frmHub:GetOnlineUsers(); for i = 1, TableMaxSize(users) do local user = users[i]; if not LibData[user.sName] and pUser[user.iProfile] == 1 then LibData[user.sName] = { ["rank"] = 0, ["posts"] = 0, ["skin"] = tVar.sSkin, }; end end doSaveTable(tVar.sFolder.."/"..tVar.sLibData,LibData,"LibData"); if loadfile(tVar.sFolder.."/"..tVar.sLibFile) then dofile(tVar.sFolder.."/"..tVar.sLibFile); if Library[1]["cdesc"] ~= "Nuked or Not Working Releases" then LibTask.ConvertLib() end else Library = { [1] = { ["cname"] = "Nuked", ["cdesc"] = "Nuked or Not Working Releases", ["cexpire"] = 30, ["items"] = {}, }, [2] = { ["cname"] = "Requests", ["cdesc"] = "User Requests", ["cexpire"] = 30, ["items"] = {}, }, }; end if loadfile(tVar.sFolder.."/"..tVar.sLibLast) then dofile(tVar.sFolder.."/"..tVar.sLibLast); if TableMaxSize(LibLast) > 0 and LibLast[1]["name"] then LibTask.ConvertLst() end else LibLast = {}; end if loadfile(tVar.sFolder.."/skin/skins.txt") then dofile(tVar.sFolder.."/skin/skins.txt"); else Skins = {}; end end, ["CatDupeCheck"] = function(newCat) local n = TableMaxSize(Library); if n > 0 then for i = 1, n do if string.gsub(string.lower(Library[i]["cname"]),"%s", "") == string.gsub(string.lower(newCat),"%s", "") then return i; end end end return nil; end, ["RelDupeCheck"] = function(newRel) local n = TableMaxSize(Library); if n > 0 then for i = 1, n do local ni = TableMaxSize(Library[i]["items"]); if ni > 0 then for z = 1, ni do if string.gsub(string.lower(Library[i]["items"][z]["name"]),"%s", "") == string.gsub(string.lower(newRel),"%s","") then local t = { [1] = i, [2] = z }; return t; end end end end end return nil; end, ["NewCat"] = function(user,temp) table.insert(Library, { ["items"] = {}, ["cname"] = temp.cat.name, ["cdesc"] = temp.cat.desc, ["cexpire"] = tonumber(temp.cat.exp), }); doSaveTable(tVar.sFolder.."/"..tVar.sLibFile,Library,"Library"); end, ["DelCat"] = function(user,temp) table.remove(Library,tonumber(temp.cat.var)); for z = TableMaxSize(LibLast), 1,-1 do if tonumber(LibLast[z]["cat"]) == tonumber(temp.cat.var) then table.remove(LibLast,z); elseif tonumber(LibLast[z]["cat"]) > tonumber(temp.cat.var) then LibLast[z]["cat"] = LibLast[z]["cat"] - 1; end end doSaveTable(tVar.sFolder.."/"..tVar.sLibLast,LibLast,"LibLast"); doSaveTable(tVar.sFolder.."/"..tVar.sLibFile,Library,"Library"); end, ["DelRel"] = function(user,temp) local i = tonumber(temp.rel.cat); local n = tonumber(temp.rel.var); for z = TableMaxSize(LibLast),1,-1 do if tonumber(LibLast[z]["cat"]) == i then if tonumber(LibLast[z]["rel"]) == n then table.remove(LibLast,z); elseif tonumber(LibLast[z]["rel"]) > n then LibLast[z]["rel"] = LibLast[z]["rel"] - 1; end end end table.remove(Library[i]["items"],n); doSaveTable(tVar.sFolder.."/"..tVar.sLibLast,LibLast,"LibLast"); doSaveTable(tVar.sFolder.."/"..tVar.sLibFile,Library,"Library"); end, ["AddRel"] = function(user,temp) local i = tonumber(temp.rel.cat); table.insert(Library[i]["items"], { ["notes"] = temp.rel.desc, ["name"] = temp.rel.name, ["expire"] = tonumber(Library[i]["cexpire"]), ["date"] = os.date(date), ["url"] = temp.rel.url, ["mlink"] = temp.rel.mlink, ["poster"] = user.sName, ["votes"] = 0, ["voted"] = {}; ["comments"] = {}, }); table.insert(LibLast,1, { ["cat"] = i, ["rel"] = TableMaxSize(Library[i]["items"]), }); if TableMaxSize(LibLast) > tVar.sLastRel then for i = TableMaxSize(LibLast),tVar.sLastRel,-1 do table.remove(LibLast,i); end end local p = 1; if temp.rel.mlink ~= "Not Included" then p=p+1; end if temp.rel.url ~= "Not Included" then p=p+1; end if temp.rel.desc ~= "Not Included" then p=p+1; end if not LibData[user.sName] then LibData[user.sName] = { ["rank"] = 0, ["posts"] = 0, }; end LibData[user.sName]["rank"] = LibData[user.sName]["rank"] + p; LibData[user.sName]["posts"] = LibData[user.sName]["posts"] + 1; temp.rel.var = TableMaxSize(Library[i]["items"]); if tVar.sNofify ~= "off" then local hub = frmHub:GetOnlineUsers(); for i = 1, TableMaxSize(hub) do local user = hub[i]; if pUser[user.iProfile] == 1 then temp.skip = LibData[user.sName]["skin"]; if tVar.sNotify == "pm" then user:SendPM(tVar.nBot,Wizard.Tags(Wizard.Show.OnCreation(temp.skin),temp)); elseif tVar.sNotify == "main" then user:SendData(tVar.nBot,Wizard.Tags(Wizard.Show.OnCreation(temp.skin),temp)); end end end end doSaveTable(tVar.sFolder.."/"..tVar.sLibFile,Library,"Library"); doSaveTable(tVar.sFolder.."/"..tVar.sLibLast,LibLast,"LibLast"); doSaveTable(tVar.sFolder.."/"..tVar.sLibData,LibData,"LibData"); end, ["Nuke"] = function(user,temp) local i = tonumber(temp.rel.cat); local n = tonumber(temp.rel.var); Library[i]["items"][n]["expire"] = Library[1]["cexpire"]; local t = Library[i]["items"][n]; table.insert(Library[1]["items"],t); table.insert(LibLast,1, { ["cat"] = 1, ["rel"] = TableMaxSize(Library[1]["items"]), }); table.remove(Library[i]["items"],n); for z = TableMaxSize(LibLast),1,-1 do if tonumber(LibLast[z]["cat"]) == i then if tonumber(LibLast[z]["rel"]) == n then table.remove(LibLast,z); elseif tonumber(LibLast[z]["rel"]) > n then LibLast[z]["rel"] = LibLast[z]["rel"] - 1; end end end if TableMaxSize(LibLast) > tVar.sLastRel then for i = TableMaxSize(LibLast),tVar.sLastRel,-1 do table.remove(LibLast,i); end end if tVar.sNofify ~= "off" then local hub = frmHub:GetOnlineUsers(); for i = 1, TableMaxSize(hub) do local user = hub[i]; temp.skin = LibData[user.sName]["skin"]; if tVar.sNotify == "pm" then user:SendPM(tVar.nBot,Wizard.Tags(Wizard.Show.OnCreation(temp.skin),temp)); elseif tVar.sNotify == "main" then user:SendData(tVar.nBot,Wizard.Tags(Wizard.Show.OnCreation(temp.skin),temp)); end end end doSaveTable(tVar.sFolder.."/"..tVar.sLibFile,Library,"Library"); doSaveTable(tVar.sFolder.."/"..tVar.sLibLast,LibLast,"LibLast"); end, ["Vote"] = function(user,temp) local i = tonumber(temp.rel.cat); local n = tonumber(temp.rel.var); local v = tonumber(Library[i]["items"][n]["votes"]) + 1; local c = temp.vote.comment; local r = temp.vote.rating; if c ~= "Not Included" then Library[i]["items"][n]["comments"][user.sName] = c; end if r ~= "Not Rated" then Library[i]["items"][n]["voted"][user.sName] = r; Library[i]["items"][n]["votes"] = v; end doSaveTable(tVar.sFolder.."/"..tVar.sLibFile,Library,"Library"); end, ["ConvertLst"] = function() doSaveTable(tVar.sFolder.."/"..tVar.sLibLast..".bak",LibLast,"LibLast"); local t = {}; for i = 1, TableMaxSize(LibLast) do local cat = LibLast[i]["cat"]; local name = LibLast[i]["name"]; local n = TableMaxSize(Library); if n > 0 then for i = 1, n do if cat == Library[i]["cname"] then local ni = TableMaxSize(Library[i]["items"]); if ni > 0 then for z = 1, ni do if string.gsub(string.lower(Library[i]["items"][z]["name"]),"%s", "") == string.gsub(string.lower(name),"%s","") then table.insert(t,{ ["cat"] = i, ["rel"] = z }); break; end end break; end end end end end LibLast = t; doSaveTable(tVar.sFolder.."/"..tVar.sLibLast,LibLast,"LibLast"); SendToOps(tVar.sBot,"*** Latest Releases database conversion completed, old database has been saved to: "..tVar.sLibFile..".bak"); end, ["ConvertLib"] = function() doSaveTable(tVar.sFolder.."/"..tVar.sLibFile..".bak",Library,"Library"); local t = { [1] = { ["cname"] = "Nuked", ["cdesc"] = "Nuked or Not Working Releases", ["cexpire"] = 30, ["items"] = {}, }, [2] = { ["cname"] = "Requests", ["cdesc"] = "User Requests", ["cexpire"] = 30, ["items"] = {}, }, }; local fi = 1; if Library[1]["cname"] == "Nuked" then fi = 2; end if Library[2]["cname"] == "Requests" then fi = 3; end local n = TableMaxSize(Library); if n > 0 then for i = fi, n do t[i] = Library[i] local ni = TableMaxSize(Library[i]["items"]); if ni > 0 then for z = 1, ni do t[i]["items"][z]["votes"] = 0; t[i]["items"][z]["voted"] = {}; t[i]["items"][z]["comments"] = {}; end end end end Library = t; doSaveTable(tVar.sFolder.."/"..tVar.sLibFile,Library,"Library"); SendToOps(tVar.sBot,"*** Library database conversion completed, old database has been saved to: "..tVar.sLibFile..".bak"); end, ["Clean"] = function() local ret = 0; local ci = TableMaxSize(Library); if ci then for i = ci,1,-1 do local ri = TableMaxSize(Library[i]["items"]) do if ri then for n = ri, 1,-1 do if tonumber(Library[i]["items"][n]["expire"]) > -1 then local ti = (tonumber(Library[i]["items"][n]["expire"])-1); Library[i]["items"][n]["expire"] = ti; if ti <= 0 then ret = ret + 1; table.remove(Library[i]["items"],n); for z = TableMaxSize(LibLast),1,-1 do if tonumber(LibLast[z]["cat"]) == i then if tonumber(LibLast[z]["rel"]) == n then table.remove(LibLast,z); elseif tonumber(LibLast[z]["rel"]) > n then LibLast[z]["rel"] = LibLast[z]["rel"] - 1; end end end end end end end end end end doSaveTable(tVar.sFolder.."/"..tVar.sLibFile,Library,"Library"); doSaveTable(tVar.sFolder.."/"..tVar.sLibLast,LibLast,"LibLast"); return ret; end,};tQCmd = { [tCmd.qAddRel] = function(user,data) if Wizard.QAC(user,tCmd.qAddRel) then local _,_,cat,rel = string.find(data,"%b<>%s+%S+%s+(%d+)%s+(.*)"); if cat and tonumber(cat) and rel then cat = tonumber(string.format("%.0f",cat)); if cat > 2 and cat <= TableMaxSize(Library) then local dupe = LibTask.RelDupeCheck(rel); if not dupe then local temp = {rel={cat=cat, name=rel, mlink="Not Included", url="Not Included", desc="Not Included"},skin=LibData[user.sName]["skin"]}; LibTask.AddRel(user,temp); user:SendData(tVar.sBot,"*** "..rel.." has been added to "..Library[cat]["cname"].."."); else user:SendData(tVar.sBot,"*** Error: Duplicate release found.. Category: "..Library[dupe[1]]["cname"]..", "..Library[dupe[1]]["items"][dupe[2]]); end else user:SendData(tVar.sBot,"*** Error: You cannot add a release to this category, please choose another category.\n"..Wizard.Show.CatList()); end else user:SendData(tVar.sBot,"*** Quicky add a new release: "..tVar.sTrig..tCmd.qAddRel.." <cat #> <release name>\n\n"..Wizard.Show.CatList()); end end end, [tCmd.qAddCat] = function(user,data) if Wizard.QAC(user,tCmd.qAddCat) then local _,_,exp,cat,desc = string.find(data,"%b<>%s+%S+%s+(%d+)%s+\"(.+)\"%s+(.*)"); if exp and tonumber(exp) and cat and desc then exp = tonumber(string.format("%.0f",exp)); local dupe = LibTask.CatDupeCheck(cat); if not dupe then local temp = {cat={name=cat, desc=desc, exp=exp},skin=LibData[user.sName]["skin"]}; LibTask.NewCat(user,temp); user:SendData(tVar.sBot,"*** \""..cat.."\" has been added as a category."); else user:SendData(tVar.sBot,"*** Error: Duplicate category found.. Category: "..Library[dupe]["cname"]); end else user:SendData(tVar.sBot,"*** Quicky add a new category: "..tVar.sTrig..tCmd.qAddCat.." <expire time> <\"cat name\"> <cat description>\n\n\tDuplicates are not allowed!\n\n"..Wizard.Show.CatList()); end end end, [tCmd.qDelRel] = function(user,data) if Wizard.QAC(user,tCmd.qDelRel) then local _,_,cat,rel = string.find(data,"%b<>%s+%S+%s+(%d+)%.(%d+)"); if cat and rel then if tonumber(cat) and tonumber(rel) and tonumber(cat) > 0 and tonumber(cat) <= TableMaxSize(Library) and tonumber(rel) > 0 and tonumber(rel) <= TableMaxSize(Library[tonumber(cat)]["items"]) then if pAdmin[user.iProfile] == 1 or Library[tonumber(cat)]["items"][tonumber(rel)]["poster"] == user.sName then local temp = {rel={cat=cat, var=rel},skin=LibData[user.sName]["skin"]}; LibTask.DelRel(user,temp); user:SendData(tVar.sBot,"*** Release "..cat.."."..rel.." has been deleted."); else user:SendData(tVar.sBot,"*** Error: You cannot delete this release!"); end else user:SendData(tVar.sBot,"*** Error: Invalid release id. Expecting... example: 3.2"); end else user:SendData(tVar.sBot,"*** Quicky delete a release by id: "..tVar.sTrig..tCmd.qDelRel.." <release id> "); end end end, [tCmd.qDelCat] = function(user,data) if Wizard.QAC(user,tCmd.qDelCat) then local _,_,cat = string.find(data,"%b<>%s+%S+%s+(%d+)"); if cat then if tonumber(cat) and tonumber(cat) > 2 and tonumber(cat) <= TableMaxSize(Library) then local temp = {cat={var=cat},skin=LibData[user.sName]["skin"]}; user:SendData(tVar.sBot,"*** Category "..Library[tonumber(cat)]["cname"].." has been deleted."); LibTask.DelCat(user,temp); else user:SendData(tVar.sBot,"*** Error: Invalid category number, Expecting: 2-"..TableMaxSize(Library)); end else user:SendData(tVar.sBot,"*** Quicky delete a category: "..tVar.sTrig..tCmd.qDelCat.." <category number>\n\n"..Wizard.Show.CatList()); end end end, [tCmd.qReq] = function(user,data) if Wizard.QAC(user,tCmd.qAddRel) then local _,_,req = string.find(data,"%b<>%s+%S+%s+(.*)"); if req then local dupe = LibTask.RelDupeCheck(req); if not dupe then local temp = {rel={cat="2", name=req, mlink="Not Included", url="Not Included", desc="Not Included"},skin=LibData[user.sName]["skin"]}; LibTask.AddRel(user,temp); user:SendData(tVar.sBot,"*** "..req.." has been added to "..Library[2]["cname"].."."); else user:SendData(tVar.sBot,"*** Error: Duplicate release found.. Category: "..Library[dupe[1]]["cname"]..", "..Library[dupe[1]]["items"][dupe[2]]); end else user:SendData(tVar.sBot,"*** Quicky add a new request: "..tVar.sTrig..tCmd.qReq.." <request name>"); end end end, [tCmd.qSkin] = function(user,data) if Wizard.QAC(user,tCmd.qSkin) then local n = TableMaxSize(Skins); if n then local _,_,num = string.find(data,"%b<>%s+%S+%s+(%S+)"); if num and tonumber(num) > 0 and tonumber(num) <= TableMaxSize(Skins) then user:SendData(tVar.sBot,"*** You are now using the "..Skins[tonumber(num)]["name"].." skin."); LibData[user.sName]["skin"] = Skins[tonumber(num)]["folder"]; doSaveTable(tVar.sFolder.."/"..tVar.sLibData,LibData,"LibData"); else local s = ""; local cur = LibData[user.sName]["skin"]; for i = 1, n do if cur == Skins[i]["folder"] then cur = Skins[i]["name"]; end s = s.."\t\t"..i..".\tName: "..Skins[i]["name"].."\n\t\t\tCreator: "..Skins[i]["creator"].."\n\n" end user:SendData(tVar.sBot,"*** Change your prefered skin: "..tVar.sTrig..tCmd.qSkin.." <skin number>\n\n\t\tYou are currently using the "..cur.." skin\n\n"..s); end else user:SendData(tVar.sBot,"*** No skins to choose from."); end end end, [tCmd.qShow] = function(user,data) if Wizard.QAC(user,tCmd.qShow) then local _,_,cat,rel = string.find(data,"%b<>%s+%S+%s+(%d+)%.(%d+)"); if cat and rel then if tonumber(cat) and tonumber(rel) and tonumber(cat) > 0 and tonumber(cat) <= TableMaxSize(Library) and tonumber(rel) > 0 and tonumber(rel) <= TableMaxSize(Library[tonumber(cat)]["items"]) then local temp = {rel={cat=cat, var=rel},skin=LibData[user.sName]["skin"]}; user:SendPM(tVar.sBot,"*** Showing Release "..cat.."."..rel.."... \n\n\n"..Wizard.Tags(Wizard.ShowRel[4](temp.skin),temp)); else user:SendData(tVar.sBot,"*** Error: Invalid release id. Expecting... example: 3.2"); end else user:SendData(tVar.sBot,"*** Quicky show a release by id: "..tVar.sTrig..tCmd.qShow.." <release id> "); end end end, [tCmd.qRank] = function(user,data) if Wizard.QAC(user,tCmd.qRank) then local d = Wizard.Show.Divider(LibData[user.sName]["skin"]) local s = "*** Showing profile details for "..user.sName..string.gsub(d,"{release}","") for i = 1, TableMaxSize(Library) do for n = 1, TableMaxSize(Library[i]["items"]) do t = Library[i]["items"][n]; if t["poster"] == user.sName then s = s.."\n\t"..i.."."..n.." - "..t["name"] end end end s = s..string.gsub(d,"{release}","") .."\n\tRank: "..Wizard.Show.Rank(user.sName)..", "..LibData[user.sName]["rank"].." Points" .."\n\tTotal Number of Posts: "..LibData[user.sName]["posts"].."\n" user:SendPM(tVar.sBot,s); end end, [tCmd.qComment] = function(user,data) if Wizard.QAC(user,tCmd.qComment) then local s,d = "",Wizard.Show.Divider(LibData[user.sName]["skin"]) local msg = "*** Showing all commented releases for "..user.sName..string.gsub(d,"{release}",""); for i = 1, TableMaxSize(Library) do for n = 1, TableMaxSize(Library[i]["items"]) do t = Library[i]["items"][n]; if t["poster"] == user.sName then local c = 0; s = ""; for k,v in pairs(t["comments"]) do if string.find(v,"^(.-)\n") then local p = ""; for line in StringMatch(v,".-\n") do p = p.."\t\t - "..line end s = s.."\t[ "..k.." ("..Wizard.Show.Rank(k)..") ] -\n"..p.."\n" else s = s.."\t[ "..k.." ("..Wizard.Show.Rank(k)..") ] - \""..v.."\"\n" end c=c+1; end if c > 0 then local r = "\n\tRelease Id: "..i.."."..n.."\n\t"..Library[i]["cname"].." - "..t.name.."\n\n"..s msg = msg..string.gsub(d,"{release}",r); end end end end user:SendPM(tVar.sBot,msg); end end, [tCmd.qMag] = function(user,data) if Wizard.QAC(user,tCmd.qMag) then local s,d = "",Wizard.Show.Divider(LibData[user.sName]["skin"]) local msg = "*** Showing all magnet links "..string.gsub(d,"{release}",""); for i = 1, TableMaxSize(Library) do for n = 1, TableMaxSize(Library[i]["items"]) do t = Library[i]["items"][n]; if t["mlink"] ~= "Not Included" then s = "\t"..Library[i]["cname"].." - "..t.name.."\n\tRelease Id: "..i.."."..n..Wizard.Show.Lines(t["mlink"],"Magnet Link") msg = msg..string.gsub(d,"{release}",s); end end end user:SendPM(tVar.sBot,msg); end end, [tCmd.qWeb] = function(user,data) if Wizard.QAC(user,tCmd.qMag) then local s,d = "",Wizard.Show.Divider(LibData[user.sName]["skin"]) local msg = "*** Showing all web links "..string.gsub(d,"{release}",""); for i = 1, TableMaxSize(Library) do for n = 1, TableMaxSize(Library[i]["items"]) do t = Library[i]["items"][n]; if t["url"] ~= "Not Included" then s = "\t"..Library[i]["cname"].." - "..t.name.."\n\tRelease Id: "..i.."."..n..Wizard.Show.Lines(t["url"],"Web Link") msg = msg..string.gsub(d,"{release}",s); end end end user:SendPM(tVar.sBot,msg); end end, [tCmd.qClean] = function(user,data) if Wizard.QAC(user,tCmd.qClean) then user:SendData(tVar.sBot,"*** Starting the cleaner"); local i = LibTask.Clean(); user:SendData(tVar.sBot,"*** Cleaner finished. "..i.." releases cleaned."); end end, [tCmd.qAddSkin] = function(user,data) if Wizard.QAC(user,tCmd.qAddSkin) then local _,_,folder,creator,name = string.find(data,"%b<>%s+%S+%s+(%S+)%s+(%S+)%s+(.*)"); if folder and creator and name then user:SendData(tVar.sBot,"*** Added new skin: \n\n\tFolder: PtokaX/scripts/"..tVar.sFolder.."/skin/"..folder.."/\n\tCreator: "..creator.."\n\tSkin Name:"..name); table.insert(Skins,{ ["name"] = name, ["folder"] = folder, ["creator"] = creator }); doSaveTable(tVar.sFolder.."/skin/skins.txt",Skins,"Skins"); else user:SendData(tVar.sBot,"*** Add a new skin: "..tVar.sTrig..tCmd.qAddSkin.." <skin folder> <creator> <descripton>"); end end end, };function Main() frmHub:RegBot(tVar.sBot,tVar.sIsOP,tVar.sBotD,tVar.sBotE); if tVar.sNotify ~= "off" or tVar.sOnConnect ~= "off" then frmHub:RegBot(tVar.nBot,tVar.nIsOP,tVar.nBotD,tVar.nBotE); end LibTask.Start(); SetTimer(86400000); StartTimer();endfunction ChatArrival(user,data) local data = string.sub(data,1,-2) local _,_,sTrig,sCmd = string.find(data,"%b<>%s*(%S)(%S+)") if sTrig and sCmd and sTrig == tVar.sTrig then if not Wizard.Start(user,data,sCmd) then if tQCmd[sCmd] then tQCmd[sCmd](user,data); return 1; end else return 1; end endendfunction ToArrival(user,data) if string.sub(data,6,5+(string.len(tVar.sBot))) == tVar.sBot then data = string.sub(data,(18+string.len(tVar.sBot)+2*string.len(user.sName)),(string.len(data)-1)); local _,_,sTrig,sCmd = string.find(data,"(%S)(%S+)"); if sTrig and sCmd and sTrig == tVar.sTrig then if not Wizard.Start(user,data,sCmd) then if tQCmd[sCmd] then tQCmd[sCmd](user,"<"..user.sName.."> "..data); return 1; end end elseif WizTemp[user.sName] then local wiz = WizTemp[user.sName]["wizard"]; Wizard[wiz]["Start"](user,data,WizTemp[user.sName]); return 1; end endendfunction OnTimer() LibTask.Clean(); endSerialize = function(tTable,sTableName,hFile,sTab) sTab = sTab or ""; hFile:write(sTab..sTableName.." = {\n"); for key,value in pairs(tTable) do if (type(value) ~= "function") then local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key); if(type(value) == "table") then Serialize(value,sKey,hFile,sTab.."\t"); else local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value); hFile:write(sTab.."\t"..sKey.." = "..sValue); end hFile:write(",\n"); end end hFile:write(sTab.."}");enddoSaveTable = function(file,table,tablename) local hFile = io.open(file,"w+") Serialize(table,tablename,hFile); hFile:close()endfunction doLoadFile(xFile) local xStr = ""; local hxFile,sErr = io.open(tVar.sFolder.."/"..xFile,"r"); if hxFile then xStr = hxFile:read("*a"); hxFile:close(xFile); io.flush(); xStr = string.gsub(xStr,"{cls}",cls); return xStr; else return nil; endendfunction NewUserConnected(user) if pUser[user.iProfile] == 1 then if string.lower(tVar.sRC) == "on" then if user.bUserCommand then if pAdmin[user.iProfile] == 1 then user:SendData("$UserCommand 1 3 "..tVar.sRCMenu.."\\Wizards\\Category\\New Category$<%[mynick]> "..tVar.sTrig..tCmd.sAddCat.."|"); user:SendData("$UserCommand 1 3 "..tVar.sRCMenu.."\\Wizards\\Category\\Delete Category$<%[mynick]> "..tVar.sTrig..tCmd.sDelCat.."|"); end user:SendData("$UserCommand 1 3 "..tVar.sRCMenu.."\\Wizards\\Release\\New Release$<%[mynick]> "..tVar.sTrig..tCmd.sAddRel.."|"); user:SendData("$UserCommand 1 3 "..tVar.sRCMenu.."\\Wizards\\Release\\New Request$<%[mynick]> "..tVar.sTrig..tCmd.sReq.."|"); user:SendData("$UserCommand 1 3 "..tVar.sRCMenu.."\\Wizards\\Release\\Delete Release$<%[mynick]> "..tVar.sTrig..tCmd.sDelRel.."|"); user:SendData("$UserCommand 1 3 "..tVar.sRCMenu.."\\Wizards\\Browse The Library$<%[mynick]> "..tVar.sTrig..tCmd.sShowRel.."|"); if pAdmin[user.iProfile] == 1 then user:SendData("$UserCommand 1 3 "..tVar.sRCMenu.."\\Quick\\Category\\New Category$<%[mynick]> "..tVar.sTrig..tCmd.qAddCat.." %[line: Expiration Time? 0 = Never or 1-99] \"%[line:Category Name?]\" %[line:Category Description?]|"); user:SendData("$UserCommand 1 3 "..tVar.sRCMenu.."\\Quick\\Category\\Delete Category$<%[mynick]> "..tVar.sTrig..tCmd.qDelCat.." %[line:Category Number? Leave blank for a list.]|"); end user:SendData("$UserCommand 1 3 "..tVar.sRCMenu.."\\Quick\\Release\\New Release$<%[mynick]> "..tVar.sTrig..tCmd.qAddRel.." %[line:Category Number? Leave blank for a list.] %[line:Release Name?]|"); user:SendData("$UserCommand 1 3 "..tVar.sRCMenu.."\\Quick\\Release\\New Request$<%[mynick]> "..tVar.sTrig..tCmd.qReq.." %[line:Request Name?]|"); user:SendData("$UserCommand 1 3 "..tVar.sRCMenu.."\\Quick\\Release\\Delete Release$<%[mynick]> "..tVar.sTrig..tCmd.qDelRel.." %[line:Release Id?]|"); user:SendData("$UserCommand 1 3 "..tVar.sRCMenu.."\\Quick\\Show Release Details$<%[mynick]> "..tVar.sTrig..tCmd.qShow.." %[line:Release Id?]|"); user:SendData("$UserCommand 1 3 "..tVar.sRCMenu.."\\Quick\\Show All Magnet Links$<%[mynick]> "..tVar.sTrig..tCmd.qMag.."|"); user:SendData("$UserCommand 1 3 "..tVar.sRCMenu.."\\Quick\\Show All Web Links$<%[mynick]> "..tVar.sTrig..tCmd.qWeb.."|"); user:SendData("$UserCommand 1 3 "..tVar.sRCMenu.."\\My Rank and Posts$<%[mynick]> "..tVar.sTrig..tCmd.qRank.."|"); user:SendData("$UserCommand 1 3 "..tVar.sRCMenu.."\\My Commented Posts$<%[mynick]> "..tVar.sTrig..tCmd.qComment.."|"); if pAdmin[user.iProfile] == 1 then user:SendData("$UserCommand 1 3 "..tVar.sRCMenu.."\\Run The Cleaner$<%[mynick]> "..tVar.sTrig..tCmd.qClean.."|"); user:SendData("$UserCommand 1 3 "..tVar.sRCMenu.."\\Add New Skin$<%[mynick]> "..tVar.sTrig..tCmd.qAddSkin.."|"); end user:SendData("$UserCommand 1 3 "..tVar.sRCMenu.."\\Change The Skin$<%[mynick]> "..tVar.sTrig..tCmd.qSkin.." %[line:Skin Number? Leave blank for a list.]|"); end end if not LibData[user.sName] then LibData[user.sName] = { ["rank"] = 0, ["posts"] = 0, ["skin"] = tVar.sSkin, }; doSaveTable(tVar.sFolder.."/"..tVar.sLibData,LibData,"LibData"); end local temp = { ["skin"] = LibData[user.sName]["skin"] }; if TableMaxSize(LibLast) > 0 then if tVar.sOnConnect == "pm" then user:SendPM(tVar.nBot,Wizard.Tags(Wizard.Show.OnEntry(temp.skin),temp)); elseif tVar.sOnConnect == "main" then user:SendData(tVar.nBot,Wizard.Tags(Wizard.Show.OnEntry(temp.skin),temp)); end end endendOpConnected=NewUserConnected