View/Edit #12:parse_mailread_cmd

Switch to edit mode.

Name(s): parse_mailread_cmd
1:  ":parse_mailread_cmd(verb,args,default,prep[,trailer])"
2:  "  handles anything of the form  `VERB message_seq [PREP folder ...]'"
3:  "    default is the default msg-seq to use if none given"
4:  "    prep is the expected prepstr (assumes prepstr is set), usually `on'"
5:  "    trailer, if present and true, indicates trailing args are permitted."
6:  "  returns {recipient object, message_seq, current_msg,\"...\"} or 0"
7:  set_task_perms(caller_perms())
8:  if (!(pfs = this:parse_folder_spec(@listdelete(args, 3))))
9:    return 0
10: endif
11: {verb, args, default, prep, ?extra = 0} = args
12: folder = pfs[1]
13: cur = this:get_current_message(folder) || {0}
14: if (typeof(pms = folder:parse_message_seq(pfs[2], @cur)) == $LIST)
15:   rest = {@listdelete(pms, 1), @pfs[3]}
16:   if (!extra && rest)
17:     "...everything should have been gobbled by :parse_message_seq..."
18:     player:tell("I don't understand `", rest[1], "'")
19:     return 0
20:   elseif (pms[1])
21:     "...we have a nonempty message sequence..."
22:     return {folder, pms[1], cur, rest}
23:   elseif (used = length(pfs[2]) + 1 - length(pms))
24:     "...:parse_message_seq used some words, but didn't get anything out of it"
25:     pms = "%f %<has> no `" + $string_utils:from_list(pfs[2][1..used], " ") + "' messages."
26:   elseif (typeof(pms = folder:parse_message_seq(default, @cur)) == $LIST)
27:     "...:parse_message_seq used nothing, try the default; wow it worked"
28:     return {folder, pms[1], cur, rest}
29:   endif
30: elseif (typeof(pms) == $ERR)
31:   player:tell($mail_agent:name(folder), " is not readable by you.")
32:   if (!$object_utils:isa(folder, $newsgroup))
33:     player:tell("Use * to indicate a non-player mail recipient.")
34:   endif
35:   return 0
36: endif
37: if (folder == this)
38:   subst = {{"%f's", "Your"}, {"%f", "You"}, {"%<has>", "have"}}
39: elseif (is_player(folder))
40:   subst = {{"%f", folder.name}, {"%<has>", $gender_utils:get_conj("has", folder)}}
41: else
42:   subst = {{"%f", $mail_agent:name(folder)}, {"%<has>", "has"}}
43: endif
44: player:tell($string_utils:substitute(pms, {@subst, {"%%", "%"}}))
45: return 0
46: "Last modified by Dax (#789) on Tue May  3 13:45:55 2005 MDT."

Verb arguments: this none this
Verb perms: Readable eXecutable NOT-Debug
Verb owned by: Slacker (#55)

You are not logged in.

[home | help | who | search | setup | code]