message 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

message board

Started by achiever, 07 November, 2006, 09:38:32

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

achiever

--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

sir,

i was using the script message board from lua 5 in the lua 5.1
the scripts gives no error but when some 1 writes some thing the script is stoped,
and then if u try to read wats writen it shows u a blank board.

can ne 1 help me  :(

thks,

achiever.

ps:- the right click doesnt work when u try some thing from right click option it has no effect at all and when ne next command is typed, it is all shown together.
!read<achiever> !write this script testing <achiever> +read

plzz fix it also :(

thks.
thks,
achiever.

6Marilyn6Manson6

Update your post without space in [ code] and in [ /code], after wait replyes of Mutor :D

achiever

hi,

thank u sir, this script works great n has many features,
thks a lot :D

bye,

achiever.
thks,
achiever.

achiever

 :)

that was my duty,

achiever
Posted on: November 09, 2006, 08:39:28 am
hi,

sir can u add just a small part, that when an operator wants to display a message permanently for some time then that message should be kept at the bottom seperately, like a sticky message and should be able to remove it when the need is done.

thks,

achiever
hi mutor,

it has been long time since i posted this request but i m in real need of it so plzz is can this scipt be modified accordingly

thks,
achiever.
thks,
achiever.

speedX

For using Message Board v1.09, do we have to delete the old database (v1.08) ??
Thanking You,

speedX

speedX

Quote from: Mutor on 24 March, 2007, 15:27:06
No, sticky messages were added as a separate file to avoid this.
[of course it would hurt to back up your message file :P]
Sticky file will be created if non-existent.

hm..smart boy  :P
Hey Mutor, the +readby command doenst seem to be working in this new version.
It always shows tht "there are no messages by "user"" even if his board messages are there...
Thanking You,

speedX

achiever

hi,

thks a lot mutor

achiever.
the scirpt shows "there are no messages to display" on read command.

i changed
MsgFile = "MessageBoard.dat",


by
MsgFile = "MessageBoard.txt",


and now its working for me with old data, plzz check it out i may be wrong.

thks,
achiever
thks,
achiever.

achiever

hi,
yes i had not checked all the commands after making changes in 1.09.
thks for the info, has switched to 1.08b.
thks,
achiever.
hi,

plzz modify the script such that no 1 use this board as an advertise board.
and can it be made such that instead of banning that user, he wont be able to write on message board for some preset time in days and this notification is also added to the sticky messages part.

thks,
achiever
thks,
achiever.

Yahoo

Hi mutor..... just add 1 more option in this script. For now thrs only option by which very few no. of messages can be stored in .txt file.

Can u make 1 change by which the .txt file will store all messages added by users but only few latest messages will be shown wen v type +read.

And also wen any user tries to search, the script will search from all the messages stored and not only those few messages.

Like for example, 1000 messages have been stored in .txt file but if i type +read it will show latest 100 messages but for searching, it will search from all 1000 messages.

(Originally Posted by SwapY? in Lua Board#2)
"BoRN FIGhTEr"

Yahoo

actually qwhat he want to say is that (very few no. of messages can be stored in .txt file) means
Max number of messages to cache
MaxMsg = 200,  <--- this should be unlimited i.e when a user write in message board it should be save irrespective of the max number of message for eg if user write 201 message then also it should be save.All message which users write should be save irrespective of max messages setting
The Latest (x) number of messages should only be displayed but the message number should be the origianl one the one that is in the text file for eg:
Max number of messages to read [most recent]
MaxRead = 10
[ 241 ]   April 14 2007 21:06:20  [ orco ]  : someone plzz download and share THE NAMESAKE.
[ 242 ]   April 14 2007 21:25:22  [ djmafia ]  :  will share spiderman 3 full movie in a week  a djmafia release ! ! !
[ 243 ]   April 14 2007 21:37:46  [ djmafia ]  : srry guys ! !it was a fake file ! ! !
[ 244 ]   April 14 2007 22:26:42  [ meetsantyz ]  :  Any interested in selling old pc ( must be  > 2 ghz) or any old moniotor / hard disk  etc... contact me on 9869380948.....  I need 6 old pc in this week... contact ASAP
[ 245 ]   April 14 2007 22:27:04  [ meetsantyz ]  : Any interested in selling old pc ( must be  > 2 ghz) or any old moniotor / hard disk  etc... contact me on 9869380948.....  I need 6 old pc in this week... contact ASAP
[ 246 ]   April 14 2007 22:59:04  [ Noodle ]  : Megadeth - A Tout Le Monde ( Live Ottawa Mar 28 2007 )
[ 247 ]   April 15 2007 00:42:40  [ the_game ]  : sm1 plz share the movie   "bullet proof"    starrin adam sandler....and also   "batman begins "    pls dload or it share it....awesome movie guys....thx
[ 248 ]   April 15 2007 10:45:01  [ Zapper ]  : Encarta Shared by me too ! Download ASAP

i hope u understand what i want to explain to you
"BoRN FIGhTEr"

Yahoo

thanks dude and i am really sorry if i have wrote something wrong
i will like to have a small change in the script instead of
Max number of messages to read [most recent]
MaxRead = 10,
cant be in days for eg
Max number of messages to read [most recent]
MaxRead = 3, <--- days
"BoRN FIGhTEr"

achiever

hi,
thks for the modifications,
but can u plzz add the feature that user can be disabled to write or read by ops for some time.

thks,
achiever.
thks,
achiever.

Yahoo

mutor if possible plzz comment on my latest post (about the days)
"BoRN FIGhTEr"

Yahoo

i will like to have small change in the script .can it be possible to make the commands case insensitive
"BoRN FIGhTEr"

achiever

hi mutor,
is it possible to show the message posted today as
Quote[ 209 ]   TODAY 19:58:04  [ yogi7 ] : testing message for today 

and tomorrow it should show this message as
Quote[ 209 ]   YESTERDAY 19:58:04  [ yogi7 ] : testing message for today 

then from day-after-tomarrow it should show the date as it does now.
Quote[ 209 ]   April 24 2007 19:58:04  [ yogi7 ] : testing message for today 

hope u understood me.
i got the idea from this site itself :-)

thks,
thks,
achiever.

achiever

well it will be difficult to be done with all the post till now, but i m ready to move on ;-)
will this have all the features of 1.08d ?

thks,
thks,
achiever.

Yahoo

sorry for posting this request again but i didnt had any reply for this post
i will like to have small change in the script can it be possible to make the commands case insensitive
"BoRN FIGhTEr"

Leun

remove the string.lower() in the ChatArrival and cmds

Creative

Hello Mutor,
                I am using "Message Board 1.08d   10/20/04 LUA 5 .0/5.1" script.
Sir just tell me what should i edit, if i want the sticky message to be seen as,

<Date> Operator Type +rules.

instead of,

Sticky [ 1 ]  *<Master Creative> Type +rules*

Please tell me what addition i should do in this script.

Yahoo

can u plzz post the code only for removing the case insensitive
thanks in advance
"BoRN FIGhTEr"

Thor

if string.find(data,v,1,1) or string.find(data,"%d+%.%d+%.%d+%.%d",1,1) then

Btw, I don't understand the second pattern... :-/

Thor

string.find(data,"%d+%.%d+%.%d+%.%d",1,1)

It's match with %d+%.%d+%.%d+%.%d and not with numbers I think, because it has four parameter also...

Creative

Hello Sir
           As i told that in User Alerts post that i already have Right Click menu, so i would like to disable the submenu option from this script too. Please tell me how to disable submenu option in this script.

I tried to make all profiles 0 in
"-- Which profiles receive command menu(s)?" option but then script +read and +write commands stops working.

Creative

Thank you ver much Sir

I appreciate your work very much :)

Keep it Up

achiever

hi,
when i m showinig last 12 or ne number of messages then while reading the board i get

QuoteFusion Hub   Message Board    Displayng last [ 169 ] message(s)

which the number of last message on board.

plzz check,
thks,
thks,
achiever.

SMF spam blocked by CleanTalk