#########################################################################
# InfoServ 1.0    Dec. 1992, written by Zalcor@Singlenesia
#
# This file creates an object to implement the player-accessible commands
# made possible by the InfoServ system.
#
# To make this file ready for uploading to the mush, it should be filtered
# with the "strip" program. The effects of this filter are as follows:
#
#   Removes all lines that have a '#' in the first column.
#   Strips leading whitespace from all lines.
#   Concatenates all lines, up until it reaches a line with a '-' in the
#      first column.
#########################################################################
# This object must be created by a Wizard. When placed in the Master
# Room, it will implement the following commands:
#
#   rwho <mud name>	Displays the WHO list for <mudname>
#
#   rpeers              Displays the names of all muds that can be contacted.
#
#   rpeers <pattern>    Displays the names of all muds whose name matches
#                         <pattern>
#
#   rpage <name>=<message>
#                       Sends a remote page to <name>, with the message
#                       <message>. <name> must be in the form 
#                       <name>@<mud>, where <mud> is one of the ones listed
#                       by rpeers.
#
#   +lock add <lock>    Adds a remote page lock. This allows a player to
#                       block remote pages selectively (as opposed to just
#                       setting himself HAVEN. <lock> can take one of three
#                       forms:
#
#                          <name>          Blocks all remote pages from
#                                          anyone who has the name <name>.
#                          *@<mud>         Block all remote pages from
#                                          anyone at the mud <mud>.
#                          <name>@<mud>    Blocks all remote pages from
#                                          anyone with the name <name>,
#                                          at the mud <mud>.
#
#                       Any number of separate locks may be specified by
#                       issuing this command once for each lock. A player
#                       must pass all of the specified locks to page
#                       successfully.
#
#                       Players may specify a reject message to be sent
#                       to anyone who rpages, and fails a lock. I have
#                       not bothered to write a command to shorthand this,
#                       as it's trivial. The player should enter the command:
#
#                          $rwho_reject me=<message>
#
#   +lock remove <lock> Removes a lock previously set with the +lock add
#                       command.
#
#   +lock list          Reports the current locks you have set.
#
#   +dict <word>        Reports the dictionary entry for <word>.
#
#   +spell <object>     This command scans an object, reporting any
#                       mispellings. <object> has two possible forms.
#                       If <object> is simply the name of an object, then
#                       every attribute on the object will be checked for
#                       mispellings.
#
#                       <Object> may also take the form: <object>/<pattern>,
#                       Where <pattern> indicates which attributes to check.
#                       <pattern> may contain the * character, which matches
#                       0 or more characters.
#
#                       If more than one attribute is being checked, then
#                       a separate result will be reported for each
#                       attribute checked. The checks will take place in the
#                       order the attributes are report when the object is
#                       examined.
#
#   +addword <word>     Adds <word> to the private dictionary of the player.
#                       Once issued, then <word> will no longer be reported
#                       as being mispelled.
#
#   +removeword <word>  Removes <word> from the private dictionary of the
#                       player.
#
#   +listwords          Reports the contents of the player's private 
#                       dictionary.
######################################################################
#
# Note: This object *must* inherit Wizard powers.
#
# Please report any comments, suggestions or bugs to:
#
#      johnm@cajal.uoregon.edu
######################################################################

@create InfoServ=10
-
@va InfoServ=$rwho *:
   @switch hasflag(*MUDLINK,connect)=
      1,@pemit *MUDLINK=rwho %N = %0,
      0,@pemit %# =Sorry MUD links are down. Please try again later.
-
@vb InfoServ=$rpeers:
   @switch [hasflag(*mudlink,connect)]=
      1,@pemit *mudlink=rpeers %n=,
      0,@pemit *%#=Sorry, MUD links are down. Please try again later.
-
@vc InfoServ=$rpeers *:
      @switch hasflag(*MUDLINK,connect)=
         1,@pemit *MUDLINK=rpeers %n=%0,
         0,@pemit %#=Sorry MUD links are down. Please try again later.
-
@vd InfoServ=$rpage *=*:
      @switch hasflag(*MUDLINK,connect)=
         1,@pemit *MUDLINK=rpage %N@%0 = %1,
         0,@pemit %#=Sorry MUD links are down. Please try again later.
-
@ve InfoServ=$+lock add *:
      @switch member(get(%#/rwho_refuse),ucstr(%0))=
         0,{
            @set %#=rwho_refuse:[get(%#/rwho_refuse)] [ucstr(%0)];
            @pemit %#=Info-Serv lock is added.
         }
-
@vf InfoServ=$+lock remove *:
   @switch member(get(%#/rwho_refuse),ucstr(%0))=
      >0,{
         @set %#=rwho_refuse:[remove(get(%#/rwho_refuse)],[ucstr(%0))];
         @pemit %#=Info-Serv lock is removed.
      }
-
@vg InfoServ=$+lock list:
   @switch words(get(%#/rwho_refuse)=
      0,{@pemit %#=You have no locks set against remote paging.},
      {
         @pemit %#=
            You have the following locks against remote pages:%r
            [get(%#/rwho_refuse)]
      }
-
@vh InfoServ=$+dict *:
   @switch hasflag(*MUDLINK,connect)=
      1,@pemit *MUDLINK=@dict %N=%0,
      0,@pemit %#=Sorry, the dictionary is temporarily unavailable.
-
@vi InfoServ=$+spell *:

#
# Ok, we get a little tricky here. All the +spell command really does is
# to massage the input a bit. Then, the calling player is @forced to issue
# the *real* spell command. A @force is used over a @trigger, because of
# the horrid delays @trigger introduces. A @force also keep the programming
# simpler. The main reason to use the @force, is to allow this object to
# obtain the dbref# of the object to be checked. This is done by forcing
# the player to send the dbref# instead of the name.
#

# First, check to see if any attribute pattern has been specified.

   @switch words(after(%0,/))=
      0,{@fo %#={++secretspell \[num\(%0\)\]}},

# Ok, an attribute pattern was specified... send it along...

      {@fo %#={++secretspell \[num\([before(%0,/)]\)\]/[after(%0,/)]}}
-
@vj InfoServ=$++secretspell *:
   @switch hasflag(*MUDLINK,connect)=
      1,{
         @dolist lattr(%0)={
            @pemit *MUDLINK=
               @spell %N ##: =
                  [setdiff(secure([get([before(%0,/)]/##)]),
                           get(%#/DICTIONARY)
                  )];
         }
      },
      0,@pemit %#=Sorry, the spelling checker is temporarily unavailable.
-
@vk InfoServ=$+addword *:
   @set %#=DICTIONARY:[setunion(get(%#/DICTIONARY),secure(%0))];
   @pemit %#=The word has been added to your dictionary.
-
@vl InfoServ=$+removeword *:
   @switch words(secure(%0))=
      >1,{@pemit %#=You may only remove one word at a time.},
      {
         @set %#=DICTIONARY:[remove(get(%#/DICTIONARY),secure(%0))];
         @pemit %#=The word has been removed from your dictionary.
      }
-
@vm InfoServ=$+listwords:
   @switch words(get(%#/DICTIONARY))=
      0,{@pemit %#=You have no words in your private dictionary.},
      1,{
         @pemit %#=
            Your private dictionary contains the word "[get(%#/DICTIONARY)]".
      },
      {
         @pemit %#=
            Your private dictionary contains the following words:%r
            [get(%#/DICTIONARY)]
      }
-
@vn InfoServ=$rvers*:
   @switch hasflag(*MUDLINK,connect)=
      1,@pemit *MUDLINK=@version %N
      ,@pemit %# =Sorry MUD links are down. Please try again later.
-
@set InfoServ=INHERIT
-
@set InfoServ=!no_
-
@lock InfoServ=me
-
drop InfoServ
--
