Nammyung's Chalkboard 2.1 beta

A chalkboard that allows you to leave messages and read the messages of others, similar to a bulletin board.

Author: Nammyung@M*U*S*H
Category: Other
Compatibility: CobraMUSH, PennMUSH.

Instructions

Copy and paste the below code into a compatible MUSH or MUX.

MUSHCode for Nammyung's Chalkboard 2.1 beta

@create chalkboard
@lock/Basic chalkboard==me
@lset chalkboard/Basic=no_inherit
@lock/Enter chalkboard==me
@lset chalkboard/Enter=no_inherit
@set chalkboard = !NO_COMMAND
&++ chalkboard=$++:@switch/first hasattr(me,setr(1,inc(grep(me,message*,|[convsecs(index(v(temp_read_%#),|,2,1))]|))))=1,{@pemit %#=Date\: [index(setr(2,v(%q1)),|,4,1)]%RWritten by\: [name(index(%q2,|,1,1))][switch(index(%q2,|,5,1),1,%rPrivate to\: %N)]%RSubject\: [index(%q2,|,2,1)]%R%R[index(%q2,|,3,1)]%R%R[eval(me,READ_OPTIONS)];&temp_read_%# me=[index(%q2,|,2,1)]|[convtime(index(%q2,|,4,1))]|[index(%q2,|,1,1)]},0,@pemit %#=There are no more messages.
&+- chalkboard=$+-:@switch/first hasattr(me,setr(1,dec(grep(me,message*,|[convsecs(index(v(temp_read_%#),|,2,1))]|))))=1,{@pemit %#=Date\: [index(setr(2,v(%q1)),|,4,1)]%RWritten by\: [name(index(%q2,|,1,1))][switch(index(%q2,|,5,1),1,%rPrivate to\: %N)]%RSubject\: [index(%q2,|,2,1)]%R%R[index(%q2,|,3,1)]%R%R[eval(me,READ_OPTIONS)];&temp_read_%# me=[index(%q2,|,2,1)]|[convtime(index(%q2,|,4,1))]|[index(%q2,|,1,1)]},0,@pemit %#=There are no earlier messages.
&+CBCREDIT chalkboard=$+cbcredit:@pemit %#=eval(me,credit)
&+CBPOST chalkboard=$+cbpost* *=*:@switch hasattr(me,user)=1,@pemit %#=eval(me,INUSE_MSG),{&user me=%#;&subject me=%1;&date me=[time()];&text me=%2;&temp_message me=%#|%1|%2|[v(date)]|[switch(strmatch(%0,*/p*),1,1|[num(*index(%0,:,2,1))],0|0)]|0|[switch(strmatch(%0,*/h*),1,HID,0)]|0;@set me/do_post_*=!no_command;@pemit %#=You have written the following message\:%R%RDate\: [v(date)]%RSubject\: [v(subject)]%R%R[v(text)]%R%R[eval(me,POST_OPTIONS)];@wait 60=@tr me/remind_post}
&+CBPOST_CHECK chalkboard=$+cbpost:@switch hasattr(me,user)=1,@pemit %#=eval(me,INUSE_MSG),{@switch hasattr(me,temp_%#_message)=1,{&user me=%#;@set me/do_post_*=!no_command;@pemit %#=ansi(b,You have a saved message:)%R%RSubject\: [setr(2,index(setr(1,v(temp_%#_message)),|,2,1))]%R[switch(setr(4,index(%q1,|,5,1)),1,*Private* to [name(setr(5,index(%q1,|,6,1)))]%R)]%R[setr(3,index(%q1,|,3,1))]%R%R[eval(me,POST_OPTIONS)];&temp_message me=%#|%q2|%q3|[time()]|%q4|%q5|0|0|0;@wait 60=@tr me/remind_post},{@pemit %#=ansi(b,You don't have any saved messages. Please use the syntax '+cbpost <subject>=<message>' to post a new message.)}}
&+CBREAD chalkboard=$+cbread*:@switch %0=,@pemit %#=There are following messages written on the chalkboard\:%R[iter(sortby(new_sort,setdiff(lattr(me/MESSAGE*),grep(me,MESSAGE*,|HID|))),delete(##,0,7)\: On [index(setr(1,v(##)),|,4,1)]\, [name(index(%q1,|,1,1))] wrote about [index(%q1,|,2,1)].[switch(1,index(%q1,|,5,1),%b*Private* [switch(index(%q1,|,6,1),%#,for you.)])],,%R)]%R%R'+cbread <message#>' to read message#.,{@switch/first 1=cor(not(hasattr(me,message[setr(3,delete(%0,0,1))])),strmatch(index(setr(2,v(message%q3)),|,8,1),HID)),@pemit %#=Message %q3 does not exist or is set HIDDEN.,cand(index(%q2,|,5,1),not(strmatch(index(%q2,|,6,1),%#))),@pemit %#=Message %q3 is a private message. You may not read private messages not intended for you.,@pemit %#=Message %q3%RDate\: [index(%q2,|,4,1)]%RWritten by\: [name(index(%q2,|,1,1))][switch(index(%q2,|,5,1),1,%RPrivate to\: [name(index(%q2,|,6,1))])]%RSubject\: [index(%q2,|,2,1)]%R%R[index(%q2,|,3,1)]%R%R[eval(me,READ_OPTIONS)];&temp_read_[%#] me=[index(%q2,|,2,1)]|[convtime(index(%q2,|,4,1))]|[index(%q2,|,1,1)]}
&+ERASE chalkboard=$+erase*:@switch/first or(not(hasattr(me,user)),strmatch(%#,v(user)))=0,@pemit %#=eval(me,INUSE_MSG),{&user me=%#;@switch/first %0=,{@set me/do_erase_abort=!no_command;@pemit %#=You have written the following messages on the chalkboard\:%R[iter(sort(lattr(me/message*)),switch(v(##),%#|*,[delete(##,0,7)]\: [index(v(##),|,4,1)] Subject\:[index(v(##),|,2,1)][switch(index(v(##),|,5,1),1,%BPrivate to\: [index(v(##),|,6,1)])]%R),,)]%RPlease '+erase <message number>' or 'abort erase' if you change your mind.;@wait 60={@pemit %#=Erase aborted.;@tr me/done}},{@switch/first 1=not(or(strmatch(%#,index(v(message[setr(1,delete(%0,0,1))]),|,1,1)),strmatch(%#,#1764),strmatch(%#,#1723))),{@pemit %#=You can only erase messages that you wrote yourself.;@tr me/done},hasattr(me,message[setr(1,[delete(%0,0,1)])]),{@halt me=@pemit %#=You have chosen to erase the following message\:%R%RMessage %0%RDate\: [index(v(message%q1),|,4,1)]%RSubject\: [index(v(message%q1),|,2,1)]%R[switch(index(v(message%q1),|,5,1),1,Private to\: [index(v(message%q1),|,6,1)]%R)][index(v(message%q1),|,3,1)]%R%R'confirm erase' to erase\, 'abort erase' if you change your mind.;&delnum me=%q1;@set me/do_erase_*=!no_command;@wait 60={@pemit %#=Erase aborted.;@tr me/done}},{@pemit %#=You have chosen an invalid message number.;@tr me/done}}}
&+NEXT chalkboard=$+next:@switch/first setr(1,first(after(sortby(me/right_sort,setdiff(grep(me,message*,|[index(v(temp_read_%#),|,1,1)]|),setunion(grep(me,message*,|HID|),setdiff(grep(me,message*,|1|#),grep(me,message*,|1|%#|))))),grep(me,message*,|[convsecs(index(v(temp_read_%#),|,2,1))]|))))=,@pemit %#=There are no more public messages in this thread.,{@pemit %#=Date\: [index(setr(2,v(%q1)),|,4,1)]%RWritten by\: [name(index(%q2,|,1,1))][switch(index(%q2,|,5,1),1,%rPrivate to\: %N)]%RSubject\: [index(%q2,|,2,1)]%R%R[index(%q2,|,3,1)]%R%R[eval(me,READ_OPTIONS)];&temp_read_%# me=[index(%q2,|,2,1)]|[convtime(index(%q2,|,4,1))]|[index(%q2,|,1,1)]}
&+PREV chalkboard=$+prev:@switch/first setr(1,last(before(sortby(me/right_sort,setdiff(grep(me,message*,|[index(v(temp_read_%#),|,1,1)]|),setunion(grep(me,message*,|HID|),setdiff(grep(me,message*,|1|#),grep(me,message*,|1|%#|))))),grep(me,message*,convsecs(index(v(temp_read_%#),|,2,1))))))=,@pemit %#=There are no earlier public messages in this thread.,{@pemit %#=Date\: [index(setr(2,v(%q1)),|,4,1)]%RWritten by\: [name(index(%q2,|,1,1))][switch(index(%q2,|,5,1),1,%rPrivate to\: %N)]%RSubject\: [index(%q2,|,2,1)]%R%R[index(%q2,|,3,1)]%R%R[eval(me,READ_OPTIONS)];&temp_read_%# me=[index(%q2,|,2,1)]|[convtime(index(%q2,|,4,1))]|[index(%q2,|,1,1)]}
&+READ chalkboard=$+read *:@switch/first [hasattr(me,MESSAGE%0)]=1,{@pemit %#=[ansi(bh,Date\:)]%B%B%B[ansi(y,[index([v(message%0)],|,1,1)])]%R[ansi(bh,Message by\:)]%B[ansi(y,name([index(v(message%0),|,2,1)]))]%R[ansi(bh,Subject\:)]%B%B [ansi(y,[index(v(message%0),|,3,1)])]%R%R[ansi(c,[index(v(message%0),|,4,1)])]},0,{@pemit %#=[ansi(rh,There is no message \#%0!)]}
&+REPLY chalkboard=$+reply* *:@switch hasattr(me,user)=1,@pemit %#=eval(me,INUSE_MSG),{&user me=%#;&subject me=[index(setr(1,v(temp_read_%#)),|,1,1)];&date me=[time()];&text me=%1;&temp_message me=%#|[v(subject)]|%1|[v(date)]|[switch(strmatch(%0,*/p*),1,1|[index(%q1,|,3,1)],0|0)]|0|[switch(strmatch(%0,*/h*),1,HID,0)]|0;@set me/do_post_*=!no_command;@pemit %#=You have written the following [switch(%0,*/p*,PRIVATE )]response\:%R%RDate\: [v(date)]%RSubject\: [v(subject)]%R%R[v(text)]%R%R[eval(me,POST_OPTIONS)];@wait 60=@tr me/remind_post}
&+WIPE chalkboard=$+wipe chalkboard:@switch/first %N=Nammyung,{@wipe me/message*;&curnum me=0;@pemit %#=[ansi(b,Chalkboard has been cleared.)]},Clare,{@wipe me/message*;&curnum me=0},@pemit %#=[ansi(y,Sorry\, only the Cafe staff are allowed to wipe the chalkboard. Please 'look chalkboard' for instruction.)]
&+WRITE chalkboard=$+write *=*:@switch/first [hasattr(me,inuse)]=1,{@pemit %#=Sorry\, someone is writing on the chalkboard right now. Try again later.},0,{&subject me=%0;&text me=%1;&person me=%#;&inuse me=;@trigger me/askconfirm}
&ABORT chalkboard=$abort message:@halt me=@switch %#=v(person),@tr me/end
&ABORTERASE chalkboard=$abort erase:@switch %#=v(person),{@pemit %#=Erase aborted;@tr me/enderase}
&ASKCONFIRM chalkboard=@pemit v(person)=Please confirm your message.%R%RSubject\:[v(subject)]%R[v(text)]%R%R'Confirm message' to save\, or 'Abort message' to abort.;@wait 60=@tr me/remind_write
&ASKDEL chalkboard=@emit Well, you better finish this later.;&person me;&delnum me;&inuse me
&CONFIRM chalkboard=$confirm message:@halt me=@switch %#=v(person),@tr me/store
&CONFIRMERASE chalkboard=$confirm erase:@switch %#=v(person),@tr me/doerase
&CREDIT chalkboard=Nammyung's Chalkboard v.2.1.beta%R%RMany thanks to Trispis and others who helped me so patiently!
&CURNUM chalkboard=0
&CURRENTMESSAGE chalkboard=0
&DESCRIBE chalkboard=To your right, you see a tall chalkboard containing messages from various visitors to the Cafe. '+cbread' to see what they wrote. '+cbpost <subject>=<message>' to leave a message of your own. '+erase' to remove a message that you've written.
@set chalkboard/DESCRIBE=no_command visual prefixmatch public nearby
&DOERASE chalkboard=&message[get(#1575/delnum)] me;@trigger me/domove;@wait 2={&message[get(#1575/currentmessage)] me;&currentmessage me=[sub([get(#1575/currentmessage)],1)];@pemit [num([get(#1575/person)])]=Message erased.;@trigger me/enderase}
&DOMOVE chalkboard=@dolist [lnum([sub([get(#1575/currentmessage)],[get(#1575/delnum)])])]={&message[add([get(#1575/delnum)],##)] me=[get(#1575/message[add([get(#1575/delnum)],[add(##,1)])])]}
&DONE chalkboard=@halt me=@set me/do_*=no_command;&user me;&subject me;&date me;&text me;&temp_message me;&delnum me
&DO_ERASE_ABORT chalkboard=$abort erase:@switch %#=[v(user)],{@halt me=@pemit %#=Erase aborted.;&delnum me;@tr me/done}
@set chalkboard/DO_ERASE_ABORT=no_command
&DO_ERASE_CONFIRM chalkboard=$confirm erase:@switch %#=v(user),{&message[v(delnum)] me;@tr me/move=[v(delnum)];@wait 2={&message[v(curnum)] me;&curnum me=dec(v(curnum));@pemit %#=Message erased.;&delnum me;@trigger me/done}}
@set chalkboard/DO_ERASE_CONFIRM=no_command
&DO_POST_ABORT chalkboard=$+abort:@switch %#=v(user),{@pemit %#=ansi(b,Your message has been aborted.);@tr me/done}
@set chalkboard/DO_POST_ABORT=no_command
&DO_POST_EDIT chalkboard=$+edit:@switch %#=v(user),{@pemit %#=ansi(y,Sorry\, editing isn't implemented yet.)%R[eval(me,POST_OPTIONS)]}
@set chalkboard/DO_POST_EDIT=no_command
&DO_POST_POST chalkboard=$+post:@switch %#=v(user),{&message[inc(v(curnum))] me=[v(temp_message)];&curnum me=[inc(v(curnum))];@pemit %#=ansi(b,Your message has been posted.);@tr me/do_post_scroll}
@set chalkboard/DO_POST_POST=no_command
&DO_POST_SAVE chalkboard=$+save:@switch %#=v(user),{&temp_[%#]_message me=[v(temp_message)];@pemit %#=ansi(b,Your message has been saved for later. You can access it later by typing '+cbpost');@tr me/done}
@set chalkboard/DO_POST_SAVE=no_command
&DO_POST_SCROLL chalkboard=@switch gt(v(curnum),v(maxnum))=1,{&message1 me;@tr me/move=1;@wait 2={&message[v(curnum)] me;&curnum me=dec(v(curnum));@tr me/done}},0,{@tr me/done}
@set chalkboard/DO_POST_SCROLL=no_command
&END chalkboard=&subject me;&text me;&person me;&inuse me
&ENDERASE chalkboard=@halt me=&delnum me;&person me;&inuse me
&ERASE chalkboard=$erase message:@halt me=@switch/first [hasattr(me,inuse)]=1,{@pemit %#=Sorry\, someone is writing on the chalkboard right now. Try again later.},0,{&person me=%#;&inuse me=;@pemit %#=You have written the following messages on the chalkboard\:%R%R[iter([sort([grepi(me,MESSAGE*,|%#|)])],[delete(##,0,7)]\: [index(v(##),|,1,1)] Subject\:[index(v(##),|,3,1)],,%R)]%R%RPlease '+erase <message number>' or 'abort erase' if you change your mind.;@wait 60={@pemit v(person)=Erase aborted.;@tr me/enderase}}
&INUSE_MSG chalkboard=ansi(y,Sorry\, [name(v(user))] is writing on the chalkboard right now. Why don't you try in a minute or two?)
&MAXNUM chalkboard=100
&MOVE chalkboard=@dolist [lnum(sub(v(curnum),%0))]=&message[add(%0,##)] me=[v(message[add(%0,##,1)])]
@set chalkboard/MOVE=no_command prefixmatch
&NEW_SORT chalkboard=sub(1,add(lt(setr(2,convtime(index(v(%0),|,4,1))),setr(3,convtime(index(v(%1),|,4,1)))),lte(%q2,%q3)))
&POST_OPTIONS chalkboard=ansi(g,'+post'\, '+edit'\, '+save'\, or '+abort'?)
&READ chalkboard=$read chalkboard:@pemit %#=[iter([sort([lattr(me/MESSAGE*)])],[ansi(yh,[delete(##,0,7)]\:)] [ansi(b,On)] [ansi(b,[index([v(##)],|,1,1)])][ansi(yh,\,)] [ansi(ch,[name(index([v(##)],|,2,1))])] [ansi(b,wrote regarding)] [ansi(yh,\:)] [ansi(ch,[index([v(##)],|,3,1)])],,%R)]%R%R[ansi(n,Please '+read <message number>')][html(body bgcolor=000000)] [html(/font)]
&READ_OPTIONS chalkboard=ansi(g,'+reply <text>' to post a response, '++' to read the next message, '+-' to read the previous message, '+next' to read the next message on the thread, or '+prev' to read the previous message on the thread.)
&REMIND_POST chalkboard=@pemit [v(user)]=ansi(y,Please choose '+post', '+edit', '+save', or '+abort'. Your message will automatically time out to '+abort' in 60 seconds.);@wait 60={@pemit [v(user)]=ansi(b,Your message has been aborted.);@tr me/done}
&REMIND_WRITE chalkboard=@pemit v(person)=Please 'confirm message' or 'abort message'. Your message will time out to 'abort' in 60 seconds.;@wait 60={@pemit v(person)=Message aborted.;@tr me/end}
&RIGHT_SORT chalkboard=sub(1,add(lt(setr(2,convtime(index(v(%0),|,4,1))),setr(3,convtime(index(v(%1),|,4,1)))),lte(%q2,%q3)))
&STORE chalkboard=&message[add([v(currentmessage)],1)] me=[time()]|[v(person)]|[v(subject)]|[v(text)];&currentmessage me=[add([v(currentmessage)],1)];@pemit [v(person)]=Your message has been stored.;@trigger me/end