Message Board for Ptokax 3.3.21 +
 

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

Message Board for Ptokax 3.3.21 +

Started by effgjamis, 15 September, 2005, 22:52:29

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

effgjamis

Hello to all the Guru's,

I have a need, as I am switching from the OLD NMDC to Ptokax 3.3.21 hub, I have ( vb script ) from Gadget ( bullettin board ) which I have used for a long long time. )

I found a LUA script that I think will work simiular but, it gives me an error "  [15:10] Syntax [string "--
..."]:23: attempt to call global `strlower' (a nil value) "

the heading part of the script is as follows:)

--Message Board 1.01   10/20/04
--
--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.

-------------------------------------------------

I can provide the entire script if neccessary..

----------

If someone has a script which will provide a global read/write -- authorized message removal/delete which those who are not online/offline can read/write/post would be greatly appreciated...

Thank you in advance...

<<<--- Eff --->>>
Curious Mind would like to know..

blackwings

#1
I have converted the script to lua 5 for you + changed so that several different prefixes can be used with the commands =
--Message Board 1.02	10/20/04 LUA 5
--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
--		+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 prefixes can be used = !+?$# by blackwings
--
--	?To Do
--		?Allow users to delete their own messages
--		?Add context menu
--
--User Settings-------------------------------------------------------------------------------------
Comm1 = string.lower("read")			-- Script Command, read board
Comm2 = string.lower("write")			-- Script Command, write to board
Comm3 = string.lower("del")			-- Script Command, delete messages
MaxMessages = 50		-- Max number of messages to cache
MsgBoard = "MessageBoard.txt"	-- Message file, creat this file in your scripts dir.
rprofiles = {[0]=1,[1]=1,[2]=1} 	-- Which profiles may read the board? 
wprofiles = {[0]=1,[1]=1,[2]=1} 	-- Which profiles may write to the board?
dprofiles = {[0]=1,[1]=1,[2]=1} 	-- Which profiles may delete messages?
Hub = frmHub:GetHubName()	-- Hub name, pulled from the Px
Bot = frmHub:GetHubBotName()	-- Uncomment frmHub:RegBot(Bot)in function Main for custom name
--End User Settings---------------------------------------------------------------------------------- 
BoardMessages = {}

function Main()
	LoadFromFile(MsgBoard)
	--frmHub:RegBot(Bot)	-- Uncomment for custom name
	local cPrefix = "!+?$#"
	frmHub:SetPrefixes(cPrefix)	
end

function ToArrival(user,data)
	local s,e,whoTo,from,cmd = string.find(data, "%$To:%s(%S+)%sFrom:%s(%S+)%s%$%b<>%s+(%S+).*|")
	if whoTo == Bot then
		return MsgBoard(user,cmd)
	end
end

function MsgBoard(user,cmd)
	s,e,cmd = string.find(data, "%b<>%s+(%S+)")
	if IfValidCMD(cmd, "Comm1") and rprofiles[user.iProfile]==1 then
		ReadBoard(user)
		return 1
	elseif IfValidCMD(cmd, "Comm2") and wprofiles[user.iProfile]==1 then
		s,e,msg = string.find(data, "%b<>%s+%S+%s(.*)")
			if msg == nil then
				local dsp
				dsp = "\r\n\t=-=<>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=<>=-=\r\n"
				dsp = dsp.."\t"..Hub.."\tMessage Board\r\n"
				dsp = dsp.."\tDid you forget what you were going to say?\r\n"
				dsp = dsp.."\tCommand syntax is ->> "..Prefix..Comm2.." \r\n"
				dsp = dsp.."\t=-=<>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=<>=-=\r\n"
				user:SendData(Bot,dsp)
				SendPmToNick(user.sName,Bot,dsp)
				return 1
			else
				Write2Board(user, msg)
				return 1
			end
	elseif IfValidCMD(cmd, "Comm3") and dprofiles[user.iProfile]==1 then
		s,e,delmsg = string.find(data, "%b<>%s+%S+%s(%d+)")
		if delmsg == nil or BoardMessages[delmsg] == nil then
			local dsp0
			dsp0 = "\r\n\t=-=<>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=<>=-=\r\n"
			dsp0 = dsp0.."\t"..Hub.."\tMessage Board\r\n"
			dsp0 = dsp0.."\tDelete which message? Provide message number\r\n"
			dsp0 = dsp0.."\tCommand syntax is ->> "..Prefix..Comm3.." \r\n"
			dsp0 = dsp0.."\tType ->> "..Prefix..Comm1.."  to list messages \r\n"
			dsp0 = dsp0.."\t=-=<>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=<>=-=\r\n"
			user:SendData(Bot,dsp0)
			SendPmToNick(user.sName,Bot,dsp0)
			return 1
		else
			--if BoardMessages[delmsg] ~= 1 then user:SendData(Bot,dsp0) return 1 end
			tremove(BoardMessages, delmsg)
			SaveToFile(MsgBoard , BoardMessages , "BoardMessages")
			user:SendData(Bot,"Message number [ "..delmsg.." ] has been deleted.")
			SendPmToNick(user.sName,Bot,"Message number [ "..delmsg.." ] has been deleted.")
			return 1
		end
	end
end

function ReadBoard(user)
	local n = getn(BoardMessages)
	local dsp1
	dsp1 = "\r\n=-=<>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=<>=-=\r\n"
	dsp1 = dsp1.."  "..Hub.."\tMessage Board\t Displayng last [ "..n.." ] message(s)\r\n"
	dsp1 = dsp1.."=-=<>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=<>=-=\r\n\r\n"
		for i = 1, n do
			BoardMessages[i] = gsub(BoardMessages[i],"\n","\r\n\t") 
			BoardMessages[i] = gsub(BoardMessages[i],"wrote::","wrote::\r\n\t")
			dsp1 = dsp1.."\r\n[ "..i.." ]\t"..BoardMessages[i].."\r\n\r\n"
		end
		SendPmToNick(user.sName, Bot, dsp1) 
end

function Write2Board(user, msg)
	local dsp2
	dsp2 = "\r\n\t=-=<>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=<>=-=\r\n"
	dsp2 = dsp2.."\t[ "..user.sName.." ] just posted to the "..Hub.." Message Board\r\n"
	dsp2 = dsp2.."\t=-=<>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=<>=-=\r\n"
	dsp2 = dsp2.."\tType "..Prefix..Comm1.." in main/pm to list or "..Prefix..Comm2.."  to post .\r\n"
	dsp2 = dsp2.."\t=-=<>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=<>=-=\r\n\r\n"
	SendToAll(Bot, dsp2) 
	tinsert(BoardMessages, ("On "..os.date("%B %d %Y %X ").." [ "..user.sName.." ] wrote::")..msg)
		if getn(BoardMessages) > MaxMessages then tremove(BoardMessages, 1) end
		SaveToFile(MsgBoard , BoardMessages , "BoardMessages")
	end

function Serialize(tTable, sTableName, sTab)--Fixed
	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 tTable do
		local sKey = (type(key) == "string") and format("[%q]",key) or format("[%d]",key);
			if(type(value) == "table") then
				sTmp = sTmp..Serialize(value, sKey, sTab.."\t"); -- The Bug was here
			else
				local sValue = (type(value) == "string") and format("%q",value) or tostring(value);
				sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
			end
				sTmp = sTmp..",\n"
			end
	sTmp = sTmp..sTab.."}\r\n"
	return sTmp
end

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

function LoadFromFile(file)
local sTmp = ""    
    for line in io.lines(file) do
        sTmp = sTmp..line.."\r\n"
    end
    return sTmp
end

tPrefix = frmHub:GetPrefixes()

function IfValidCMD(sIsCMD, sWhatCMD)
	for sIndex in tPrefix do
		if sIsCMD == (tPrefix[sIndex]..sWhatCMD) then
			return 1
		end
	end
end


Jitway

Great script there. Should come in handy.
It\'s not what you say but how you get your point across!

effgjamis

QuoteOriginally posted by blackwings
I have converted the script to lua 5 for you

WOW... I would have never thought I would get such a quick reply... my thanks.......  however, :(   I have a small problem..

I get the following error:

  "SyntaxC:\Ptokax2scripts\MessageBoardBlkWing.lua:153: bad argument #1 to `lines' (string expected, got function) "

When I restart the scripts.. but when I do a syntax check, no errors are shown.

I am using Ptokax 3.3.21 ,, with no bot, was running Terminator 5, but stopped it to test this script.

Also, The bot ( message board ) does not seem to register in the user list of the client.

I would like it's bot name to be " NewsPaper" as registered in the Client.. I am using "PeerWeb DC++ 3.01 "  as the DC client.

MY many many thanks to you for your assistants you have no idea how much I appreciate this effort..
<<<--- Eff --->>>
Curious Mind would like to know..

blackwings

try this =
--Message Board 1.03	10/20/04 LUA 5
--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
--		+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 prefixes can be used = !+?$# - by blackwings
--	+Changes from v 1.02
--		+fixed a load file bug - by blackwings
--
--	?To Do
--		?Allow users to delete their own messages
--		?Add context menu
--
--User Settings-------------------------------------------------------------------------------------
Comm1 = string.lower("read")			-- Script Command, read board
Comm2 = string.lower("write")			-- Script Command, write to board
Comm3 = string.lower("del")			-- Script Command, delete messages
MaxMessages = 50		-- Max number of messages to cache
MsgBoard = "MessageBoard.txt"	-- Message file, creat this file in your scripts dir.
rprofiles = {[0]=1,[1]=1,[2]=1} 	-- Which profiles may read the board? 
wprofiles = {[0]=1,[1]=1,[2]=1} 	-- Which profiles may write to the board?
dprofiles = {[0]=1,[1]=1,[2]=1} 	-- Which profiles may delete messages?
Hub = frmHub:GetHubName()	-- Hub name, pulled from the Px
Bot = frmHub:GetHubBotName()	-- Uncomment frmHub:RegBot(Bot)in function Main for custom name
--End User Settings---------------------------------------------------------------------------------- 
BoardMessages = {}

function Main()
	LoadFromFile(MsgBoard)
	--frmHub:RegBot(Bot)	-- Uncomment for custom name
	local cPrefix = "!+?$#"
	frmHub:SetPrefixes(cPrefix)	
end

function ToArrival(user,data)
	local s,e,whoTo,from,cmd = string.find(data, "%$To:%s(%S+)%sFrom:%s(%S+)%s%$%b<>%s+(%S+).*|")
	if whoTo == Bot then
		return MsgBoard(user,cmd)
	end
end

function MsgBoard(user,cmd)
	s,e,cmd = string.find(data, "%b<>%s+(%S+)")
	if IfValidCMD(cmd, "Comm1") and rprofiles[user.iProfile]==1 then
		ReadBoard(user)
		return 1
	elseif IfValidCMD(cmd, "Comm2") and wprofiles[user.iProfile]==1 then
		s,e,msg = string.find(data, "%b<>%s+%S+%s(.*)")
			if msg == nil then
				local dsp
				dsp = "\r\n\t=-=<>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=<>=-=\r\n"
				dsp = dsp.."\t"..Hub.."\tMessage Board\r\n"
				dsp = dsp.."\tDid you forget what you were going to say?\r\n"
				dsp = dsp.."\tCommand syntax is ->> "..Prefix..Comm2.." \r\n"
				dsp = dsp.."\t=-=<>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=<>=-=\r\n"
				user:SendData(Bot,dsp)
				SendPmToNick(user.sName,Bot,dsp)
				return 1
			else
				Write2Board(user, msg)
				return 1
			end
	elseif IfValidCMD(cmd, "Comm3") and dprofiles[user.iProfile]==1 then
		s,e,delmsg = string.find(data, "%b<>%s+%S+%s(%d+)")
		if delmsg == nil or BoardMessages[delmsg] == nil then
			local dsp0
			dsp0 = "\r\n\t=-=<>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=<>=-=\r\n"
			dsp0 = dsp0.."\t"..Hub.."\tMessage Board\r\n"
			dsp0 = dsp0.."\tDelete which message? Provide message number\r\n"
			dsp0 = dsp0.."\tCommand syntax is ->> "..Prefix..Comm3.." \r\n"
			dsp0 = dsp0.."\tType ->> "..Prefix..Comm1.."  to list messages \r\n"
			dsp0 = dsp0.."\t=-=<>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=<>=-=\r\n"
			user:SendData(Bot,dsp0)
			SendPmToNick(user.sName,Bot,dsp0)
			return 1
		else
			--if BoardMessages[delmsg] ~= 1 then user:SendData(Bot,dsp0) return 1 end
			tremove(BoardMessages, delmsg)
			SaveToFile(MsgBoard , BoardMessages , "BoardMessages")
			user:SendData(Bot,"Message number [ "..delmsg.." ] has been deleted.")
			SendPmToNick(user.sName,Bot,"Message number [ "..delmsg.." ] has been deleted.")
			return 1
		end
	end
end

function ReadBoard(user)
	local n = getn(BoardMessages)
	local dsp1
	dsp1 = "\r\n=-=<>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=<>=-=\r\n"
	dsp1 = dsp1.."  "..Hub.."\tMessage Board\t Displayng last [ "..n.." ] message(s)\r\n"
	dsp1 = dsp1.."=-=<>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=<>=-=\r\n\r\n"
		for i = 1, n do
			BoardMessages[i] = gsub(BoardMessages[i],"\n","\r\n\t") 
			BoardMessages[i] = gsub(BoardMessages[i],"wrote::","wrote::\r\n\t")
			dsp1 = dsp1.."\r\n[ "..i.." ]\t"..BoardMessages[i].."\r\n\r\n"
		end
		SendPmToNick(user.sName, Bot, dsp1) 
end

function Write2Board(user, msg)
	local dsp2
	dsp2 = "\r\n\t=-=<>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=<>=-=\r\n"
	dsp2 = dsp2.."\t[ "..user.sName.." ] just posted to the "..Hub.." Message Board\r\n"
	dsp2 = dsp2.."\t=-=<>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=<>=-=\r\n"
	dsp2 = dsp2.."\tType "..Prefix..Comm1.." in main/pm to list or "..Prefix..Comm2.."  to post .\r\n"
	dsp2 = dsp2.."\t=-=<>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=<>=-=\r\n\r\n"
	SendToAll(Bot, dsp2) 
	tinsert(BoardMessages, ("On "..os.date("%B %d %Y %X ").." [ "..user.sName.." ] wrote::")..msg)
		if getn(BoardMessages) > MaxMessages then tremove(BoardMessages, 1) end
		SaveToFile(MsgBoard , BoardMessages , "BoardMessages")
	end

function Serialize(tTable, sTableName, sTab)--Fixed
	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 tTable do
		local sKey = (type(key) == "string") and format("[%q]",key) or format("[%d]",key);
			if(type(value) == "table") then
				sTmp = sTmp..Serialize(value, sKey, sTab.."\t"); -- The Bug was here
			else
				local sValue = (type(value) == "string") and format("%q",value) or tostring(value);
				sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
			end
				sTmp = sTmp..",\n"
			end
	sTmp = sTmp..sTab.."}\r\n"
	return sTmp
end

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

function LoadFromFile(file) 
	local handle = io.open(file,"r") 
	if (handle ~= nil) then 
		dofile(file)
		handle:flush() 
		handle:close()
        end 
end 

tPrefix = frmHub:GetPrefixes()

function IfValidCMD(sIsCMD, sWhatCMD)
	for sIndex in tPrefix do
		if sIsCMD == (tPrefix[sIndex]..sWhatCMD) then
			return 1
		end
	end
end


kunal

[15:07] Syntax C:\ptokax0.3.3.21\scripts\msgboard.lua:154: bad argument #1 to `open' (string expected, got function)

blackwings

kunal, have you created the file MessageBoard.txt in Scripts?

If you have, try to test to change the current LoadFromFile to one of these and see if the bug disappear.
If you find that one of them doesn't give you the bug, post which one it was here.

Code =
function LoadFromFile(file) 
	local handle = io.open(file) 
	if handle then 
		dofile(file)
		handle:flush() 
		handle:close()
        end 
end 

function LoadFromFile(file) 
	local handle = io.open(file,"r") 
	if handle then 
		dofile(file)
		handle:flush() 
		handle:close()
        end 
end 

function LoadFromFile(file) 
	local handle = io.open(file) 
	if (handle ~= nil) then 
		dofile(file)
		handle:flush() 
		handle:close()
        end 
end


kunal

tried all three.
but none seems to work
get this error
[16:06] Syntax C:\ptokax0.3.3.21\scripts\msgboard.lua:154: bad argument #1 to `open' (string expected, got function)

Madman

#8
--Message Board 1.03	10/20/04 LUA 5
--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
--		+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 prefixes can be used = !+?$# - by blackwings
--	+Changes from v 1.02
--		+fixed a load file bug - by blackwings
--	+Changes from v 1.03
--		+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
--		^ Moded by Madman ^
--	?To Do
--		?Allow users to delete their own messages
--		?Add context menu
--
--User Settings-------------------------------------------------------------------------------------
Comm1 = string.lower("read")			-- Script Command, read board
Comm2 = string.lower("write")			-- Script Command, write to board
Comm3 = string.lower("del")			-- Script Command, delete messages
MaxMessages = 50		-- Max number of messages to cache
MsgBoardFile = "MessageBoard.txt"	-- Message file, creat this file in your scripts dir.
rprofiles = {[0]=1,[1]=1,[2]=1,[3]=1,[-1]=1}  	-- Which profiles may read the board?
wprofiles = {[0]=1,[1]=1,[2]=1,[3]=1,[-1]=1}  	-- Which profiles may write to the board?
dprofiles = {[0]=1,[1]=1,[2]=1} 	-- Which profiles may delete messages?
Hub = frmHub:GetHubName()	-- Hub name, pulled from the Px
Bot = frmHub:GetHubBotName()	-- Botname, use frmHub:GetHubBotName() or "BotName"
--End User Settings----------------------------------------------------------------------------------
BoardMessages = {}

function Main()
	LoadFromFile(MsgBoardFile)
	if not (Bot == frmHub:GetHubBotName()) then
		frmHub:RegBot(Bot)
	end
end

function ToArrival(user,data)
	local s,e,whoTo = string.find(data, "%$To:%s(%S+)")
	if whoTo == Bot then
		return MsgBoard(user, data)
	end
end

function ChatArrival(user, data)
	return MsgBoard(user, data)
end

function MsgBoard(user, data)
	local data = string.sub(data,1, -2)
	local s,e,cmd = string.find(data, "%b<>%s+[%!%+%?%$%#](%S+)")
	if cmd then
		s,e,Prefix = string.find(data, "%b<>%s+(%p)%S+")
		local tCmds = {
			[Comm1] = function(user, data)
				if rprofiles[user.iProfile]==1 then
					ReadBoard(user) return 1
				end
			end,
			[Comm2] = function(user, data)
				if wprofiles[user.iProfile]==1 then
					local s,e,msg = string.find(data, "%b<>%s+%S+%s(.*)")
					if msg == nil then
						local dsp
						dsp = "\r\n\t=-=<>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=<>=-=\r\n"
						dsp = dsp.."\t"..Hub.."\tMessage Board\r\n"
						dsp = dsp.."\tDid you forget what you were going to say?\r\n"
						dsp = dsp.."\tCommand syntax is ->> "..Prefix..Comm2.." \r\n"
						dsp = dsp.."\t=-=<>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=<>=-=\r\n"
						user:SendData(Bot,dsp)
						SendPmToNick(user.sName,Bot,dsp)
						return 1
					else
						Write2Board(user, msg)
						return 1
					end
				end
			end,
			[Comm3] = function(user, data)
				if dprofiles[user.iProfile]==1 then
					local s,e,delmsg = string.find(data, "%b<>%s+%S+%s+(%d+)")
					if (delmsg == nil) then
						local dsp0
						dsp0 = "\r\n\t=-=<>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=<>=-=\r\n"
						dsp0 = dsp0.."\t"..Hub.."\tMessage Board\r\n"
						dsp0 = dsp0.."\tDelete which message? Provide message number\r\n"
						dsp0 = dsp0.."\tCommand syntax is ->> "..Prefix..Comm3.." \r\n"
						dsp0 = dsp0.."\tType ->> "..Prefix..Comm1.."  to list messages \r\n"
						dsp0 = dsp0.."\t=-=<>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=<>=-=\r\n"
						user:SendData(Bot,dsp0)
						SendPmToNick(user.sName,Bot,dsp0)
						return 1
					else
						--if BoardMessages[delmsg] ~= 1 then user:SendData(Bot,dsp0) return 1 end
						table.remove(BoardMessages, delmsg)
						SaveToFile(MsgBoardFile , BoardMessages , "BoardMessages")
						user:SendData(Bot,"Message number [ "..delmsg.." ] has been deleted.")
						SendPmToNick(user.sName,Bot,"Message number [ "..delmsg.." ] has been deleted.")
						return 1
					end
				end
			end,
		}
		if tCmds[cmd] then
			return tCmds[cmd](user, data)
		end
	end
end

function ReadBoard(user)
	local n = table.getn(BoardMessages)
	local dsp1
	dsp1 = "\r\n=-=<>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=<>=-=\r\n"
	dsp1 = dsp1.."  "..Hub.."\tMessage Board\t Displayng last [ "..n.." ] message(s)\r\n"
	dsp1 = dsp1.."=-=<>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=<>=-=\r\n\r\n"
		for i = 1, n do
			dsp1 = dsp1.."\r\n[ "..i.." ]\t"..BoardMessages[i].."\r\n\r\n"
		end
		SendPmToNick(user.sName, Bot, dsp1)
end

function Write2Board(user, msg)
	local dsp2
	dsp2 = "\r\n\t=-=<>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=<>=-=\r\n"
	dsp2 = dsp2.."\t[ "..user.sName.." ] just posted to the "..Hub.." Message Board\r\n"
	dsp2 = dsp2.."\t=-=<>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=<>=-=\r\n"
	dsp2 = dsp2.."\tType "..Prefix..Comm1.." in main/pm to list or "..Prefix..Comm2.."  to post .\r\n"
	dsp2 = dsp2.."\t=-=<>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=<>=-=\r\n\r\n"
	SendToAll(Bot, dsp2)
	table.insert(BoardMessages, ("On "..os.date("%B %d %Y %X ").." [ "..user.sName.." ] wrote: ")..msg)
		if table.getn(BoardMessages) > MaxMessages then table.remove(BoardMessages, 1) end
		SaveToFile(MsgBoardFile , BoardMessages , "BoardMessages")
	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 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()
end

function LoadFromFile(file)
	local handle = io.open(file,"r")
	if (handle ~= nil) then
		dofile(file)
		handle:flush()
		handle:close()
	end
end

Give this a try..

Blackwings
The problem was that you hade
MsgBoard = "MessageBoard.txt"
LoadFromFile(MsgBoard)
function MsgBoard(user,cmd)
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

kunal

madman ur script doesnt give any error but when i try any cmds they dont work

effgjamis

Hello all..

I have loaded the script, and it loads with no syntax error.  however:

Either I don't understand how the commands work or they don't...   I have tried all the prefix's "! + $ ? # " and nothing..

Yes I have created, prior to loading the script, the file "MessageBoard" in the script folder.. and it remains empty, regardless of the command..

In Main and as a PM I entered the following command/commands..
 +write ,,, +Write   (etc for each prefix.) and the message what ever it would be.. in and out of " " 's  
and still no message is written to the file..

I wish to thank all whom have contributed to this effort of problem resolution.

Thanks again for all of your support.
<<<--- Eff --->>>
Curious Mind would like to know..

Madman

My above post has been edited...
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p


Madman

Script updated...
Now the cmd's should work...
They worked 4 me..
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p


effgjamis

QuoteOriginally posted by madman
Script updated...
Now the cmd's should work...
They worked 4 me..

Sorry, Madman, but I must be a blind, deaf moronic idiot.

the Cmd's for some reason do not work for me, either in Main or PM to the MsgBoard in the Userlist.
I do have a file " MessageBoard.txt " in the scripts folder along with the Message board script..

would you mind in giving an example of the commands.?

I PM MsgBoard  and key  "    +write this is a test    " enter ... I then key  "  +write "this is test two"  

I then +read

nothing........
I then look at the content of the MessageBoard.Txt and nothing is there.

Any assistance would be greatly appreciated..

thank you
<<<--- Eff --->>>
Curious Mind would like to know..

Madman

#16
i just type +write test to the bot in pm...

check if there is any other script that blocks the commands some how..

But the del command dont seem to work... tho....

*Edit*
Fixed the del command...
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

blackwings

#17
nice work madman :) , I just simply made an conversion and a couple off small things.
But then I noticed the script was generally messed up and I didn't really feel like to rewrite the whole script :P

Its good that you did it anyway ;)


Madman

QuoteOriginally posted by blackwings
nice work madman :) , I just simply made an conversion and a couple off small things.
But then I noticed the script was generally messed up and I didn't really feel like to rewrite the whole script :P

Its good that you did it anyway ;)

Hehe... i dont have anything else to do anyway...
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

kunal

the cmds work only in pm not in main.
also the cmds only work for operators.

blackwings

QuoteOriginally posted by kunal
the cmds work only in pm not in main.
also the cmds only work for operators.
Why in main, pm is only needed. But madman can surely fix it for you ;)

cmds should work for master's,operator's and vip's

use this and both reg and normal users can read the board =
rprofiles = {[0]=1,[1]=1,[2]=1,[3]=1,[-1]=1}    -- Which profiles may read the board?


effgjamis

QuoteOriginally posted by kunal
the cmds work only in pm not in main.
also the cmds only work for operators.

Hummm,,,, very interesting,,, but what is the following statements in the script for ?? :

rprofiles = {[0]=1,[1]=1,[2]=1} 	-- Which profiles may read the board?
wprofiles = {[0]=1,[1]=1,[2]=1} 	-- Which profiles may write to the board?
dprofiles = {[0]=1,[1]=1,[2]=1} 	-- Which profiles may delete messages?

If would seem strange that the orginal author would code for different profiles and yet only one will function.

humm.. not real sure what to do now... Thought that was going to be great to use.. instead, this LUA experience is causing me a bit of wonderment.

OH well...

I wish to thank all, for great effort put into this MsgBoard script. However, just for ops, I have no need.

YOU ALL have a great day/weekend..
<<<--- Eff --->>>
Curious Mind would like to know..

effgjamis

QuoteOriginally posted by kunal
the cmds work only in pm not in main.
also the cmds only work for operators.

QuoteOriginally posted by blackwings
cmds should work for master's,operator's and vip's

use this and both reg and normal users can read the board =rprofiles = {[0]=1,[1]=1,[2]=1,[3]=1,[-1]=1}    -- Which profiles may read the board?
Not sure I really understand the code you are showing me BlackWings, but I offer the following as an attempt of understanding with questions:

In your string of code, [-1]=1 ,  what does the -1 indicate and how is that applied to the levels of profiles?
Also, if one was to apply the same code string to the wprofiles and dprofiles, would that provide the ability for all to read, write and delete all?

In Ptokax I see a sequence of Ranks as follows:  Master, operator, VIP, REG, Moderator, netfounder.

As there are 6 items, levels, I would say that [0]= Master, [1]=Operator, [2]=VIP, [3]=Reg, [4]=Moderator, [5]=netfounder.

However, I do see that only 0,1,2,3 are coded (in an array, however, I don't see where the array is defined) or does it default to the [x]=y, as being 1, and so on?

I sure would like a Picture if at all possible, better yet, the MsgBoard script function with all levels, rather than OP only...

Thank again for all the assistance..
<<<--- Eff --->>>
Curious Mind would like to know..

blackwings

0 = master
1 = operator
3 = vip
4 = moderator (not a default ptokax profile)
5 = netfounder (not a default ptokax profile)
-1 = normal/unregisterd users

rprofiles = {[0]=1,[1]=1,[2]=1}

rprofiles is a table, becaue it doesn't start with 1, anyway its should have been shown liks this for easier view =

rprofiles = {
   [0]=1,
   [1]=1,
   [2]=1
}

[0]=1   =   [index]=value

and why 1 if to allow profile, well its because of this line =
if rprofiles[user.iProfile]==1 then


effgjamis

QuoteOriginally posted by blackwings
0 = master
1 = operator
3 = vip
4 = moderator (not a default ptokax profile)
5 = netfounder (not a default ptokax profile)
-1 = normal/unregisterd users


THANKS... and I mean BIG THANKS...

I see # 2 missing,, you have 0,1,3,4,5,-1 ........
Would it be that # 2 = VIP and # 3 = Reg ??

Youu have shed some light on this issue.. However, as I look in the profiles of Ptokax 3.3.21 I see, already defined, All the above (0,1,2,3,4,5)  as established in the Profiles.  Of course I have no clue what is or what is not considered a default. Perhaps the author knows. LOL

As I typed the above paragraph, I was thinking on how one might control those who are registered and I see that # 2 has been omitted from your list. I would then say #2 or #3 are REG , VIP or VIP , REG. ????

 So, IF -1 then you are a person who has connected, but have not registered but are considered normal.
Therefore anyone not registered, is normal.   Which brings a thought, when/how does the -1 become a value ?

Thanks again and sorry for all my questions.. but I gotta..
<<<--- Eff --->>>
Curious Mind would like to know..

SMF spam blocked by CleanTalk