Brandy Mail 1.4 +review patch

The code adds a HELDBY:<player> keyword for use in +review. It searches for all messages being held by the specified player.

Author: Greg Kempe
Category: Mail Systems
Compatibility: CobraMUSH, PennMUSH, TinyBit, TinyMUSH, TinyMUX.

Instructions

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

MUSHCode for Brandy Mail 1.4 +review patch

#
# +review Patch for BrandyMail 14
#
# Version 1 (9/7/98)
# Patch coded by Greg Kempe (kempe@iafrica.com)
# BrandyMail coded by Brandy@CrystalMUSH
# Server: TinyMUSH 2.2.3, BrandyMail 14
#
# HOWTO:
# o To apply the patch, change all occurrences of #17 to the dbref of your
# Parent Mail Object and all occurrences of #22 to the dbref of your help
# object.
#
# NB: If you have added some other patches that affect the attributes listed
# below, I strongly advise against just overwriting them with these
# versions. The modified sections should, instead, be copied across
# manually (they are clearly marked by comments.)
#
# DISCLAIMER: I am not liable for any damages to your DB caused by this code.
# It shouldn't, though, do anything funny, so don't worry too much.
# This patch is in no way an official one for BrandyMail and is
# unsupported by Brandy.
# Please contact me with any oddities, so that I can update the
# patch code.
#
# DESCRIPTION:
# The code adds a HELDBY:<player> keyword for use in +review.
# It searches for all messages being held by the specified player.
#
# Eg: +review heldby:jasper
#
# NOTE: '+help mail keywords' is updated accordingly.
#
# Modified attributes:
# &FORMAT_REQUEST : handles prettying the keyword (also fixes 'To:' keyword bug)
# &EXPAND_OUTGOING_LETTER_RANGE
# : handles the actual search
# &HELP_MAIL_KEYWORDS
# : help for the new keyword
#

&FORMAT_REQUEST #17=switch([setq(1, after(%0, :))]%0+[strlen(%0)], *+0,{%b( current )},a*:*,{%b( author: %q1 )},s*, {[switch(%0,*:*, {%b( subject: %q1 )}, {%b( saved )})]},t*:*,{[switch(%0,te*, {%b( text: %q1 )}, {%b( to: %q1 )})]},h*:*,{%b( heldby: %q1) },a*, {%b( all )},f*, {%b( first )},p*, {%b( previous )},m*, {%b( marked )},c*, {%b( current )},u*, {%b( unread )},d*, {%b( deleted )},l*, {%b( last )},n*, {%b( next )},)
&EXPAND_OUTGOING_LETTER_RANGE #17=squish([setq(6, trim(%0, l))]switch(0, strlen(%1),, strlen(%q6), switch(hasattr(%q0, out-%2-text), 1, %2, last(%1)),eq(%0, 0), [setq(3, iter(%0,switch(##, *-*, [setq(1, before(##, -))][setq(2, after(##, -))]switch(or(lte(%q1, 0), gt(%q2, words(%1)), lt(%q2, %q1)),1,ABORTInvalid message range specified.ENDABORT,lnum(%q1, %q2)), *..*,[setq(1, before(##, ..))][setq(2, after(##, ..))]switch(or(lte(%q1, 0), gt(%q2, words(%1)), lt(%q2, %q1)),1,ABORTInvalid message range specified.ENDABORT,lnum(%q1, %q2)),switch(or(lte(##, 0), gt(##, words(%1))),1,ABORTInvalid message number specified.ENDABORT,##))))]switch(%q3, *ABORT*, %q3, elements(%1, %q3)),switch([setq(4, pos(:, %q6))][setq(5, switch(%q4, #-1, Z, mid(%q6, 0, sub(%q4, 1))))]1,strmatch(text, %q5*),[setq(1, trim(after(%0, :)))]squish(iter(%1, switch(get(%3/out-##-text), *%q1*, ##))),strmatch(to, %q5*),[setq(1, trim(after(%0, :)))][setq(2, num(*%q1))]switch(type(*%q1), PLAYER, squish(iter(%1, switch(match(get(%3/out-##-dist), %q2:*), 0,, ##))), ABORTName specified is not a player.ENDABORT), strmatch(subject, %q5*),[setq(1, trim(after(%0, :)))]squish(iter(%1, switch(get(%3/out-##-subject), *%q1*, ##))),strmatch(heldby, %q5*),[setq(1, trim(after(%0, :)))][setq(2, num(*%q1))]switch(type(*%q1), PLAYER, squish(iter(%1, switch(match(get(%3/out-##-held), %q2), 0,, ##))), ABORTName specified is not a player.ENDABORT), strmatch(all, %q6*),%1,strmatch(first, %q6*),first(%1),strmatch(previous, %q6*),switch(%2, first(%1),ABORTYou have reached the beginning of your mail messages.ENDABORT,extract(%1, sub(match(%1, %2), 1), 1)),strmatch(current, %q6*),switch(hasattr(%q0, out-%2-text), 1, %2, last(%1)),strmatch(last, %q6*),last(%1), strmatch(next, %q6*),switch(%2,last(%1),ABORTYou have reached the end of your mail messages.ENDABORT,extract(%1, add(match(%1, %2), 1), 1)), ABORTInvalid keyword specified.ENDABORT)))
&HELP_MAIL_KEYWORDS #22=This is a list of the valid keyword possibilities for the +mail commands thataccept a keyword parameter.%r%r[ljust(<number>, 20)]Just that number, i.e.,"5" for message number 5.%r[ljust(<list of numbers>, 20)]Several numbers,i.e., "3 8" for messages 3 and 8.%r[ljust(<a>-<b>, 20)]A range of numbers,i.e., "2-5" for messages 2 to 5.%r[ljust(<a>..<b>, 20)]A range of numbers,i.e., "2..5" for messages 2 to 5.%r[ljust(all, 20)]All messages.%r[ljust(current, 20)]The current message.%r[ljust(deleted, 20)]Messages markedfor deletion.%r[ljust(first, 20)]The first message.%r[ljust(last, 20)]Thelast message.%r[ljust(marked, 20)]Marked messages.%r[ljust(next, 20)]Themessage after the current message.%r[ljust(previous, 20)]The message beforethe current message.%r[ljust(unread, 20)]Messages that are unread.%r[ljust(saved, 20)]Messages marked as 'saved'.%r[ljust(author:<name>, 20)]Messages from <name>.%r[ljust(subject:<string>, 20)]Messages with <string>somewhere in the subject line.%r[ljust(text:<string>, 20)]Messages with<string> somewhere in the mail body.%r[ljust(to:<name>, 20)]Messagespreviously sent to <name> (Only for +review)%r[ljust(heldby:<name>, 20)]Messages being held by <name> (Only for +review)%r%rOnly the first character of the keyword needs to be specified.