Hi guys,
This Message board script is made by mutor.....i needed some additional commands in this script if possible....
Here is the script....
--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 = 100 -- 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]=0,[2]=0} -- 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
I want the following addition....
-When a user types !wrote <nick> he should get all the messages tht particular user has entered...
For eg:
!wrote Mutor
- [ 1 ] On August 15 2006 13:46:14 [ Mutor ] wrote: Hi
- [ 2 ] On August 15 2006 14:16:21 [ Mutor ] wrote: Movies shared....
Quote from: speedX on 17 August, 2006, 14:44:58
I want the following addition....
-When a user types !wrote <nick> he should get all the messages tht particular user has entered...
There's a similar script that does what you want.
Search the forum for 'Bulletin Board'.
yup i tried those scripts.....but didn like it.....i jus need a simple one.....so can anyone jus modify the script according to my requests wich i posted....plzz
Posted on: 2006-08-17, 17:28:35
can u jus modify it??
hey Mutor...thx for the script....but i found some errors....
1) When I type "+read" the message board comes in main chat but i would like it to come in PM.
2) and when a user types any message....i type "!readby <nick>" ...it says
QuoteSorry speedX, there are no messages from <nick>.<nick> [ 5 ] On August 18 2006 12:58:46 [ nick ] wrote: hi
It means tht even if the user has entered something....it shows me tht message...
3) and When i type !readby speedX thn it shows the message like this..
Quote
speedX [ 1 ] On August 15 2006 13:46:14 [ speedX ] wrote: Welcome
^acesam^speedX [ 3 ] On August 18 2006 12:57:10 [ speedX ] wrote: Hi
speedX [ 4 ] On August 18 2006 12:57:16 [ speedX ] wrote: bye
abbyabbyspeedX [ 7 ] On August 18 2006 12:59:51 [ speedX ] wrote: kk
But i would like it if it was like this:
Quote
speedX [ 1 ] On August 15 2006 13:46:14 [ speedX ] wrote: Welcome
speedX [ 3 ] On August 18 2006 12:57:10 [ speedX ] wrote: Hi
speedX [ 4 ] On August 18 2006 12:57:16 [ speedX ] wrote: bye
speedX [ 7 ] On August 18 2006 12:59:51 [ speedX ] wrote: kk
Hope i have not confused you.....thx..
s/want/would like please.
?? i didn get you..
Quote from: speedX on 18 August, 2006, 11:37:36
?? i didn get you..
Don't use the word 'want' when reqwuesting something. Compare:
I want it to show in PM
I would like it to show in PM
hm..rite
nope dude....srry but it is still showing me those errors......k let it be....can u jus convert tht script to 5.1 wich i have posted.....thx..
oh cool.....now it works fine....but last prob m8....
u said..
Quote
If you send commands in main it will repsond in main [hub tab commands].
if you send commands in pm it will respond in pm [user list commands].
but i would like it to come in pm only....i mean if a user types !read in main chat thn also it should come in PM.....plzz..thank u..
Posted on: 2006-08-25, 08:52:03
i would like it to come in pm only...like in Lua 5.0
perfect.....thx mutor....this is wat i wantd.....thank u again m8....
Posted on: 2006-08-26, 09:14:00
hey Mutor..hi..can u modify this script such tht if a user type +read ...thn other users should be able to see tht +read....but not the messages...only +read & +write....thank u..
Posted on: 2006-09-24, 13:27:10
hey Mutor.....in this script i have not givin permission to reg users to delete the other users messages....but still tht command comes in their right click....how ot remove it ?? also the message board help comes in their right click..i would like to remove tht also.....
speedX: This is the final time I pointing out that you MUST NOT post like you talk in chat.Also,you can't go posting on top of your posts. Don't create a series of posts by you.
It makes things look bad and usually you are not clearly passing through what you want to say.
Editing your previously posted messages will do the job.
Next time I am deleting all the series of posting you do. If there are two in a row two will be deleted, if three then three are deleted and so on,..
Please, respect the forum and the people behind it.Not only a lot of people take their time to visit it,
so we need to make them see a forum good enough to stay.
Also many people really care about the forum.
So making it easy to read and navigate is the key to make us believe that thinking about the forum is worth the time we all invest in it.
About posts and requests for scirpts.When you want to post for something like some change in a script please make sure:
- You post in the appropriate thread.
This means that you can't post in an other script's thread.
It also means that if there is no thread on that script you are free to make a new one. - Make your request as specific as possible.
This means that you make sure that your post makes sense, (plain English helps a lot).
and also that you already know what you want changed, exactly. - Clearly format the post.
This means that you are sending a written message that is going to be read by someone. Considering the previous, you already know that there is a certain way to write something and it has nothing to do with the way it is said verbaly or in thinking it. First think then type, make this a motto.
By the way this text I think is a nice start for a netiquete for the forum. Please contribute so we can have a sticky topic out of this where some forum rules can be added.
Herodes: note the double posts button and see the magic it can do (I tried it here. :D)
hm...yup i have now stopped posting double posts.........and 1 last request Mutor....tht +readby command doesnt work for lower case......when i type !readby speedX thn it shows the messages but when i type !readby speedx....it doesnt......
hello good buddy
i have just downloaded this script and is working fine
i have just 1 question is it possable to change the title to request board rather than message board
also how do i delete all messages can delete what i posted but not other peeps
cheers
Doug uk