READ THE RULES
0 Members and 1 Guest are viewing this topic.
----[ 2 Board Messages ]------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- [1] [ 07/17/09 22:37:18 ] <DeAn> Test 1 [2] [ 07/17/09 22:37:02 ] <DeAn> Gen-X Hub-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------[ 2 Board Messages ]----
----[ 2 Board Messages ]------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- [1] [ On 07/17/09 At 22:37:18 ] <DeAn> Test 1 [2] [ On 07/17/09 At 22:37:02 ] <DeAn> Gen-X Hub-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------[ 2 Board Messages ]----
[16:03:57] <PtokaX> I'm sorry that is too close a match to an existing entry. Last match found: [# 2] - [ 07/17/09 22:37:18 ] <DeAn> Gen-X Hub
----[ 2 Board Messages ]------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- [1] [ On 07/17/09 At 22:37:02 ] <DeAn> Gen-X Hub [2] [ On 07/17/09 At 22:37:18 ] <DeAn> Test 1-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------[ 2 Board Messages ]----
-- Acceptable percentage of same words allowed in new posting [set as 101 to disable] MatchLimit = 35, -- Descending read order? true/false [false = ascending] Descend = true,
I code for the aesthetic I want. The line stays.
----[ 2 Board Messages ]------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- [1] [ On 07/17/09 At 22:37:18 ] <DeAn> Test 1 [2] [ On 07/17/09 At 22:37:02 ] <DeAn> Gen-X Hub-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
UserConnected = function(user) if SendMbCmds(user) then local Prof = ProfMan.GetProfile(user.iProfile).sProfileName local msg = "Welcome "..user.sNick..", "..Prof.."'s "..MbCfg.Script.." commands ".. "enabled. Right click hub tab or user list for menu." Core.SendToUser(user,"<"..MbCfg.BotNick.."> "..msg.."|") endendOpConnected,RegConnected = UserConnected,UserConnected
<[MessageBoard]> Welcome Mutor, Master's MessageBoard 2.2 commands enabled. Right click hub tab or user list for menu.
MbCmds = { mbwrite = {function(user,data,cmd) if user then local _,_,post = data:find("%b<> %p"..cmd.." (.+)|") if not post then return "Error!, Usage: "..MbCfg.Prefixes:sub(1,1)..cmd.." <message>" else return WriteMsg(user,post,false) end else return "Post A Message To The Board"," %[line:Message]"," %[line:Message]" end end, {[-1] = true,[0] = true,[1] = true,[2] = true,[3] = true} }, mbsticky = {function(user,data,cmd) if user then local _,_,post = data:find("%b<> %p"..cmd.." (.+)|") if not post then return "Error!, Usage: "..MbCfg.Prefixes:sub(1,1)..cmd.." <sticky message>" else return WriteMsg(user,post,true) end else return "Post A Sticky Message To The Board"," %[line:Sticky Message]"," %[line:Sticky Message]" end end, {[-1] = true,[0] = true,[1] = true,[2] = true,[3] = true} }, mbread = {function(user,data,cmd) if user then local _,_,lo,hi = data:find("%b<> %p"..cmd.." ([%d]-) ([%d]-)|") if lo then lo = tonumber(lo) end if hi then hi = tonumber(hi) end return ReadBoard(lo,hi,nil,nil,nil,nil) else return "Read Board Messages"," %[line:Start Range # (Optional)] %[line:End Range # (Optional)]", " %[line:Start Range # (Optional)] %[line:End Range # (Optional)]" end end, {[-1] = true,[0] = true,[1] = true,[2] = true,[3] = true} }, mbreadnick = {function(user,data,cmd) if user then local _,_,nick = data:find("%b<> %p"..cmd.." (%S+)|") if nick then return ReadBoard(nil,nil,nil,nick,nil,nil) else return "Error!, Usage: "..MbCfg.Prefixes:sub(1,1)..cmd.." <nick name>" end else return "Read Board Messages For Nick"," %[line:Nickname]"," %[line:Nickname]" end end, {[-1] = true,[0] = true,[1] = true,[2] = false,[3] = false} }, mbreadmine = {function(user,data,cmd) if user then return ReadBoard(nil,nil,nil,user.sNick,nil,nil) else return "Read My Board Messages","","" end end, {[-1] = true,[0] = true,[1] = true,[2] = false,[3] = false} }, mbreaddate = {function(user,data,cmd) if user then local _,_,m,d,y = data:find("%b<> %p"..cmd.." (%d%d)%/(%d%d)%/(%d%d%d%d)|$") if m and d and y then local x = {["month"] = m,["day"] = d,["year"] = y} local t = os.time(x) if not t then return "Date is out of range" else return ReadBoard(nil,nil,nil,nil,t,nil) end else return "Error!, Usage: "..MbCfg.Prefixes:sub(1,1)..cmd.." <mm/dd/yyyy>" end else return "Read Board Messages For Date"," %[line:Date in mm/dd/yyyy format]"," %[line:Date in mm/dd/yyyy format]" end end, {[-1] = true,[0] = true,[1] = true,[2] = false,[3] = false} }, mbreadrange = {function(user,data,cmd) if user then local _,_,nick = data:find("%b<> %p"..cmd.." (%S+)|") local _,_,m,d,y,m2,d2,y2 = data:find("%b<> %p"..cmd.." (%d%d*)%/(%d%d*)%/(%d%d%d%d) (%d%d*)%/(%d%d*)%/(%d%d%d%d)|$") if m and d and y and m2 and d2 and y2 then local x,x2 = {["month"] = m,["day"] = d,["year"] = y},{["month"] = m2,["day"] = d2,["year"] = y2} local t,t2 = os.time(x),os.time(x2) if t and t2 then if t > t2 then return "Start date may not be later than end date." else return ReadBoard(nil,nil,nil,nil,t,t2) end else local s = "" if not t then s = "Start date is" end if not t2 then if s:len() == 0 then s = "End date is" else s = s.." and end date are both" end end return "Error! "..s.." out of range." end else return "Error!, Usage: "..MbCfg.Prefixes:sub(1,1)..cmd.." <mm/dd/yyyy> <mm/dd/yyyy>" end else return "Read Board Messages For Date Range", " %[line:Start Date in mm/dd/yyyy format] %[line:End Date in mm/dd/yyyy format]", " %[line:Start Date in mm/dd/yyyy format] %[line:End Date in mm/dd/yyyy format]" end end, {[-1] = false,[0] = true,[1] = true,[2] = false,[3] = false} }, mbquery = {function(user,data,cmd) if user then local _,_,query = data:find("%b<> %p"..cmd.." (.+)|") if query then return ReadBoard(nil,nil,query,nil,nil,nil) else return "Error!, Usage: "..MbCfg.Prefixes:sub(1,1)..cmd.." <search string>" end else return "Search Board Messages For String"," %[line:Search String]"," %[line:Search String]" end end, {[-1] = false,[0] = true,[1] = true,[2] = true,[3] = false} }, mbdelmsg = {function(user,data,cmd) if user then local _,_,int = data:find("%b<> %p"..cmd.." (%d+)|") if not int then return "Error!, Usage: "..MbCfg.Prefixes:sub(1,1)..cmd.." <message number>" else if BoardMessages[tonumber(int)] then table.remove(BoardMessages,tonumber(int)) return "Message number "..int.." has been deleted." else return "Sorry "..user.sNick..", message number "..int.." is invalid." end end else return "Remove A Message From The Board"," %[line:Message Number]"," %[line:Message Number]" end end, {[-1] = false,[0] = true,[1] = false,[2] = false,[3] = false} }, mbdelmymsg = {function(user,data,cmd) if user then local _,_,int = data:find("%b<> %p"..cmd.." (%d+)|") if not int then return "Error!, Usage: "..MbCfg.Prefixes:sub(1,1)..cmd.." <message number>" else if BoardMessages[tonumber(int)] then if BoardMessages[tonumber(int)][2]:lower() == user.sNick:lower() then table.remove(BoardMessages,tonumber(int)) return "Message number "..int.." has been deleted." else return "Sorry "..user.sNick..", message number "..int.." is not yours." end else return "Sorry "..user.sNick..", message number "..int.." is invalid." end end else return "Remove My Message From The Board"," %[line:Message Number]"," %[line:Message Number]" end end, {[-1] = true,[0] = true,[1] = true,[2] = true,[3] = true} }, mbdelsticky = {function(user,data,cmd) if user then local _,_,int = data:find("%b<> %p"..cmd.." (%d+)|") if not int then return "Error!, Usage: "..MbCfg.Prefixes:sub(1,1)..cmd.." <message number>" else if StickyMessages[tonumber(int)] then table.remove(StickyMessages,tonumber(int)) return "Message number "..int.." has been deleted." else return "Sorry "..user.sNick..", sticky number "..int.." is invalid." end end else return "Remove A Sticky From The Board"," %[line:Sticky Number]"," %[line:Sticky Number]" end end, {[-1] = false,[0] = true,[1] = false,[2] = false,[3] = false} }, mbhelp = {function(user,data,cmd) if user then local reply,t,c = "\n\n\t"..MbCfg.Script.." Command Help\n\n\tCommand".. "\t\tDescription\r\n\t"..string.rep("¯",40).."\r\n",{},"" for i,v in pairs(MbCmds) do local desc,args = MbCmds[i][1]() table.insert(t,"\t+"..string.format("%-15s",i).."\t"..desc.."\r\n") end table.sort(t, function(a,b)return a < b end) for i,v in ipairs(t) do c = c..v end if c:len() > 0 then return reply..c.."\n\t"..string.rep("¯",40).."\r\n\r\n" end else return MbCfg.Script.." Help","","" end end, {[-1] = true,[0] = true,[1] = true,[2] = true,[3] = true} }}
<[MessageBoard]> Welcome Unregistered, Unregistered User's MessageBoard 2.2 commands enabled. Right click hub tab or user list for menu.
-- Descending read order? true/false [false = ascending] Descend = true,
[3] [ 11/16/09 19:55:45 ] <NICK_1> FILE 1 shared! :) [2] [ 11/16/09 22:16:18 ] <NICK_2> FILE 2 shared! [1] [ 11/16/09 22:50:21 ] <NICK_3> FILE 3 Shared !!!
[1] [ 11/16/09 19:55:45 ] <NICK_1> FILE 1 shared! :) [2] [ 11/16/09 22:16:18 ] <NICK_2> FILE 2 shared! [3] [ 11/16/09 22:50:21 ] <NICK_3> FILE 3 Shared !!!
--[[ MessageBoard 2.3 LUA 5.1x [Strict] [API 2] By Mutor 12/24/07 A simple message board with stickies for the new PtokaX API This is a complete rewrite of the script and thus a new format. Previous message logs are incompatible with this version. -Provides context menu [right click] -Menus/commands permission per profile, per command -Hub tab commands display in main, user list commands display in pm from bot. -Option to always display in private message -Option to display stickies or messages first -Duplicate message/percentage same message, block feature -Anti-advertisment option [ops protected] -Max message cache limit. Read message limit. -Alphabetic command listing -Error reporting to OpNick +Changes from 2.0 09/28/08 +Added option for ascending/descending read order requested by Yahoo +Changes from 2.1 01/11/09 +Added option for message history at login requested by Jusper +Added user command to toggle history [per user] +Changes from 2.2 11/16/09 +Added 'order' to commands menus / help listing. +Added help listing 'parameter', see below. ~Changed OnError function, option to send to OpNick or OpChat, if enabled. MessageBoard 2.3 Command Help Command Parameter Description ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ !mbread <start> <end> Read Board Messages !mbwrite <message> Post A Message To The Board !mbsticky <sticky message> Post A Sticky Message To The Board !mbdelmsg <message number> Remove A Message From The Board !mbdelmymsg <message number> Remove My Message From The Board !mbdelsticky <sticky number> Remove A Sticky From The Board !mbquery <search string> Search Board Messages For String !mbreadmine Read My Board Messages !mbreadnick <nick> Read Board Messages For Nick !mbreaddate <mm/dd/yyyy> Read Board Messages For Date !mbreadrange <start date> <end date> Read Board Messages For Date Range !msghistory Toggle Message History At Login !mbhelp [this information] MessageBoard 2.3 Help ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯]]MbCfg = { -- Admin's "nick" for status / error messages ["" = Send to OpChat] OpNick = "Mutor", -- "Botname" ["" = hub bot] BotNick = "[MessageBoard]", -- Should bot have a key? true/false BotIsOp = true, -- Bot's description BotDesc = "", -- Bot Email address BotMail = "user@domain.com", -- "Command Menu" ["" = hub name] Menu = "", -- "Command SubMenu" ["" = script name] SubMenu = "", -- File to save messages MsgFile = "MessageBoard23.dat", -- File to save sticky messages StickyFile = "StickyBoard23.dat", -- Always reply in PM? true/false PmOnly = true, -- List Messages Before Stickies? true/false MsgFirst = true, -- Prefix Sticky Message With Time Stamp true/false StickyTs = true, -- Maximum number of messages to cache MaxCache = 500, -- Default number of messages to read ReadCnt = 10, -- Enable Anti-Advertisement filtering? true/false AaEnabled = true, -- Anti-Advertisement triggers AaTrigs = { "bounceme.net","hopto.org","myftp.biz","myftp.org","myvnc.com","no-ip.biz","no-ip.info","no-ip.org", "redirectme.net","servebeer.com","serveblog.net","servecounterstrike.com","serveftp.com","servegame.com", "servehalflife.com","servehttp.com","servemp3.com","servepics.com","servequake.com","sytes.net","mine.nu", "zapto.org","blogsyte.com","cable-modem.org","ciscofreak.com","damnserver.com","ditchyourip.com", "dnsiskinky.com","geekgalaxy.com","homesecuritymac.com","homesecuritypc.com","myactivedirectory.com", "mymediapc.net","mypsx.net","net-freaks.com","no-ip.ca","no-ip.co.uk","no-ip.com","no-ip.net","point2this.com", "pointto.us","quicksytes.com","securityexploits.com","securitytactics.com","serveexchange.com","servehumour.com", "servep2p.com","servesarcasm.com","stufftoread.com","unusualperson.com","workisboring.com","dns2go","myftpsite", }, -- Acceptable percentage of same words allowed in new posting [set as 101 to disable] MatchLimit = 35, -- Descending read order? true/false [false = ascending] Descend = false, -- Send message history to connecting users? true/false History = true,}local Path = Core.GetPtokaXPath().."scripts/"OnStartup = function() MbCfg.Script,MbCfg.Prefixes = "MessageBoard 2.3",SetMan.GetString(29) if MbCfg.BotNick == "" then MbCfg.BotNick = SetMan.GetString(21) end if MbCfg.BotDesc == "" then MbCfg.BotDesc = SetMan.GetString(21).." "..MbCfg.Script end if MbCfg.BotNick ~= SetMan.GetString(21) then Core.RegBot(MbCfg.BotNick, MbCfg.BotDesc, MbCfg.BotMail, MbCfg.BotIsOp) end if MbCfg.Menu == "" then MbCfg.Menu = SetMan.GetString(0) end if MbCfg.SubMenu == "" then MbCfg.SubMenu = MbCfg.Script end if not MbCfg.AaEnabled then MbCfg.AaTrigs = nil end if not MbCfg.MsgFile:find("^"..Path,1,true) then MbCfg.MsgFile = Path..MbCfg.MsgFile end if not MbCfg.StickyFile:find("^"..Path,1,true) then MbCfg.StickyFile = Path..MbCfg.StickyFile end MbCfg.HistoryFile = Path.."MsgHistory.dat" if loadfile(MbCfg.MsgFile) then dofile(MbCfg.MsgFile) else BoardMessages = {} SaveFile(MbCfg.MsgFile,BoardMessages,"BoardMessages") end if loadfile(MbCfg.StickyFile) then dofile(MbCfg.StickyFile) else StickyMessages = {} SaveFile(MbCfg.StickyFile,StickyMessages,"StickyMessages") end if loadfile(MbCfg.HistoryFile) then dofile(MbCfg.HistoryFile) else History = {} SaveFile(MbCfg.HistoryFile,History,"History") end MbCfg.Order = {"mbread","mbwrite","mbsticky","mbdelmsg","mbdelmymsg","mbdelsticky", "mbquery","mbreadmine","mbreadnick","mbreaddate","mbreadrange","msghistory","mbhelp"} OnError(MbCfg.Script.." ".._VERSION.." by Mutor has been started, using "..Mem().." of memory.")endOnExit = function() OnError(MbCfg.Script.." ".._VERSION.." by Mutor has been stopped. Freeing "..Mem().." of memory.")endOnError = function(msg) if msg and msg:len() > 0 then if msg:sub(-1,-1)~= "|" then msg = msg.."|" end if MbCfg.OpNick and MbCfg.OpNick ~= "" then local user = Core.GetUser(MbCfg.OpNick) if user then Core.SendToUser(user,"<"..MbCfg.BotNick.."> "..msg) end else local x = SetMan.GetOpChat().bEnabled if x then Core.SendToOpChat("<"..MbCfg.BotNick.."> "..msg) else Core.SendPmToOps(MbCfg.Bot,msg) end end endendUserConnected = function(user) if SendMbCmds(user) then local Prof = "Unregistered User" if user.iProfile ~= -1 then Prof = ProfMan.GetProfile(user.iProfile).sProfileName end local msg = "Welcome "..user.sNick..", "..Prof.."'s "..MbCfg.Script.." commands ".. "enabled. Right click hub tab or user list for menu." Core.SendToUser(user,"<"..MbCfg.BotNick.."> "..msg.."|") end local Chk = function(n) for i,v in ipairs(History) do if n:lower() == v:lower() then return true end end end if next(BoardMessages) and MbCfg.History and Chk(user.sNick) then local sfx = "\r\n\r\n\tType "..MbCfg.Prefixes:sub(1,1).."msghistory to toggle this pm on/off" local lo,hi = 1,math.min(MbCfg.ReadCnt,#BoardMessages) local msg = ReadBoard(lo,hi,nil,nil,nil,nil)..sfx Core.SendPmToUser(user,MbCfg.BotNick,msg.."|") endendOpConnected,RegConnected = UserConnected,UserConnectedChatArrival = function(user,data) local _,_,cmd = data:find("%b<> ["..MbCfg.Prefixes.."](%a+)") if cmd and MbCmds[cmd] and MbCmds[cmd][2][user.iProfile] then if MbCfg.AaEnabled and not Core.GetUserValue(user,11) then for _,v in ipairs(MbCfg.AaTrigs) do if data:lower():find(v:lower(),1,1) or data:find("%d-%.%d-%.%d-%.%d-") then return Core.SendToAll("<"..MbCfg.BotNick.."> Let's all laugh at ".. user.sNick..", who tried and failed to advertise on the message board." ),true end end end local reply = MbCmds[cmd][1](user,data,cmd) if reply and reply ~= "" then local _,_,to = data:find("^$To: (%S+) From:") if to and to == MbCfg.BotNick or MbCfg.PmOnly then Core.SendPmToUser(user,MbCfg.BotNick,reply.."|") else Core.SendToUser(user,"<"..MbCfg.BotNick.."> "..reply.."|") end end return true endendToArrival = ChatArrivalMem = function() collectgarbage("collect") return string.format("%-.2f Kb.",collectgarbage("count")) endReadBoard = function(from,to,query,auth,date,daterange) local arg = "" local z if auth or query or date then if query then arg = "For Search String: "..query elseif auth then arg = "For Author: "..auth end z = true from,to = 1,#BoardMessages end if not from then from = 1 else z = true end if not to then to = math.min(from + MbCfg.ReadCnt,#BoardMessages) else to = math.min(to,#BoardMessages) end local sret,ret,m,s,x,result = {},{},"","","-","" if not z and next(StickyMessages) then for i,v in ipairs(StickyMessages) do if date or daterange then local d1,d2 = os.date("%x",v[3]):gsub("%D",""),os.date("%x",date):gsub("%D","") if daterange then d3 = os.date("%x",daterange):gsub("%D","") if d1 >= d2 or d1 <= d3 then s = s.." ["..i.."] "..v[1].."\n" table.insert(sret,{i," ["..i.."] "..v[1].."\n"}) end else if d1 == d2 then table.insert(sret,{i," ["..i.."] "..v[1].."\n"}) end end elseif auth then if v[2]:lower():find(auth:lower(),1,true) then table.insert(sret,{i," ["..i.."] "..v[1].."\n"}) end elseif not query or v[1]:gsub("^.+> ",""):find(query) then table.insert(sret,{i," ["..i.."] "..v[1].."\n"}) end end end if next(BoardMessages) then for i = from, to do if date then arg = "For: "..os.date("%x",date) local d1,d2 = os.date("%x",BoardMessages[i][3]):gsub("%D",""),os.date("%x",date):gsub("%D","") if daterange then arg = arg.." To: "..os.date("%x",daterange) d3 = os.date("%x",daterange):gsub("%D","") if d1 >= d2 or d1 <= d3 then table.insert(ret,{i," ["..i.."] "..BoardMessages[i][1].."\n\n"}) end else if d1 == d2 then table.insert(ret,{i," ["..i.."] "..BoardMessages[i][1].."\n\n"}) end end elseif auth then if BoardMessages[i][2]:lower():find(auth:lower(),1,true) then table.insert(ret,{i," ["..i.."] "..BoardMessages[i][1].."\n\n"}) end elseif not query or BoardMessages[i][1]:gsub("^.+> ",""):find(query) then arg = tostring(to - from + 1).." Messages" table.insert(ret,{i," ["..i.."] "..BoardMessages[i][1].."\n\n"}) end end end if #ret > 0 then if MbCfg.Descend then table.sort(ret, function(a,b) return a[1] > b[1] end) end for i,v in ipairs(ret) do m = m..v[2] end result = "\n\n----[ "..tostring(#ret).." Board Messages ]"..x:rep(175).."\n\n"..m..x:rep(175).."[ "..tostring(#ret).." Board Messages ]----\n" end if #sret > 0 then if MbCfg.Descend then table.sort(sret, function(a,b) return a[1] > b[1] end) end for i,v in ipairs(sret) do s = s..v[2] end local so = "\n\n----[ "..tostring(#sret).." Sticky Messages ]"..x:rep(175).."\n"..s..x:rep(175).."[ "..tostring(#sret).." Sticky Messages ]----\n" if MbCfg.MsgFirst then result = result..so else result = so..result end end if result:len() > 0 then return "Results: "..arg..result else return "No matching entries found." endendWriteMsg = function(user,msg,sticky) if MbCfg.AaEnabled and not Core.GetUserValue(user,11) then for _,v in ipairs(MbCfg.AaTrigs) do if msg:lower():find(v:lower(),1,1) or msg:find("%d-%.%d-%.%d-%.%d-") then return "Invalid string detected: "..string.format("%q",v)..". You may not advertise here." end end end local check,reply = CheckMsg(msg,sticky) if check then return "I'm sorry that is too close a match to an existing entry. Last match found:\n\n".. " [# "..check.."] - "..reply.."\n\n" else local msgtype = "board message" local prof = "Unregistered User" if user.iProfile ~= -1 then prof = ProfMan.GetProfile(user.iProfile).sProfileName end local msgprefix = "[ "..os.date().." ] <"..user.sNick.."> " if sticky then msgtype = "sticky message" if MbCfg.StickyTs then table.insert(StickyMessages,1,{msgprefix:gsub("<","%1"..prof.." ")..msg,user.sNick,os.time()}) else table.insert(StickyMessages,1,{msgprefix:gsub("^%b[] <","<"..prof.." ")..msg,user.sNick,os.time()}) end SaveFile(MbCfg.StickyFile,StickyMessages,"StickyMessages") else table.insert(BoardMessages,1,{msgprefix..msg,user.sNick,os.time()}) SaveFile(MbCfg.MsgFile,BoardMessages,"BoardMessages") end while #BoardMessages > MbCfg.MaxCache do table.remove(BoardMessages,#BoardMessages) end local reply = prof.." "..user.sNick.." just posted a "..msgtype.. " to the message board. Type "..MbCfg.Prefixes:sub(1,1).."mbread to read messages." Core.SendToAll("<"..MbCfg.BotNick.."> "..reply.."|") return prof.." "..user.sNick..", your "..msgtype.." was successfully posted." endendCheckMsg = function(msg,sticky) local T = BoardMessages if sticky then T = StickyMessages end if next(T) then msg = msg:lower(msg) for i,v in ipairs(T) do local txt = v[1]:lower():gsub("^%[.-%] ","") --Exact match, case insensitive if txt:lower() == msg:lower() then return i,v[1] end --Match anywhere within message, case insensitive if txt:lower():find(msg:lower()) then return i,v[1] end --Run a loop to find percentage of match local len,cnt = 0,0 for word in txt:gmatch("%S+") do len = len + 1 if msg:lower():find(word,1,1) then cnt = cnt + 1 end end local pct = (cnt/len) * 100 or 0 if pct >= MbCfg.MatchLimit then return i,v[1].." String match: "..string.format("%.2f%%",pct) end end endendSendMbCmds = function(user) local u,p,m,s,t,c = "$UserCommand 1 ",MbCfg.Prefixes:sub(1,1),MbCfg.Menu,MbCfg.SubMenu,{},"" for i,v in ipairs(MbCfg.Order) do if MbCmds[v][2][user.iProfile] then local desc,arg1,arg2 = MbCmds[v][1]() c = c..u.."1 "..m.."\\"..s.."\\"..desc.."$<%[mynick]> "..p..v..arg1.."||".. u.."2 "..m.."\\"..s.."\\"..desc.."$$To: "..MbCfg.BotNick.." From: %[mynick] ".. "$<%[mynick]> "..p..v..arg2.."||" end end if c ~= "" then Core.SendToUser(user,c) Mem() return true end Mem()endMbCmds = { mbwrite = {function(user,data,cmd) if user then local _,_,post = data:find("%b<> %p"..cmd.." (.+)|") if not post then return "Error!, Usage: "..MbCfg.Prefixes:sub(1,1)..cmd.." <message>" else return WriteMsg(user,post,false) end else return "Post A Message To The Board"," %[line:Message]"," %[line:Message]","<message>" end end, {[-1] = false,[0] = true,[1] = true,[2] = true,[3] = true} }, mbsticky = {function(user,data,cmd) if user then local _,_,post = data:find("%b<> %p"..cmd.." (.+)|") if not post then return "Error!, Usage: "..MbCfg.Prefixes:sub(1,1)..cmd.." <sticky message>" else return WriteMsg(user,post,true) end else return "Post A Sticky Message To The Board"," %[line:Sticky Message]", " %[line:Sticky Message]","<sticky message>" end end, {[-1] = false,[0] = true,[1] = true,[2] = true,[3] = true} }, mbread = {function(user,data,cmd) if user then local _,_,lo,hi = data:find("%b<> %p"..cmd.." ([%d]-) ([%d]-)|") if lo then lo = tonumber(lo) end if hi then hi = tonumber(hi) end return ReadBoard(lo,hi,nil,nil,nil,nil) else return "Read Board Messages"," %[line:Start Range # (Optional)] %[line:End Range # (Optional)]", " %[line:Start Range # (Optional)] %[line:End Range # (Optional)]","<start> <end>" end end, {[-1] = false,[0] = true,[1] = true,[2] = true,[3] = true} }, mbreadnick = {function(user,data,cmd) if user then local _,_,nick = data:find("%b<> %p"..cmd.." (%S+)|") if nick then return ReadBoard(nil,nil,nil,nick,nil,nil) else return "Error!, Usage: "..MbCfg.Prefixes:sub(1,1)..cmd.." <nick name>" end else return "Read Board Messages For Nick"," %[line:Nickname]"," %[line:Nickname]","<nick>" end end, {[-1] = false,[0] = true,[1] = true,[2] = false,[3] = false} }, mbreadmine = {function(user,data,cmd) if user then return ReadBoard(nil,nil,nil,user.sNick,nil,nil) else return "Read My Board Messages","","","" end end, {[-1] = false,[0] = true,[1] = true,[2] = false,[3] = false} }, mbreaddate = {function(user,data,cmd) if user then local _,_,m,d,y = data:find("%b<> %p"..cmd.." (%d%d)%/(%d%d)%/(%d%d%d%d)|$") if m and d and y then local x = {["month"] = m,["day"] = d,["year"] = y} local t = os.time(x) if not t then return "Date is out of range" else return ReadBoard(nil,nil,nil,nil,t,nil) end else return "Error!, Usage: "..MbCfg.Prefixes:sub(1,1)..cmd.." <mm/dd/yyyy>" end else return "Read Board Messages For Date"," %[line:Date in mm/dd/yyyy format]", " %[line:Date in mm/dd/yyyy format]","<mm/dd/yyyy>" end end, {[-1] = false,[0] = true,[1] = true,[2] = false,[3] = false} }, mbreadrange = {function(user,data,cmd) if user then local _,_,nick = data:find("%b<> %p"..cmd.." (%S+)|") local _,_,m,d,y,m2,d2,y2 = data:find("%b<> %p"..cmd.." (%d%d*)%/(%d%d*)%/(%d%d%d%d) (%d%d*)%/(%d%d*)%/(%d%d%d%d)|$") if m and d and y and m2 and d2 and y2 then local x,x2 = {["month"] = m,["day"] = d,["year"] = y},{["month"] = m2,["day"] = d2,["year"] = y2} local t,t2 = os.time(x),os.time(x2) if t and t2 then if t > t2 then return "Start date may not be later than end date." else return ReadBoard(nil,nil,nil,nil,t,t2) end else local s = "" if not t then s = "Start date is" end if not t2 then if s:len() == 0 then s = "End date is" else s = s.." and end date are both" end end return "Error! "..s.." out of range." end else return "Error!, Usage: "..MbCfg.Prefixes:sub(1,1)..cmd.." <mm/dd/yyyy> <mm/dd/yyyy>" end else return "Read Board Messages For Date Range", " %[line:Start Date in mm/dd/yyyy format] %[line:End Date in mm/dd/yyyy format]", " %[line:Start Date in mm/dd/yyyy format] %[line:End Date in mm/dd/yyyy format]", "<start date> <end date>" end end, {[-1] = false,[0] = true,[1] = true,[2] = false,[3] = false} }, mbquery = {function(user,data,cmd) if user then local _,_,query = data:find("%b<> %p"..cmd.." (.+)|") if query then return ReadBoard(nil,nil,query,nil,nil,nil) else return "Error!, Usage: "..MbCfg.Prefixes:sub(1,1)..cmd.." <search string>" end else return "Search Board Messages For String"," %[line:Search String]", " %[line:Search String]","<search string>" end end, {[-1] = false,[0] = true,[1] = true,[2] = true,[3] = false} }, mbdelmsg = {function(user,data,cmd) if user then local _,_,int = data:find("%b<> %p"..cmd.." (%d+)|") if not int then return "Error!, Usage: "..MbCfg.Prefixes:sub(1,1)..cmd.." <message number>" else if BoardMessages[tonumber(int)] then table.remove(BoardMessages,tonumber(int)) return "Message number "..int.." has been deleted." else return "Sorry "..user.sNick..", message number "..int.." is invalid." end end else return "Remove A Message From The Board"," %[line:Message Number]", " %[line:Message Number]","<message number>" end end, {[-1] = false,[0] = true,[1] = false,[2] = false,[3] = false} }, mbdelmymsg = {function(user,data,cmd) if user then local _,_,int = data:find("%b<> %p"..cmd.." (%d+)|") if not int then return "Error!, Usage: "..MbCfg.Prefixes:sub(1,1)..cmd.." <message number>" else if BoardMessages[tonumber(int)] then if BoardMessages[tonumber(int)][2]:lower() == user.sNick:lower() then table.remove(BoardMessages,tonumber(int)) return "Message number "..int.." has been deleted." else return "Sorry "..user.sNick..", message number "..int.." is not yours." end else return "Sorry "..user.sNick..", message number "..int.." is invalid." end end else return "Remove My Message From The Board"," %[line:Message Number]", " %[line:Message Number]","<message number>" end end, {[-1] = false,[0] = true,[1] = true,[2] = true,[3] = true} }, mbdelsticky = {function(user,data,cmd) if user then local _,_,int = data:find("%b<> %p"..cmd.." (%d+)|") if not int then return "Error!, Usage: "..MbCfg.Prefixes:sub(1,1)..cmd.." <message number>" else if StickyMessages[tonumber(int)] then table.remove(StickyMessages,tonumber(int)) return "Message number "..int.." has been deleted." else return "Sorry "..user.sNick..", sticky number "..int.." is invalid." end end else return "Remove A Sticky From The Board"," %[line:Sticky Number]", " %[line:Sticky Number]","<sticky number>" end end, {[-1] = false,[0] = true,[1] = false,[2] = false,[3] = false} }, msghistory = {function(user,data,cmd) if user then local Chk = function(n) for i,v in ipairs(History) do if n:lower() == v:lower() then return i end end return false end local status,result,x = "added to","You will now receive message history at login.",Chk(user.sNick) if x then table.remove(History,x) status,result = "removed from","You will no ".. "longer receive message history at login." else table.insert(History,user.sNick) end SaveFile(MbCfg.HistoryFile,History,"History") return "You have been "..status.." the history table. "..result else return "Toggle Message History At Login","","","" end end, {[-1] = false,[0] = true,[1] = true,[2] = true,[3] = true} }, mbhelp = {function(user,data,cmd) if user then local reply,t,p,c = "\n\n\t"..MbCfg.Script.." Command Help\n\n\tCommand".. "\t\tParameter\t\t\tDescription\r\n\t"..string.rep("¯",75).."\r\n",{},MbCfg.Prefixes:sub(1,1),"" for i,v in ipairs(MbCfg.Order) do if MbCmds[v][2][user.iProfile] then local desc,_,_,parm = MbCmds[v][1]() local ts = "\t" if #parm < 8 then ts = "\t\t" end c = c.."\t"..p..string.format("%-15s",v).."\t".. string.format("%-40.35s",parm)..ts..desc.."\r\n" end end if c:len() > 0 then return reply..c.."\n\t"..string.rep("¯",75).."\r\n\r\n" end else return MbCfg.Script.." Help","","","[this information]\t" end end, {[-1] = false,[0] = true,[1] = true,[2] = true,[3] = true} }}Serialize = function(tTable, sTableName, hFile, sTab) sTab = sTab or ""; hFile:write(sTab..sTableName.." = {\n" ) for key, value in ipairs(tTable) do 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 hFile:write( sTab.."}")endSaveFile = function(file,table, tablename ) local hFile = io.open (file , "wb") Serialize(table, tablename, hFile) hFile:close() collectgarbage("collect")end
The number is the actual index from the table.The table is sorted by the Descend setting.I think it best to reflect the actual index,rather than what you feel to 'look' better.For the record it's NOT a release bot even if you want it to be.