@edit cambot_action.muf 1 99999 d 1 i ( cambot_action.muf 04/10/01 by BoingDragon This is the primary program of the cambot system. It can be used alone in a room or as part of a holodeck and Furry Science Theater 3000 setup. In a room or parent room link a 'cambot' action to this program, then type 'cambot' to display usage and set the command aliases. To use with FST3K rooms, set the property 'fst3k_parent:' in the room the action lives in. By default, logs will be saved on the rooms they are recorded in, unless a 'library' property is set in the room or parent which has the db number of an object to save them to. Editing and other permissions flow as follows: library owner -> log owner -> line owner Line owners can edit, delete and change lines they created Log owners have full control over all lines of the log and can delete logs Library owners have full control over all logs by all owners Program properties: "recorder" on the program object must be set to the number of room_recorder.muf, without the # sign. Library object properties: "_auth_users", set to their db numbers {no # signs} seperated by spaces will give those users library-owner level permissions over that library. ) $def ACTION_NAME "cambot;closeup;logs;setlog;clearlog;setline;deleteline;changeline;swapline;lastline;startlog;stoplog;printlog;viewlog;viewlast;addnote;hr;icdate" $def CLOSEUP_OPEN "
" $def CLOSEUP_CLOSE "
" $def LOGLINE_OPEN "

" $def LOGLINE_CLOSE "

" $include $lib/case $include $lib/sort lvar actname lvar logname lvar linenumber lvar start-type lvar startline lvar stopline lvar inarg lvar loglib lvar shownumbers lvar doublespace lvar fst3k lvar channel lvar count lvar index lvar logowner lvar lineowner lvar oldstring lvar newstring lvar targetname lvar targetdb lvar image lvar switch lvar recorder lvar fst3k_parent lvar age lvar spi lvar pdb lvar parg lvar authlist (Begin Greywolf function block) : tell ( s -- : return message to user ) me @ swap notify ; () : even? ( i -- 0|1 : return 1 if even, 0 if odd ) 2 % not ; () : extract-char ( s1 i -- s2 : return the ith character of s1 ) dup 1 = if ( handle i = 1 as special case to avoid error below ) strcut pop exit then over over strcut pop ( remove all characters after i ) rot pop swap ( remove input string ) (stack: s2 i ) 1 - strcut swap pop ( remove all characters before i ) ; () : split-remove ( s1 i -- s2 s3 : return strings on both sides of i ) dup 1 = if ( handle i = 1 as special case to avoid error ) strcut swap pop "" swap exit then over over strcut (stack: s1 i s s3 ) swap pop ( split off characters after i ) (stack: s1 i s3 ) rot rot 1 - strcut pop ( split off characters before i ) (stack: s3 s2 ) swap ; () : numeric? ( s1 -- 0|1 : returns 1 if numeric, 0 if not ) dup "0" strcmp not if pop 1 exit then atoi 0 > if 1 else 0 then ; () : last-char ( s1 -- s2 : returns last character of s1 ) dup strlen dup 2 < if pop exit then 1 - strcut swap pop ; () : html-convert ( s1 s2 s3 -- s4 : convert key codes to html) (s1 = input string ; s4 = output string ) (s2 = key code -- example '*' ) (s3 = html code -- example 'b' ) () (note: if this function is unable to get a 'clean' convert, it will return the line with no changes. The reasoning is that it is better to leave things be than to convert wrongly.) () rot (stack: * b s1 ) dup 4 pick instr not if ( if no "*" at all, leave line untouched ) swap pop swap pop exit (clean stack and quit) then (stack: * b s1 ) 0 "" 3 pick ( stack: * b s1 counter rebuild workstring ) begin dup 7 pick instr dup not if ( no more * to process ) pop strcat swap even? if swap pop ( remove input string ) break else (if odd occurrences of *, then something is wrong) (abort and return original string) pop break then then (stack: * b s1 counter rebuild workstring position ) split-remove (stack: * b s1 counter rebuild part1 workstring ) rot rot strcat swap (stack: * b s1 counter rebuild workstring ) () over last-char (stack: * b s1 counter rebuild workstring last-char ) dup "<" strcmp not ( is < last character? ) (stack: * b s1 counter rebuild workstring last-char i ) swap 8 pick strcmp not or if ( is * last character? ) (stack: * b s1 counter rebuild workstring ) swap 6 pick strcat swap ( if so, don't convert this time ) continue then () (stack: * b s1 counter rebuild workstring ) dup 1 strcut pop 7 pick strcmp not if ( is * next character? ) swap 6 pick strcat swap ( if so, don't convert this time ) continue then () (stack: * b s1 counter rebuild workstring ) dup 1 strcut pop numeric? if ( is next character numeric? ) over last-char numeric? if ( is previous character numeric? ) swap 6 pick strcat swap ( if so, don't convert this time ) continue then then () 3 pick even? if swap "<" 6 pick ">" strcat strcat strcat swap (stick tag after 'rebuild' portion ) else swap "" strcat strcat strcat swap (end bold html indicator ) then rot 1 + rot rot ( increment counter, put back in stack ) repeat ; () : bold-convert ( s1 -- s2 : convert *bold* to bold ) "*" "b" html-convert ; () : italics-convert ( s1 -- s2 : convert /italics/ to italics ) "/" "i" html-convert ; () : underline-convert ( s1 -- s2 : convert _underline_ to underline ) "_" "u" html-convert ; (End Greywolf function block) : holodeck ME @ location ; : get-logname holodeck "logname" getpropstr logname ! ( get the name of the current log ) ; : set-logname holodeck swap "logname" swap setprop ; : log-prop "logs/" logname @ strcat ; : log-propdir log-prop "/" strcat ; : log-status loglib @ log-prop "/status" strcat getpropstr ; : set-status inarg ! loglib @ log-propdir "status" strcat inarg @ setprop ; : get-line loglib @ log-prop getpropval ; : addline inarg ! get-line linenumber ! linenumber @ 1 + linenumber ! loglib @ log-propdir linenumber @ intostr strcat inarg @ setprop loglib @ log-prop linenumber @ setprop ; : addnote log-status "recording" strcmp if ">> The cambot isn't recording now! <<" tell exit then ME @ name " notes: " strcat inarg @ strcat inarg ! holodeck #-1 ">> " inarg @ strcat " (OOC)" strcat notify_except "" strcat addline ; : icdate log-status "recording" strcmp if ">> The cambot isn't recording now! <<" tell exit then "" strcat addline ME @ name " notes the date: " strcat inarg @ strcat inarg ! holodeck #-1 ">> " inarg @ strcat " (OOC)" strcat notify_except ; : get-channel "0" channel ! holodeck "fst3k_parent" envprop swap #-1 dbcmp not if atoi dbref fst3k_parent ! fst3k_parent @ "room/" nextprop channel ! begin fst3k_parent @ channel @ getpropstr holodeck intostr strcmp while fst3k_parent @ channel @ nextprop channel ! repeat channel @ 5 strcut swap pop channel ! else pop then ; : auth-user? loglib @ log-propdir "owner" strcat getpropval dbref logowner ! logowner @ ME @ dbcmp loglib @ owner ME @ dbcmp or ME @ "W" flag? or if 1 else 0 index ! loglib @ "_auth_users" getpropstr authlist ! authlist @ strlen if authlist @ " " explode count ! begin count @ 0 > while atoi dbref ME @ dbcmp if 1 index ! then count @ 1 - count ! repeat then index @ then ; : fst3k-notify inarg ! (FST3K notify) fst3k_parent @ dbref? if fst3k_parent @ contents fst3k ! begin fst3k @ room? if fst3k @ #-1 inarg @ notify_except then fst3k @ next fst3k ! fst3k @ #-1 dbcmp until then ; : addbreak log-status "recording" strcmp if ">> The cambot isn't recording now! <<" tell exit then holodeck #-1 "
" notify_except ; : startlog logname @ strlen 0 = if ( if no current log name set, create one based on the date ) "%b-%d-%Y" systime timefmt logname ! holodeck "logname" logname @ setprop then log-status "recording" strcmp not if ">> That log is already being recorded to! <<" tell exit then ( get the last line index if it exists ) get-line linenumber ! ( if no previous linenumber set, create new one, else increment ) linenumber @ 1 < if "started" start-type ! loglib @ log-propdir "owner" strcat ME @ int setprop ( first person to start log is log owner ) else "restarted" start-type ! then "recording" set-status loglib @ log-propdir "time" strcat systime setprop ( generate and save startlog line ) "" strcat addline ( set environment properties ) holodeck "recording" "yes" setprop holodeck "_arrive/cambot" "&>> Cambot is recording in this room <<" setprop holodeck "_connect/cambot" "&>> Cambot is recording in this room <<" setprop holodeck "_listen/cambot" recorder @ setprop ( messages ) ">> You start cambot recording <<" tell holodeck ME @ ">> (OOC) " ME @ name strcat " starts cambot recording <<" strcat notify_except holodeck "private" getprop not if get-channel ">> " ME @ name strcat " begins recording '" strcat logname @ strcat "' on channel " strcat channel @ strcat " <<" strcat fst3k-notify then ; : stoplog log-status "recording" strcmp if ">> The log is already stopped <<" tell exit then holodeck "recording" "no" setprop holodeck "_arrive/cambot" remove_prop holodeck "_connect/cambot" remove_prop holodeck "_listen/cambot" remove_prop ( generate and save stoplog line ) "" strcat addline "archive" set-status ( messages ) ">> You stop cambot recording <<" tell holodeck ME @ ">> " ME @ name strcat " stops cambot recording <<" strcat notify_except holodeck "private" getprop not if get-channel ">> " ME @ name strcat " stops recording '" strcat logname @ strcat "' on channel " strcat channel @ strcat " <<" strcat fst3k-notify then ; : logs 0 count ! ">> Available logs: + = campaign, - = archived, * = recording" tell inarg @ strlen 0 > if loglib @ "logs/" inarg @ strcat "/" strcat nextprop logname ! else loglib @ "logs/" nextprop logname ! then begin logname @ strlen 0 > while loglib @ logname @ getpropval 0 > if systime loglib @ logname @ "/time" strcat getpropval - age ! 1000000 age @ age @ 86400 % - 86400 / + intostr "|" strcat loglib @ logname @ "/status" strcat getpropstr "recording" strcmp if "- \"" strcat else "* \"" strcat then logname @ 5 strcut swap pop strcat "\"" strcat dup strlen 48 > if " (" strcat else " " strcat 48 strcut pop "(" strcat then age @ age @ 86400 % - 86400 / intostr strcat " days/" strcat loglib @ logname @ getpropval intostr strcat " lines)" strcat count @ 1 + count ! else "+ " logname @ 5 strcut swap pop strcat loglib @ logname @ getprop if " (" strcat loglib @ logname @ getprop strcat ")" strcat then tell then loglib @ logname @ nextprop logname ! repeat count @ 0 = if " None" tell else inarg @ strlen 0 > if ">> Displaying/sorting " count @ intostr strcat " logs for \"" strcat loglib @ "logs/" inarg @ strcat getprop strcat "\":" strcat tell else ">> Displaying/sorting " count @ intostr strcat " logs:" strcat tell then count @ sort begin count @ 0 > while 8 strcut swap pop tell count @ 1 - count ! repeat then ">> Done." tell ; : setlog holodeck "recording" getpropstr "yes" strcmp not if ">> You must do 'stoplog' first <<" tell exit then log-status "recording" strcmp not if ">> That log is already being recorded to! <<" tell exit then inarg @ strlen 0 > if loglib @ "logs/" inarg @ strcat getpropval 0 > if ">> Current log reset to \"" inarg @ strcat "\"" strcat tell else ">> New log will be named \"" inarg @ strcat "\"" strcat tell then holodeck "logname" inarg @ setprop holodeck ME @ ">> " ME @ name strcat " sets the log to '" strcat inarg @ strcat "' <<" strcat notify_except else ">> You must specify a log name. Type 'logs' to list existing logs." tell then ; : viewrange get-line not if ">> There are no recorded lines in this log." tell exit then begin startline @ stopline @ <= while loglib @ log-propdir startline @ intostr strcat getpropstr inarg ! inarg @ "||" instring if inarg @ "||" explode pop pop inarg ! then inarg @ strlen if shownumbers @ if " " 4 startline @ intostr strlen - strcut pop startline @ intostr strcat ": " strcat inarg @ strcat tell else inarg @ "
" "
" subst "I>" "i>" subst "B>" "b>" subst "U>" "u>" subst "" "" "
    " subst CLOSEUP_CLOSE "
" subst inarg ! COMMAND @ "printlog" strcmp if inarg @ "/" "" subst "*" "" subst "_" "" subst "/" "" subst "*" "" subst "_" "" subst "[ " CLOSEUP_OPEN subst " ]" CLOSEUP_CLOSE subst inarg ! inarg @ "" instr if inarg @ "
" explode count ! 1 index ! begin index @ count @ <= while inarg ! " " inarg @ striplead strcat tell index @ 1 + index ! repeat else " " inarg @ strcat tell then else " " inarg @ strcat tell then else inarg @ italics-convert bold-convert underline-convert inarg ! inarg @ "