: slash ( s -- s ) "/" strcat "/" swap strcat ; : pose? ( s -- i ) tolower "/://;//po//pos//pose/" swap instr ; : say? ( s -- i ) tolower "/\"//'//s//sa//say/" swap instr ; : page? ( s -- i ) tolower "/p//pa//pag//page/" swap instr ; : whisper? ( s -- i ) tolower "/w//wh//whi//whis//whisp//whispe//whisper/" swap instr ; : force_zog ( s -- ) trigger @ location swap force ; : send_reply ( i s -- ) swap dup 3 < if pop dup ":" 1 strncmp if "\"" swap strcat then force_zog exit then pop trigger @ location location me @ location dbcmp not if "page " me @ name strcat "=" strcat swap strcat else dup ":" 1 strncmp not if 1 strcut swap pop " " swap strcat trigger @ location name swap strcat then "whisper " me @ name strcat "=" strcat swap strcat then force_zog exit ; : explode_pop ( x1 .. xN N -- ) begin dup while swap pop 1 - loop pop ; : player_in_string? ( s -- s i ) 0 over " " explode begin dup while over .pmatch dup trigger @ location over dbcmp not and if over 3 + rotate pop intostr atoi over 2 + 0 swap - rotate explode_pop exit then pop swap pop 1 - loop pop ; : addname ( s -- s ) ", " strcat me @ name strcat "." strcat ; : huh? ( i s -- ) pop "I couldn't understand you" addname send_reply ; : end_run ( i s i -- ) not if huh? else pop pop then online begin dup while trigger @ location 3 pick intostr "/m" strcat getpropstr 3 pick ".zogmail" getpropstr not and if swap me ! me @ ".zogmail" "yes" 0 addprop 3 "I am holding messages for you" addname send_reply else swap pop then 1 - loop pop ; : valid? ( s s -- i ) 0 3 pick rot "/" explode begin dup while dup 2 + pick rot instr if dup 2 + rotate pop 1 over -2 swap - rotate then 1 - loop pop pop ; : parse_go ( i s -- i s i ) "home/your home" valid? if over "I'll be going home then" addname send_reply 5 sleep "home" force_zog 1 exit then "take a leap/fly a kite/jump in a lake/take a flying leap" valid? if over ":ignores " me @ name strcat " completely." strcat send_reply 1 exit then 0 ; : parse_come ( i s -- i s i ) "here/to me" valid? if trigger @ location location loc @ dbcmp if over "I am already here." send_reply 1 exit then trigger @ location "busy?" getpropstr if over "I am busy now. Please try later." send_reply 1 exit then over "I will be there in a moment" addname send_reply 5 sleep trigger @ location loc @ moveto 1 exit then 0 ; : parse_who ( i s -- i s i ) "is on/is online/do you see/is around/is awake/is connected" "/is playing" strcat valid? if over "I see " online begin dup while dup 2 + rotate rot name strcat ", " strcat over -1 swap - rotate 1 - loop pop dup strlen 2 - strcut pop dup ", " rinstr dup if strcut " and" swap strcat strcat else pop then "you" me @ name subst "myself" trigger @ location name subst "." strcat send_reply 1 exit then 0 ; : parse_where ( i s -- i s i ) 0 ; : parse_take ( i s -- i s i ) over 2 > if "I have to be present to pick up something" addname send_reply 1 exit then dup "the " instr dup if over swap 3 + strcut swap pop match dup #-1 dbcmp if pop over "I don't see that here." send_reply 1 exit then dup #-2 dbcmp if pop over "I don't know which you mean." send_reply 1 exit then trigger @ location over passlock? not over thing? not or if pop over "I'm sorry, I can't get that." send_reply 1 exit then name "take " swap strcat force_zog over "I have it now" addname send_reply 1 exit else pop then 0 ; : parse_drop ( i s -- i s i ) over 2 > if "I have to be present to drop something" addname send_reply 1 exit then dup "the " instr dup if over swap 3 + strcut swap pop trigger @ location swap rmatch dup #-1 dbcmp if pop over "I don't have that." send_reply 1 exit then dup #-2 dbcmp if pop over "I don't know which you mean." send_reply 1 exit then name "drop " swap strcat force_zog 1 exit else pop then 0 ; : parse_what ( i s -- i s i ) "time is it/time do you have/is the time" valid? if over "It's %t (CST)" addname systime ctime "%t" subst send_reply 1 exit then "are you" valid? if over "I'm a robot" addname send_reply 1 exit then 0 ; : parse_how ( i s -- i s i ) "are you/is it going/goes/goes it/are ya" valid? if over "I'm fine, thanks" addname send_reply 1 exit then 0 ; : parse_type ( i s -- i s i ) dup "type " instr 4 + strcut swap pop "quit/who/\"/'/;/:/p /po /pos /pose /s /sa /p /pa /pag /page " "/say /w /wh /whi /whis /whisp /whispe /whisper " strcat valid? if over ":is not allowed to type that." send_reply 1 exit then over ":types '" 3 pick strcat "' as requested by " strcat me @ name strcat "." strcat send_reply dup force_zog 1 ; : parse_do ( i s -- i s i ) 0 ; : parse_mail ( i s -- i s i ) "have/is there/any/what/are/show/give" valid? if me @ ".zogmail" remove_prop trigger @ location me @ intostr "/m" strcat getpropstr dup not if pop over "I have no messages for you" addname send_reply 1 exit then atoi 1 swap 1 for trigger @ location me @ intostr "/" strcat 3 pick intostr strcat getpropstr dup "/" instr 1 - strcut 1 strcut swap pop "[From " rot atoi dbref name strcat " on " strcat swap dup "/" instr 1 - strcut 1 strcut swap pop swap atoi ctime rot swap strcat "] " strcat swap strcat 4 pick swap send_reply trigger @ location me @ intostr "/" strcat rot intostr strcat remove_prop loop trigger @ location me @ intostr "/m" strcat remove_prop 1 exit then 0 ; : parse_tell ( i s -- i s i ) player_in_string? dup not if pop over "I don't see anyone to send that to" addname send_reply 1 exit then dbref over dup 3 pick name tolower instr dup 1 > if 1 - strcut swap pop else pop then "" 3 pick name tolower " that " strcat subst "" 3 pick name tolower " to " strcat subst "" 3 pick name tolower " " strcat subst systime intostr "/" strcat swap strcat me @ intostr "/" strcat swap strcat trigger @ location 3 pick intostr "/m" strcat getpropstr atoi 1 + intostr trigger @ location 4 pick intostr "/m" strcat 3 pick 0 addprop 3 pick intostr "/" strcat swap strcat trigger @ location swap rot 0 addprop "Message for " swap name strcat " saved" strcat addname 3 pick swap send_reply 1 ; : parse_commands ( i s -- ) over 3 < over tolower trigger @ location name tolower instr not and if pop pop pop exit then (Comment out following block if not using on HoloMUCK) (START) over 3 = 4 rotate me @ name " speaks" strcat dup strlen strncmp not and if pop pop exit then (END) tolower "message/mail" valid? if parse_mail end_run exit then "tell/send/leave a note for" valid? if parse_tell end_run exit then dup "type " instr if parse_type end_run exit then dup "do " instr if parse_do end_run exit then dup "go " instr if parse_go end_run exit then dup "come " instr if parse_come end_run exit then dup "who " instr if parse_who end_run exit then dup "where " instr if parse_where end_run exit then "take/get/pick up/gather/collect/carry/lift" valid? if parse_take end_run exit then "put/drop/set down/let go of/throw" valid? if parse_drop end_run exit then dup "what " instr if parse_what end_run exit then dup "how " instr if parse_how end_run exit then "hi/hello/hola/greetings/hey/howdy" valid? if over "Hello there" addname send_reply 1 end_run exit then "bye/good bye/goodbye/later/ciao/see ya/cya/hasta" valid? if over "Goodbye" addname send_reply 1 end_run exit then "thanks/thank you/i appreciate it/gracias/danke" valid? if over "You're very welcome" addname send_reply 1 end_run exit then pop pop ; : main ( s s -- ) trigger @ location awake? not if pop exit then 0 me @ ".last" getpropstr .sstrip dup not if pop pop pop exit then me @ ".last" remove_prop (Comment out from START to END if not on HoloMUCK) (START) 3 pick tolower "pager" instr if pop pop pop exit then (END) dup " " instr not "\"';:" 3 pick 1 strcut pop instr not and if pop pop pop exit then 1 strcut "\";':" 3 pick instr if " " swap strcat strcat else strcat then dup dup " " instr 1 - strcut pop slash dup pose? if rot pop 1 rot rot then dup say? if rot pop 2 rot rot then dup page? if rot pop 3 rot rot then dup whisper? if rot pop 4 rot rot then pop over not if pop pop pop exit then "" "@" subst parse_commands ;