Dump Board
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

Dump Board

Started by patrick, 15 January, 2009, 18:24:23

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

patrick

--[[
	Message Board 1.07	10/20/04 LUA 5 .0/5.1
	converted to LUA 5 - 09/15/05
	by Mutor

	Provides common message board. Allow users to read/write the board by profiles
	Option to delete messages, permission bt profile
	Caches board messages to exteernal text file for script/hub restarts

	+Changes from v 1.00    By Mutor
		+Added  case sensitive commands, request by NeoUltimicia
		+Added  date/time to message, request by NeoUltimicia
		+Errors now sent to PM as well as main
		+Corrected save string and tweaked table read
	+Changes from v 1.01
		+converted to LUA 5	By blackwings
		+these frmHub:GetPrefixes(1)es can be used = !+?$# - by blackwings
	+Changes from v 1.02
		+fixed a load file bug - by blackwings
	+Changes from v 1.03 	By Madman
		+fixed file handling bug
		+fixed left over lua4 parts
		-removed VaildCmd stuff
		+changed MsgBoard function to ToArrival
		+fixed prefix error
		+added auto detect if bot has hubbotname
		+fixed some minor bugs
		+added support for mainchat
		+fixed extra linespacing
	+Changes from v 1.03	By Mutor
		+LUA 5.02 / 5.1x compatible
		+Added readby & help commands and rbprofile table	 Requested by cynicist8
		+Changed Chat and To Arrivals
		+Added context menu [right click]
		+Added create messages file if non existant
		-Removed MsgBoard function
		~Broke out tCmds to a global var
	+Changes from v 1.05	By Mutor        09/24/06
		+Added respond in PM only       Request by speedX
		+Added delete own message command
		+Moved all globals vars to config table
		-Dropped loadfile function
		+Changed load file code and moved to Main
		+Added status / error messages [Sent to OpNick]
		+Added more garbage collection
		+Many textual changes
	+Changes from v 1.06	By Mutor        10/04/06
		+Added find word [case insensitive] in message       swapy2006
		+Added SearchProf table
		+A few optimizations
		
]]

--User Settings-------------------------------------------------------------------------------------
MsgCfg = {
-- Hub name, pulled from the Px
Hub = frmHub:GetHubName(),
-- Botname, use frmHub:GetHubBotName() or "BotName"
Bot = frmHub:GetHubBotName(),
-- Admins nick for status / error messages
OpNick = "Mutor",
--Reply in private message only  ["on"/"off"]
PmOnly = "on",
-- Script Command, read board
Read = string.lower("dumps"),
-- Script Command, write to board
Write = string.lower("dump"),
-- Script Command, delete messages
Delete = string.lower("deldump"),
-- Script Command, read messages by...
ReadBy = string.lower("wrotedump"),
-- Script Command, script command help
DeleteMine = string.lower("delmydump"),
-- Script Command, read messages by...
Search = string.lower("searchdump"),
-- Script Command, script command help
Help = string.lower("msghelp"),
-- Max number of messages to cache
MaxMsg = 500,
-- Message file.
MsgFile = "dumper.txt",
-- Which profiles may read the board?
ReadProf = {[0]=1,[1]=1,[2]=1,[3]=1,[4]=1,[5]=1,[-1]=1},
-- Which profiles may write to the board?
WriteProf = {[0]=1,[1]=1,[2]=1,[3]=1,[4]=1,[5]=1,[-1]=1},
-- Which profiles may delete messages?
DelProf = {[0]=1,[1]=0,[2]=0,[3]=1,[4]=1,[5]=1,[-1]=1},
-- Which profiles may read messages from specified user?
ReadByProf = {[0]=1,[1]=1,[2]=1,[3]=1,[4]=1,[5]=1,[-1]=0},
-- Which profiles may search messages for specified string?
SearchProf = {[0]=1,[1]=1,[2]=1,[3]=1,[4]=1,[5]=1,[-1]=0},
-- Which profiles receive command menu(s)?
CmdProf = {[0]=1,[1]=1,[2]=1,[3]=1,[4]=1,[5]=1,[-1]=1},
-- Name for command Menu, pulled from Hub
Menu = frmHub:GetHubName(),

}
--End User Settings----------------------------------------------------------------------------------

BoardMessages = {}

function Main()
	gc,no,pat = nil,table.getn,string.gfind
	if _VERSION == "Lua 5.1" then
		gc,no,pat = "collect",table.maxn,string.gmatch
	end
	if loadfile(MsgCfg.MsgFile) then
		dofile(MsgCfg.MsgFile)
	else
		local handle,err = io.open(MsgCfg.MsgFile,"w")
		handle:write("BoardMessages = {}")
		handle:close()
	end
	if not (MsgCfg.Bot == frmHub:GetHubBotName()) then
		frmHub:RegBot(MsgCfg.Bot,1,"","")
	end
	collectgarbage(gc)
	OnError("Message Board 1.07 for ".._VERSION.." by Mutor has been started. Memory Used: "..gcinfo().." Kb.")
end

OnExit = function()
	OnError("Message Board 1.07 for ".._VERSION.." by Mutor has been stopped.")
end

OnError = function(msg)
	SendToNick(MsgCfg.OpNick,"<"..MsgCfg.Bot.."> "..msg)
end

function NewUserConnected(user, data)
	if MsgCfg.CmdProf[user.iProfile] and MsgCfg.CmdProf[user.iProfile]==1 then
		SendMsgCmds(user)
		local prof = GetProfileName(user.iProfile)
		
		user:SendData(MsgCfg.Bot,msg)
	end
end
OpConnected = NewUserConnected

ChatArrival = function(user, data)
	data = string.sub(data,1, -2)
	if MsgCfg.CmdProf[user.iProfile] and MsgCfg.CmdProf[user.iProfile]==1 then
		local s,e,to = string.find(data,"^$To:%s(%S+)%sFrom:")
		local s,e,cmd = string.find( data, "%b<>%s%p(%w+)")
		if cmd and tCmds[cmd] then
			if to and to == MsgCfg.Bot or MsgCfg.PmOnly == "on" then
				return user:SendPM(MsgCfg.Bot,tCmds[cmd](user,data)),0
			else
				return user:SendData(MsgCfg.Bot,tCmds[cmd](user,data)),0
			end
			collectgarbage(gc)
		end
	end
end
ToArrival = ChatArrival

tCmds = {
	[MsgCfg.Read] = function(user, data)
		if user then
			if MsgCfg.ReadProf[user.iProfile] and MsgCfg.ReadProf[user.iProfile]==1 then
				return ReadBoard(user,nil,nil)
			end
		else
			return "Read BoardMessages","",""
		end
	end,
	[MsgCfg.Write] = function(user, data)
		if user then
			if MsgCfg.WriteProf[user.iProfile] and MsgCfg.WriteProf[user.iProfile]==1 then
				local s,e,msg = string.find(data, "%b<>%s+%S+%s(.*)")
				if msg == nil then
					local dsp = "\r\n\t=-=<>"..string.rep("=-",21).."=<>=-=\r\n"..
					"\t"..MsgCfg.Hub.."\tDump Board\r\n"..
					"\tDid you forget what you were going to say?\r\n"..
					"\tCommand syntax is ->> "..frmHub:GetPrefixes()[1]..MsgCfg.Write.." \r\n"..
					"\t=-=<>"..string.rep("=-",21).."=<>=-=\r\n"
					return dsp
				else
					return Write2Board(user, msg)
				end
			end
		else
			return "Write BoardMessages"," %[line:Message]"," %[line:Message]"
		end
	end,
	[MsgCfg.Delete] = function(user, data)
		if user then
			if MsgCfg.DelProf[user.iProfile] and MsgCfg.DelProf[user.iProfile]==1 then
				local s,e,delmsg = string.find(data, "%b<>%s%S+%s(%d+)")
				if (delmsg == nil) then
					local dsp = "\r\n\t=-=<>"..string.rep("=-",21).."=<>=-=\r\n"..
					"\t"..MsgCfg.Hub.."\tDumps Board\r\n"..
					"\tDelete which message? Provide message number\r\n"..
					"\tCommand syntax is ->> "..frmHub:GetPrefixes()[1]..MsgCfg.Delete..
					" <msg#>\r\n\tType ->> "..frmHub:GetPrefixes()[1]..MsgCfg.Read..
					"  to list messages \r\n\t=-=<>"..string.rep("=-",21).."=<>=-=\r\n"
					return dsp
				else
					table.remove(BoardMessages, delmsg)
					SaveToFile(MsgCfg.MsgFile , BoardMessages , "BoardMessages")
					user:SendData(MsgCfg.Bot,"Message number [ "..delmsg.." ] has been deleted.")
					return dsp
				end
			end
		else
			return "Delete BoardMessages"," %[line:Message Number]"," %[line:Message Number]"
		end
	end,
	
	[MsgCfg.ReadBy] = function(user, data)
		if user then
			if MsgCfg.ReadByProf[user.iProfile] and MsgCfg.ReadByProf[user.iProfile]==1 then
			local s,e,nick = string.find(data, "%b<>%s%S+%s(%S+)")
				if nick then
					return ReadBoard(user,nick,nil)
				else
					return "Sorry "..user.sName..", you must "..
					"specify a nick. Usage: "..frmHub:GetPrefixes()[1]..MsgCfg.ReadBy.." <nick>"
				end
			end
		else
			return "Read BoardMessages From <nick>"," %[line:NickName]"," %[line:NickName]"
		end
	end,
	[MsgCfg.Search] = function(user, data)
		if user then
			if MsgCfg.SearchProf[user.iProfile] and MsgCfg.SearchProf[user.iProfile]==1 then
			local s,e,query = string.find(data, "%b<>%s%S+%s(%S+)")
				if query then
					return ReadBoard(user,nil,query)
				else
					return "Sorry "..user.sName..", you must specify a query string. "..
					"Usage: "..frmHub:GetPrefixes()[1]..MsgCfg.Search.." <string>"
				end
			end
		else
			return "Search BoardMessages For <String>"," %[line:Search String]"," %[line:Search String]"
		end
	end,
	[MsgCfg.Help] = function(user,data)
		if user then
			local reply = "Dumps Board Help\r\n\r\n\tCommand\t\tDescription\r\n"..
			"\t"..string.rep("?",40).."\r\n"
			for i,v in pairs(tCmds) do
				local desc,args = tCmds[i]()
				reply = reply.."\t+"..string.format("%-15s",i).."\t"..desc.."\r\n"
			end
			return reply.."\n\t"..string.rep("?",40).."\r\n\r\n"
		else
			return "Message Board Help","",""
		end
	end,
}

SendMsgCmds = function(user)
	for i,v in pairs(tCmds) do
		local desc,arg1,arg2 = tCmds[i]()
		
		
	end
	collectgarbage(gc)
end

function ReadBoard(user,nick,query)
	local n,x = no(BoardMessages) or 0,""
	local dsp = "\r\n=-=<>"..string.rep("=-",60).."=<>=-=\r\n"..
	"  "..MsgCfg.Hub.."\tDumps Board\t Displayng last [ "..n.." ] message(s)"..string.char(126).."\r\n"..
	"=-=<>"..string.rep("=-",60).."=<>=-=\r\n\r\n"
	if n > 0 then
		if nick then
			dsp = string.gsub(dsp,string.char(126)," from "..nick)
			local count = 0
			for i,v in ipairs(BoardMessages) do
				local s,e,usr = string.find(v,"%[%s(%S+)%s%]%swrote%:")
				if usr and usr == nick then
					count = count + 1
					dsp = dsp.." [ "..i.." ]\t"..BoardMessages[i]..""
				end
			end
			dsp = string.gsub(dsp,n,count)
			if count == 0 then
				dsp = dsp.."\r\nSorry "..user.sName..", there are no messages from "..nick.."."
			end
			return dsp
		elseif query then
			query = string.lower(query)
			dsp = string.gsub(dsp,string.char(126)," containing the string ' "..query.." '")
			local count = 0
			for i,v in ipairs(BoardMessages) do
				for str in pat(v,"(%S+)") do
					if string.lower(str) == query then
						count = count + 1
						dsp = dsp.." [ "..i.." ]"..BoardMessages[i]..""
					end
				end
			end
			dsp = string.gsub(dsp,n,count)
			if count == 0 then
				dsp = dsp.."\r\nSorry "..user.sName..", there are no messages containing "..
				"the string "..query.."."
			end
			return dsp
		else
			dsp = string.gsub(dsp,string.char(126),x)
			for i,v in ipairs(BoardMessages) do
				dsp = dsp.." [ "..i.." ]\t"..BoardMessages[i].."\r"
			end
			return dsp
		end
	else
		dsp = dsp.."\r\nSorry "..user.sName..", the message board is empty."
		return dsp
	end
	collectgarbage(gc)
end

function Write2Board(user, msg)
	local dsp = ""..string.rep("=-",0)..""..
	""..user.sName.."'s message was added."..
	""..string.rep("=-",0)..""..
	"Type "..frmHub:GetPrefixes()[1]..MsgCfg.Read.." in main/pm to list or "..frmHub:GetPrefixes()[1]..
	MsgCfg.Write.." to post."..
	""..string.rep("=-",0)..""
	SendToAll(MsgCfg.Bot, dsp)
	table.insert(BoardMessages, (""..os.date("%B %d %Y %X ").." [ "..user.sName.." ]  : ")..msg)
	if no(BoardMessages) > MsgCfg.MaxMsg then
		table.remove(BoardMessages, 1)
	end
	SaveToFile(MsgCfg.MsgFile , BoardMessages , "BoardMessages")
	collectgarbage(gc)
end

function Serialize(tTable, sTableName, sTab)
	assert(tTable, "tTable equals nil")
	assert(sTableName, "sTableName equals nil")
	assert(type(tTable) == "table", "tTable must be a table!")
	assert(type(sTableName) == "string", "sTableName must be a string!")
	sTab = sTab or ""
	sTmp = ""
	sTmp = sTmp..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
			sTmp = sTmp..Serialize(value, sKey, sTab.."\t")
		else
			local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value)
			sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
		end
		sTmp = sTmp..",\n"
	end
	sTmp = sTmp..sTab.."}"
	return sTmp
end

function SaveToFile(file , table , tablename)
	local handle = io.open(file,"w+")
	handle:write(Serialize(table, tablename))
	handle:flush()
	handle:close()
	collectgarbage(gc)
end
  This is the script i used to use for ptokax 0.3.6.0

and when i converted that i got


-- This script is converted with PtokaX LUA API Converter v0.9 at 01/14/09 23:20:39
--[[
	Message Board 1.07	10/20/04 LUA 5 .0/5.1
	converted to LUA 5 - 09/15/05
	by Mutor

	Provides common message board. Allow users to read/write the board by profiles
	Option to delete messages, permission bt profile
	Caches board messages to exteernal text file for script/hub restarts

	+Changes from v 1.00    By Mutor
		+Added  case sensitive commands, request by NeoUltimicia
		+Added  date/time to message, request by NeoUltimicia
		+Errors now sent to PM as well as main
		+Corrected save string and tweaked table read
	+Changes from v 1.01
		+converted to LUA 5	By blackwings
		+these frmHub:GetPrefixes(1)es can be used = !+?$# - by blackwings
	+Changes from v 1.02
		+fixed a load file bug - by blackwings
	+Changes from v 1.03 	By Madman
		+fixed file handling bug
		+fixed left over lua4 parts
		-removed VaildCmd stuff
		+changed MsgBoard function to ToArrival
		+fixed prefix error
		+added auto detect if bot has hubbotname
		+fixed some minor bugs
		+added support for mainchat
		+fixed extra linespacing
	+Changes from v 1.03	By Mutor
		+LUA 5.02 / 5.1x compatible
		+Added readby & help commands and rbprofile table	 Requested by cynicist8
		+Changed Chat and To Arrivals
		+Added context menu [right click]
		+Added create messages file if non existant
		-Removed MsgBoard function
		~Broke out tCmds to a global var
	+Changes from v 1.05	By Mutor        09/24/06
		+Added respond in PM only       Request by speedX
		+Added delete own message command
		+Moved all globals vars to config table
		-Dropped loadfile function
		+Changed load file code and moved to Main
		+Added status / error messages [Sent to OpNick]
		+Added more garbage collection
		+Many textual changes
	+Changes from v 1.06	By Mutor        10/04/06
		+Added find word [case insensitive] in message       swapy2006
		+Added SearchProf table
		+A few optimizations
		
]]

--User Settings-------------------------------------------------------------------------------------
MsgCfg = {
-- Hub name, pulled from the Px
Hub = SetMan.GetString(0),
-- Botname, use frmHub:GetHubBotName() or "BotName"
Bot = SetMan.GetString(21),
-- Admins nick for status / error messages
OpNick = "Mutor",
--Reply in private message only  ["on"/"off"]
PmOnly = "on",
-- Script Command, read board
Read = string.lower("dumps"),
-- Script Command, write to board
Write = string.lower("dump"),
-- Script Command, delete messages
Delete = string.lower("deldump"),
-- Script Command, read messages by...
ReadBy = string.lower("wrotedump"),
-- Script Command, script command help
DeleteMine = string.lower("delmydump"),
-- Script Command, read messages by...
Search = string.lower("searchdump"),
-- Script Command, script command help
Help = string.lower("msghelp"),
-- Max number of messages to cache
MaxMsg = 500,
-- Message file.
MsgFile = "dumper.txt",
-- Which profiles may read the board?
ReadProf = {[0]=1,[1]=1,[2]=1,[3]=1,[4]=1,[5]=1,[-1]=1},
-- Which profiles may write to the board?
WriteProf = {[0]=1,[1]=1,[2]=1,[3]=1,[4]=1,[5]=1,[-1]=1},
-- Which profiles may delete messages?
DelProf = {[0]=1,[1]=0,[2]=0,[3]=1,[4]=1,[5]=1,[-1]=1},
-- Which profiles may read messages from specified user?
ReadByProf = {[0]=1,[1]=1,[2]=1,[3]=1,[4]=1,[5]=1,[-1]=0},
-- Which profiles may search messages for specified string?
SearchProf = {[0]=1,[1]=1,[2]=1,[3]=1,[4]=1,[5]=1,[-1]=0},
-- Which profiles receive command menu(s)?
CmdProf = {[0]=1,[1]=1,[2]=1,[3]=1,[4]=1,[5]=1,[-1]=1},
-- Name for command Menu, pulled from Hub
Menu = SetMan.GetString(0),

}
--End User Settings----------------------------------------------------------------------------------

BoardMessages = {}

function OnStartup()
	gc,no,pat = nil,table.getn,string.gfind
	if _VERSION == "Lua 5.1" then
		gc,no,pat = "collect",table.maxn,string.gmatch
	end
	if loadfile(MsgCfg.MsgFile) then
		dofile(MsgCfg.MsgFile)
	else
		local handle,err = io.open(MsgCfg.MsgFile,"w")
		handle:write("BoardMessages = {}")
		handle:close()
	end
	if not (MsgCfg.Bot == SetMan.GetString(21)) then
		Core.RegBot(MsgCfg.Bot,"","",true)
	end
	collectgarbage(gc)
	OnError("Message Board 1.07 for ".._VERSION.." by Mutor has been started. Memory Used: "..collectgarbage(count).." Kb.")
end

OnExit = function()
	OnError("Message Board 1.07 for ".._VERSION.." by Mutor has been stopped.")
end

OnError = function(msg)
	Core.SendToNick(MsgCfg.OpNick,"<"..MsgCfg.Bot.."> "..msg)
end

function NewUserConnected(user, data)
	if MsgCfg.CmdProf[user.iProfile] and MsgCfg.CmdProf[user.iProfile]==1 then
		SendMsgCmds(user)
		local prof = (ProfMan.GetProfile(user.iProfile) and ProfMan.GetProfile(user.iProfile).sProfileName)
		
		Core.SendToNick(user.sNick,"<"..MsgCfg.Bot.."> "..msg)
	end
end
OpConnected = UserConnected

ChatArrival = function(user,data)
	Core.GetUserAllData(user)
	data = string.sub(data,1, -2)
	if MsgCfg.CmdProf[user.iProfile] and MsgCfg.CmdProf[user.iProfile]==1 then
		local s,e,to = string.find(data,"^$To:%s(%S+)%sFrom:")
		local s,e,cmd = string.find( data, "%b<>%s%p(%w+)")
		if cmd and tCmds[cmd] then
			if to and to == MsgCfg.Bot or MsgCfg.PmOnly == "on" then
				return Core.SendPmToNick(user.sNick,MsgCfg.Bot,tCmds[cmd](user,data)),0
			else
				return Core.SendToNick(user.sNick,"<"..MsgCfg.Bot.."> "..tCmds[cmd](user,data)),0
			end
			collectgarbage(gc)
		end
	end
end
ToArrival = ChatArrival

tCmds = {
	[MsgCfg.Read] = function(user, data)
		if user then
			if MsgCfg.ReadProf[user.iProfile] and MsgCfg.ReadProf[user.iProfile]==1 then
				return ReadBoard(user,nil,nil)
			end
		else
			return "Read BoardMessages","",""
		end
	end,
	[MsgCfg.Write] = function(user, data)
		if user then
			if MsgCfg.WriteProf[user.iProfile] and MsgCfg.WriteProf[user.iProfile]==1 then
				local s,e,msg = string.find(data, "%b<>%s+%S+%s(.*)")
				if msg == nil then
					local dsp = "\r\n\t=-=<>"..string.rep("=-",21).."=<>=-=\r\n"..
					"\t"..MsgCfg.Hub.."\tDump Board\r\n"..
					"\tDid you forget what you were going to say?\r\n"..
function getcmdprefixarray() local p = {} for i=1,#SetMan.GetString(29) do table.insert(p,SetMan.GetString(29):sub(i,i)) end end
					"\tCommand syntax is ->> "..getcmdprefixarray()[1]..MsgCfg.Write.." \r\n"..
					"\t=-=<>"..string.rep("=-",21).."=<>=-=\r\n"
					return dsp
				else
					return Write2Board(user, msg)
				end
			end
		else
			return "Write BoardMessages"," %[line:Message]"," %[line:Message]"
		end
	end,
	[MsgCfg.Delete] = function(user, data)
		if user then
			if MsgCfg.DelProf[user.iProfile] and MsgCfg.DelProf[user.iProfile]==1 then
				local s,e,delmsg = string.find(data, "%b<>%s%S+%s(%d+)")
				if (delmsg == nil) then
					local dsp = "\r\n\t=-=<>"..string.rep("=-",21).."=<>=-=\r\n"..
					"\t"..MsgCfg.Hub.."\tDumps Board\r\n"..
					"\tDelete which message? Provide message number\r\n"..
function getcmdprefixarray() local p = {} for i=1,#SetMan.GetString(29) do table.insert(p,SetMan.GetString(29):sub(i,i)) end end
					"\tCommand syntax is ->> "..getcmdprefixarray()[1]..MsgCfg.Delete..
function getcmdprefixarray() local p = {} for i=1,#SetMan.GetString(29) do table.insert(p,SetMan.GetString(29):sub(i,i)) end end
					" <msg#>\r\n\tType ->> "..getcmdprefixarray()[1]..MsgCfg.Read..
					"  to list messages \r\n\t=-=<>"..string.rep("=-",21).."=<>=-=\r\n"
					return dsp
				else
					table.remove(BoardMessages, delmsg)
					SaveToFile(MsgCfg.MsgFile , BoardMessages , "BoardMessages")
					Core.SendToNick(user.sNick,"<"..MsgCfg.Bot.."> Message number [ "..delmsg.." ] has been deleted.")
					return dsp
				end
			end
		else
			return "Delete BoardMessages"," %[line:Message Number]"," %[line:Message Number]"
		end
	end,
	
	[MsgCfg.ReadBy] = function(user, data)
		if user then
			if MsgCfg.ReadByProf[user.iProfile] and MsgCfg.ReadByProf[user.iProfile]==1 then
			local s,e,nick = string.find(data, "%b<>%s%S+%s(%S+)")
				if nick then
					return ReadBoard(user,nick,nil)
				else
					return "Sorry "..user.sNick..", you must "..
function getcmdprefixarray() local p = {} for i=1,#SetMan.GetString(29) do table.insert(p,SetMan.GetString(29):sub(i,i)) end end
					"specify a nick. Usage: "..getcmdprefixarray()[1]..MsgCfg.ReadBy.." <nick>"
				end
			end
		else
			return "Read BoardMessages From <nick>"," %[line:NickName]"," %[line:NickName]"
		end
	end,
	[MsgCfg.Search] = function(user, data)
		if user then
			if MsgCfg.SearchProf[user.iProfile] and MsgCfg.SearchProf[user.iProfile]==1 then
			local s,e,query = string.find(data, "%b<>%s%S+%s(%S+)")
				if query then
					return ReadBoard(user,nil,query)
				else
					return "Sorry "..user.sNick..", you must specify a query string. "..
function getcmdprefixarray() local p = {} for i=1,#SetMan.GetString(29) do table.insert(p,SetMan.GetString(29):sub(i,i)) end end
					"Usage: "..getcmdprefixarray()[1]..MsgCfg.Search.." <string>"
				end
			end
		else
			return "Search BoardMessages For <String>"," %[line:Search String]"," %[line:Search String]"
		end
	end,
	[MsgCfg.Help] = function(user,data)
		if user then
			local reply = "Dumps Board Help\r\n\r\n\tCommand\t\tDescription\r\n"..
			"\t"..string.rep("?",40).."\r\n"
			for i,v in pairs(tCmds) do
				local desc,args = tCmds[i]()
				reply = reply.."\t+"..string.format("%-15s",i).."\t"..desc.."\r\n"
			end
			return reply.."\n\t"..string.rep("?",40).."\r\n\r\n"
		else
			return "Message Board Help","",""
		end
	end,
}

SendMsgCmds = function(user)
	for i,v in pairs(tCmds) do
		local desc,arg1,arg2 = tCmds[i]()
		
		
	end
	collectgarbage(gc)
end

function ReadBoard(user,nick,query)
	local n,x = no(BoardMessages) or 0,""
	local dsp = "\r\n=-=<>"..string.rep("=-",60).."=<>=-=\r\n"..
	"  "..MsgCfg.Hub.."\tDumps Board\t Displayng last [ "..n.." ] message(s)"..string.char(126).."\r\n"..
	"=-=<>"..string.rep("=-",60).."=<>=-=\r\n\r\n"
	if n > 0 then
		if nick then
			dsp = string.gsub(dsp,string.char(126)," from "..nick)
			local count = 0
			for i,v in ipairs(BoardMessages) do
				local s,e,usr = string.find(v,"%[%s(%S+)%s%]%swrote%:")
				if usr and usr == nick then
					count = count + 1
					dsp = dsp.." [ "..i.." ]\t"..BoardMessages[i]..""
				end
			end
			dsp = string.gsub(dsp,n,count)
			if count == 0 then
				dsp = dsp.."\r\nSorry "..user.sNick..", there are no messages from "..nick.."."
			end
			return dsp
		elseif query then
			query = string.lower(query)
			dsp = string.gsub(dsp,string.char(126)," containing the string ' "..query.." '")
			local count = 0
			for i,v in ipairs(BoardMessages) do
				for str in pat(v,"(%S+)") do
					if string.lower(str) == query then
						count = count + 1
						dsp = dsp.." [ "..i.." ]"..BoardMessages[i]..""
					end
				end
			end
			dsp = string.gsub(dsp,n,count)
			if count == 0 then
				dsp = dsp.."\r\nSorry "..user.sNick..", there are no messages containing "..
				"the string "..query.."."
			end
			return dsp
		else
			dsp = string.gsub(dsp,string.char(126),x)
			for i,v in ipairs(BoardMessages) do
				dsp = dsp.." [ "..i.." ]\t"..BoardMessages[i].."\r"
			end
			return dsp
		end
	else
		dsp = dsp.."\r\nSorry "..user.sNick..", the message board is empty."
		return dsp
	end
	collectgarbage(gc)
end

function Write2Board(user, msg)
	local dsp = ""..string.rep("=-",0)..""..
	""..user.sNick.."'s message was added."..
	""..string.rep("=-",0)..""..
function getcmdprefixarray() local p = {} for i=1,#SetMan.GetString(29) do table.insert(p,SetMan.GetString(29):sub(i,i)) end end
	"Type "..getcmdprefixarray()[1]..MsgCfg.Read.." in main/pm to list or "..getcmdprefixarray()[1]..
	MsgCfg.Write.." to post."..
	""..string.rep("=-",0)..""
	Core.SendToAll("<"..MsgCfg.Bot.."> ".. dsp)
	table.insert(BoardMessages, (""..os.date("%B %d %Y %X ").." [ "..user.sNick.." ]  : ")..msg)
	if no(BoardMessages) > MsgCfg.MaxMsg then
		table.remove(BoardMessages, 1)
	end
	SaveToFile(MsgCfg.MsgFile , BoardMessages , "BoardMessages")
	collectgarbage(gc)
end

function Serialize(tTable, sTableName, sTab)
	assert(tTable, "tTable equals nil")
	assert(sTableName, "sTableName equals nil")
	assert(type(tTable) == "table", "tTable must be a table!")
	assert(type(sTableName) == "string", "sTableName must be a string!")
	sTab = sTab or ""
	sTmp = ""
	sTmp = sTmp..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
			sTmp = sTmp..Serialize(value, sKey, sTab.."\t")
		else
			local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value)
			sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
		end
		sTmp = sTmp..",\n"
	end
	sTmp = sTmp..sTab.."}"
	return sTmp
end

function SaveToFile(file , table , tablename)
	local handle = io.open(file,"w+")
	handle:write(Serialize(table, tablename))
	handle:flush()
	handle:close()
	collectgarbage(gc)
end

RegConnected = UserConnected


And when i used it i got this error 
[22:53] Syntax D:\My Own Made Hub\scripts\dumps_newapi.lua:176: '(' expected near 'getcmdprefixarray'

Can any 1 please help me to fix this

CrazyGuy

#1
Looks like you accidently copied/pasted that line a couple of times.  ;D
The reason you get a syntax error is because it's written inside a function.
Move that line to the end of the script, then remove it from the following lines:

  • line 176
  • line 196
  • line 198
  • line 222
  • line 238
  • line 327

Mind you the line numbers will change when you remove it at above locations. Start therefor at the bottom of the list.

Edit: I just saw you used the API Converter. Clearly the problem with these lines is caused by a bug in the Converter. There are also other known shortcomings and problems with that converter. I'd advise to convert manually.

patrick

Thanx For the help guys  :)

?StIfFLEr??

Patrick better learn fast.

patrick

CrazyGuy i said as u did but still im getting 1 problem
when i use +dumps to read dumps it works perfectly
but i aint able to dump anything can sm1 help me  ???

?StIfFLEr??

I think u should ask permission from Mutor.
And edit his Message board Script [API2]
If he allows in this forum for me to post the edited script which is originally his script then i can post or else even i cant help you.

CrazyGuy

patrick : As Mutor said, the script is already converted and updated.
You can download it here

Closing this topic..

SMF spam blocked by CleanTalk