home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 2 / goldfish_vol2_cd1.bin / files / comm / mail / thor / thor.lha / Scripts / AMBBS.script
Encoding:
Text File  |  1994-08-06  |  25.4 KB  |  1,100 lines

  1. ; $VER: AMBBS.script 1.50 (06.08.94)
  2. ; ABBS/MBBS Script for THOR
  3. ; By Eivind Nordseth, Ultima Thule Software
  4.  
  5.     REQUEST OFF
  6.  
  7.     set $dox = ""
  8.     set $oldconf = ""
  9.     set $gethold = "FALSE"
  10.     set $errmsg = ""
  11.     set $fixtimeout = ""
  12.     set $dtmpfile = ""
  13.     set $dropconfcap = ""
  14.     set $readmode = ""
  15.     set $private = ""
  16.     set $userinfo = "FALSE"
  17.     set $repfile = ""
  18.     set $qwkcommand = "Q QWK"
  19.     set $qwkcfg = "FALSE"
  20.     set $qwkerr = "TRUE"
  21.     set $rengrab = ""
  22.     set $doctrlx = "FALSE"
  23.     set $dogreet3 = "FALSE"
  24.  
  25.     cli "thor:bin/ScriptServ \""$BBSName"\" WRITECFG"
  26.     if exists "t:privupl"$BBSName then cli "delete >nil: \"t:privupl"$BBSName"\""
  27.     if exists "t:NoLogOut" then cli "delete >nil: t:NoLogOut"
  28.  
  29.     varfile "t:"$BBSName".CONFIG"
  30.  
  31.     readvar $BBSID
  32.     readvar $BBSType
  33.     readvar $UserName
  34.     readvar $Path
  35.     readvar $PostConf
  36.     readvar $UpLoadDir
  37.     readvar $NewFiles
  38.     readvar $AutoPDnl
  39.     readvar $AutoLogoff
  40.     readvar $UseColors
  41.     readvar $Name
  42.     varfile close
  43.  
  44.     cli "delete >nil: \"t:"$BBSName".CONFIG\""
  45.  
  46.     set $LogFile = $Path"ScriptMsg.txt"
  47.  
  48.     when "\r\nNO CARRIER\r\n" goto AllDone
  49.     send "^K\n\n"
  50.  
  51.     autoxfer off ; Turn off G&R commands
  52.     autoup off   ; Turn off Zmodem autoupload
  53.     autodown on  ; Turn on Zmodem autodownload
  54.  
  55.     if !$BBSType == "MBBS_SP_QWK" then goto noSPMBBS
  56.     set $qwkcommand = "Q SP QWK"
  57.     set $BBSType = "MBBS_QWK"
  58.     
  59. noSPMBBS:
  60.     if $BBSType == "MBBS"     then menuselect TRANSLATE 1 8 ; Use IBN character set
  61.     if $BBSType == "ABBS"     then menuselect TRANSLATE 1 0 ; Use ISO character set
  62.     if $BBSType == "MBBS_QWK" then menuselect TRANSLATE 1 8 ; Use IBN character set
  63.     if $BBSType == "ABBS_QWK" then menuselect TRANSLATE 1 0 ; Use ISO character set
  64.  
  65.     converse "FIRST name?" $UserName" Q\n"
  66.     converse "will echo):" "\p\n" ; ^K^K slettet her.
  67.  
  68.     if $BBSType == "ABBS_QWK" then menuselect TRANSLATE 1 8 ; Use IBN character set
  69.  
  70.     when "From #3: Just" set $dogreet3 = "TRUE"
  71.     when "--more--" send "C"
  72.     when "coming online" gosub SysOp
  73.     when "Include original" send "\n"
  74.     when "Private message" send $private"\n"
  75.     when "other users (Enter=N)" send "\n"
  76.     when "Kommando" send "U SPR;;\n"
  77.     when "The following" gosub GotPrivUpl
  78.  
  79.     gosub SetupTimeout
  80.  
  81.     if $BBSType == "MBBS"     then set $docmd = "CHAT N U L 0 S IBN\n"
  82.     if $BBSType == "ABBS"     then set $docmd = "CHAT N U L 0 S ISO GF MBBS\n"
  83.     if $BBSType == "MBBS_QWK" then set $docmd = "CHAT N U L 0 S IBN\n"
  84.     if $BBSType == "ABBS_QWK" then set $docmd = "CHAT N U L 0 S IBN GF QWK\n"
  85.     gosub DoCommand
  86.     dlwhen
  87.     dlwhen            ; Last whens not needed anymore
  88.  
  89. ;***************** Event loop
  90.  
  91.     while exists "t:"$BBSName".EVENT" DO
  92.  
  93.     varfile "t:"$BBSName".EVENT"
  94.  
  95.     readvar $eventnr
  96.     readvar $event
  97.     readvar $sendto
  98.     readvar $conf
  99.     readvar $msgfile
  100.     readvar $replyto
  101.     readvar $subject
  102.     readvar $private
  103.     readvar $filename
  104.     readvar $notify
  105.     readvar $filedescr
  106.     readvar $detailed
  107.     readvar $frommsgnr
  108.     readvar $tomsgnr
  109.     readvar $localfile
  110.     readvar $commandstring
  111.     readvar $boolean
  112.  
  113.     varfile close
  114.  
  115.     if $doctrlx == "TRUE" then send "^X"
  116.     set $doctrlx = "FALSE"
  117.  
  118.     if $event == "0"  then gosub EnterMsg
  119.     if $event == "1"  then gosub ReplyMsg
  120.     if $event == "2"  then gosub JoinConf
  121.     if $event == "3"  then gosub ResignConf
  122.     if $event == "4"  then gosub DownloadFile
  123.     if $event == "5"  then gosub UploadFile
  124.     if $event == "6"  then gosub GetConfList
  125.     if $event == "7"  then gosub ConfigureBBS  ; Event not in Thor, yet.
  126.     if $event == "8"  then gosub SendUserInfo
  127.     if $event == "10" then gosub GetNewFiles
  128.     if $event == "11" then gosub CommandEvent
  129.     if $event == "12" then gosub AutoLogOff
  130.  
  131.     cli "thor:bin/ScriptServ \""$BBSName"\" DONE "$eventnr
  132.  
  133.     endwhile
  134.     
  135.     if $doctrlx == "TRUE" then send "^X"
  136.     set $rengrab = "y"
  137.  
  138. ;***************** Grab messages
  139.  
  140.     if $BBSType == "MBBS_QWK" then goto HandleMBBSQWK
  141.     if $BBSType == "ABBS_QWK" then goto HandleABBSQWK
  142.     set $docmd = "R DUMP ALL\n"
  143.     gosub DoCommand
  144.     gosub NoTimeout
  145.  
  146.     when "<0>" goto grabd
  147.  
  148.     converse "Command" "SE Z\n^K"
  149.     gosub NoTimeout
  150.  
  151. grabd:
  152.     dlwhen
  153.  
  154.     goto AfterGrabing
  155.  
  156. ;***************** Do ABBS_QWK packet handling
  157. HandleABBSQWK:
  158.     if !exists $UpLoadDir$BBSID".REP" then goto NoABBSRepFile
  159.     
  160.     set $docmd = "Q MU\n"
  161.     gosub DoCommand
  162.  
  163.     when "parsed successfully" set $qwkerr = "FALSE"
  164.  
  165.     wait "B01"
  166.     upload $UpLoadDir$BBSID".REP",Z
  167.     gosub NoTimeout
  168.  
  169.     capture $Path"QWKMsg.txt"
  170.  
  171.     wait "Main Command"
  172.  
  173.     capture off
  174.     dlwhen
  175.     gosub SetUpTimeout
  176.  
  177.     if $qwkerr == "TRUE" then goto ABBSRepFileFail
  178.  
  179.     cli "delete >nil: "$UpLoadDir$BBSID".REP"
  180.     cli "thor:bin/ScriptServ \""$BBSName"\" PACKAGEDONE"
  181.     cli "delete >nil: "$Path"QWKMsg.txt"
  182.     send "^X"
  183.     goto NoABBSRepFile
  184.  
  185. ABBSRepFileFail:
  186.     set $appendsource = $Path"QWKMsg.txt"
  187.     set $appenddest = $LogFile
  188.     gosub AppendFile
  189.     send "^X"
  190.  
  191. NoABBSRepFile:
  192.     
  193.     set $docmd = "R DUMP ALL\n"
  194.     gosub DoCommand
  195.     gosub NoTimeout
  196.  
  197.     when "<0>" goto grabd2
  198.  
  199.     converse "Command" "SE Z\n^K"
  200.  
  201. grabd2:
  202.     dlwhen
  203.  
  204.     goto AfterGrabing
  205.  
  206. ;***************** Do MBBS_QWK packet handling
  207. HandleMBBSQWK:
  208.     set $docmd = $qwkcommand"\n"
  209.     gosub DoCommand
  210.  
  211.     wait "QWK (? for menu)"
  212.     
  213.     if $qwkcfg == "FALSE" then goto NoQWKConfig
  214.     send "C"
  215.     
  216.     converse "ation (? for menu)" "P"
  217.     converse "se a packer" "L"
  218.     converse "ation (? for menu)" "O"
  219.     converse "se a protocol" "Z"
  220.  
  221.     wait "ation (? for menu)"
  222.     set $qwkfilelist = "y"
  223.     when "New file list Off" set $qwkfilelist = "n"
  224.     send "F"
  225.     wait "ation (? for menu)"
  226.     dlwhen    
  227.     if $qwkfilelist == $NewFiles then goto NoChgQWKList
  228.  
  229.     send "F"
  230.     wait "ation (? for menu)"
  231.     
  232. NoChgQWKList:
  233.     send "R"
  234.     wait "QWK (? for menu)"
  235.  
  236. NoQWKConfig:
  237.     if !exists $UpLoadDir$BBSID".REP" then goto NoRepFile
  238.  
  239.     when "REP-file ok." set $repfile = "OK"
  240.  
  241.     send "U"
  242.     wait "B01"
  243.     upload $UpLoadDir$BBSID".REP",Z
  244.     gosub NoTimeout
  245.  
  246.     wait "Reading REP"
  247.     capture $Path"QWKMsg.txt"
  248.  
  249.     wait "QWK (? for menu)"
  250.     capture off
  251.  
  252.     dlwhen
  253.     gosub SetUpTimeout
  254.     if !$repfile == "OK" then goto RepFileFail
  255.  
  256.     cli "delete >nil: "$UpLoadDir$BBSID".REP"
  257.     cli "thor:bin/ScriptServ \""$BBSName"\" PACKAGEDONE"
  258.     cli "delete >nil: "$Path"QWKMsg.txt"
  259.     goto NoRepFile
  260.  
  261. RepFileFail:
  262.     set $appendsource = $Path"QWKMsg.txt"
  263.     set $appenddest = $LogFile
  264.     gosub AppendFile
  265.  
  266. NoRepFile:
  267.     send "D"
  268.     gosub NoTimeout
  269.     when "Something's gone wrong!" goto QWKWrong
  270.     when "transferred with the packet?" send "N\n"
  271.     
  272.     converse "QWK (? for menu)" "R"
  273.  
  274.     timeout 3 goto QWKDone
  275. QWKLoop:
  276.     wait ""
  277.     goto QWKLoop
  278. QWKWrong:
  279.     wait "Command"
  280.     gosub Startlogfile
  281.     write $LogFile "Error:  MBBS-QWK failed making package\n"
  282.  
  283. QWKDone:
  284.     dlwhen
  285.     dlwhen
  286.     gosub SetUpTimeout
  287.     send "^X"
  288.  
  289.  
  290. ;***************** Rename the grab
  291.  
  292. AfterGrabing:
  293.     set $rengrab = "y"
  294.  
  295. ;***************** Auto dnload private files
  296.  
  297.     if !$AutoPDnl == "y" then goto NoPrivUpl
  298.     if !exists "t:privupl"$BBSName then goto NoPrivUpl
  299.  
  300.     cli "thor:bin/ScriptServ >\"t:privupl"$BBSName".tmp\" \""$BBSName"\" PrivUploadFile \"t:privupl"$BBSName"\""
  301.  
  302.     if !exists "t:privupl"$BBSName".tmp" then goto NoPrivUpl
  303.  
  304.     varfile "t:privupl"$BBSName".tmp"
  305.  
  306. PrivLoop:
  307.     readvar $filename    
  308.     if $filename == "" then goto PrivLoopEnd
  309.     if $filename == "EOF" then goto PrivLoopEnd
  310.     
  311.     gosub dfPlain
  312.     goto PrivLoop
  313.  
  314. PrivLoopEnd:
  315.     varfile close
  316.     cli "delete >nil: \"t:privupl"$BBSName".tmp\""
  317.  
  318. NoPrivUpl:
  319.  
  320. ;***************** Get files in hold
  321.  
  322.     if exists "t:privupl"$BBSName then cli "delete >nil: \"t:privupl"$BBSName"\""
  323.     if !$gethold == "TRUE" then goto NoHold
  324.  
  325.     set $docmd = "F GET\n"
  326.     gosub DoCommand
  327.     gosub NoTimeout
  328.  
  329.     set $docmd = "F DEL *\n"
  330.     gosub DoCommand
  331.  
  332. NoHold:
  333.     if $BBSType == "MBBS_QWK" then goto AfterNewFiles
  334.     if !$NewFiles == "y" then goto AfterNewFiles
  335.  
  336. ;***************** Capture Newfiles.txt
  337.  
  338.     set $docmd = ""
  339.     gosub DoCommand
  340.  
  341.     when "Detailed list (Enter=N):" send "n\n"
  342.  
  343.     cli "Delete >nil: "$Path"Newfiles.txt"
  344.     capture $Path"Newfiles.txt"
  345.     send "F N ;;\n"
  346.     gosub NoTimeout
  347.  
  348.     when "Read Command" goto NewFilesDone
  349.     wait "File Command"
  350.  
  351. NewFilesDone:
  352.     dwhen "Read Command"
  353.     dwhen "Detailed list (Enter=N):"
  354.     capture off
  355.     send "^X"
  356.  
  357. AfterNewFiles:
  358.  
  359. ;***************** Ready for logout
  360.  
  361.     if $AutoLogoff == "n" then goto NoLogOut
  362.  
  363.     if exists "t:NoLogOut" then goto NoLogOut
  364.  
  365.     set $docmd = "CHAT A U L 26\n"
  366.     gosub DoCommand
  367.  
  368.     set $docmd = "G Y N Y\n"
  369.     gosub DoCommand
  370.  
  371.     when "\r\nNO CARRIER\r\n" goto Hanged
  372.     delay 2
  373.     repeat
  374.     hangup
  375.     delay 2
  376.     until !CARRIER
  377.  
  378. Hanged:
  379.     dlwhen
  380.     goto AllDone
  381.  
  382. NoLogOut:
  383.     set $docmd = "CHAT A U L 26 W R\n"
  384.     gosub DoCommand
  385.  
  386.     dwhens
  387.     timeout 0
  388.     wait "\r\nNO CARRIER\r\n"
  389.  
  390. AllDone:
  391.     CLI "run >nil: rx thor:rexx/AddFileNote.rexx"
  392.     request on
  393.     end
  394.  
  395. SendReturn:
  396.     if $Timeouts == "2" then timeout 20 gosub Hung
  397.     if $Timeouts == "1" then set $Timeouts = "2"
  398.     if $Timeouts == "0" then set $Timeouts = "1"
  399.     send "^X"
  400.     return
  401.  
  402. Hung:
  403.     beep
  404.     message "\nI think the board has hung."
  405.     message "\nTurn off this script within 20 seconds to stop me from logging out !!"
  406.     delay 20
  407.     beep
  408.     message "\nWARNING: Logout in progress.\n"
  409.     hangup
  410.     goto AllDone
  411.  
  412. SysOp:
  413.     send "Sorry, you are trying to chat with a script.\n"
  414.     send "Please put me back to the BBS at once.\n"
  415.     set $Timeouts = "0"
  416.     wait "SYSOP is going offline!"
  417.     set $Timeouts = "0"
  418.     return
  419.  
  420.  
  421. ;************************************************
  422. DoCommand:
  423.     if $dogreet3 == "TRUE" then converse "Command" "no 4 Yo! This script represents "$Name"\n"
  424.     converse "Command" $docmd
  425.     if !$fixtimeout == "" then gosub SetupTimeout
  426.     if !$dtmpfile == "" then gosub DelDFwhens
  427.     if !$dropconfcap == "" then gosub DropConfCap
  428.     if !$rengrab == "" then gosub RenameGrab
  429.     set $dogreet3 = "FALSE"
  430.     return
  431.  
  432.  
  433. ;************************************************
  434. GotPrivUpl:
  435.     capture "t:privupl"$BBSName
  436.  
  437.     wait "Comman"
  438.     send "^X"
  439.     capture off
  440.     return
  441.  
  442. ;************************************************
  443. ; Enter message subroutine
  444. ; Uses variables:
  445. ;    $conf         - conference for message
  446. ;    $sendto     - user message is to (Empty string is equal to ALL)
  447. ;    $subject    - subject of message
  448. ;    $msgfile    - file message is in
  449. ;    $private    - private message (y/n)
  450. EnterMsg:
  451.     if !EXISTS $Path$msgfile then return
  452.  
  453.     when "enter both the first AND" gosub etomyself
  454.     when "that name is not registered" gosub etomyself
  455.     when "ALL is not allowed here!" gosub etomyself
  456.  
  457.     when "READ ONLY conference. Us" goto einpost1
  458.     when "not a member of this con" goto einpost2
  459.     when "Invalid conference selec" goto einpost3
  460.     when "Topics are:"              goto einpost4
  461.     when "Send message to" gosub sendmsgto
  462.  
  463. doconf:
  464.     if $conf == $oldconf then goto InConf
  465.  
  466.     converse "Command" "J "$conf"\n"
  467.     if !$fixtimeout == "" then gosub SetupTimeout
  468.     if !$dtmpfile == "" then gosub DelDFwhens
  469.     if !$dropconfcap == "" then gosub DropConfCap
  470.  
  471.     set $oldconf = $conf
  472.  
  473. InConf:
  474.     if $sendto == "" then set $sendto = "ALL"
  475.  
  476.     converse "Command" "E\n"
  477.     if !$fixtimeout == "" then gosub SetupTimeout
  478.     if !$dtmpfile == "" then gosub DelDFwhens
  479.     if !$dropconfcap == "" then gosub DropConfCap
  480.  
  481.  
  482.     set $dlewhen = "FALSE"
  483.     set $dox = ""
  484.     gosub SendMessage
  485.  
  486.     if $dlewhen == "TRUE" then goto DlEWhenDone
  487.     dlwhen
  488.     dlwhen
  489.     dlwhen
  490.     dlwhen
  491.     dlwhen
  492.     dlwhen
  493.     dlwhen
  494.     dlwhen
  495.  
  496.     set $dlewhen = "TRUE"
  497. DlEWhenDone:
  498.     return
  499.  
  500. etomyself:
  501.     gosub Startlogfile
  502.     write $LogFile "Error: Conference "$conf", unable to enter message to "$sendto"\n"
  503.     write $LogFile "       Message entered to yourself\n"
  504.     set $errmsg = "Unable to enter message to "$sendto
  505.     set $sendto = "^X"
  506.     return
  507.  
  508. einpost4:
  509.     gosub Startlogfile
  510.     write $LogFile "Error: Invalid conference topic: "$conf"\n"
  511.     write $LogFile "       Message to "$sendto" entered in "$PostConf" instead\n"
  512.     set $errmsg = "Invalid conference topic: "$conf
  513.     send "\n"
  514.     set $oldconf = ""
  515.     goto einpost
  516. einpost3:
  517.     gosub Startlogfile
  518.     write $LogFile "Error: Invalid conference selection: "$conf"\n"
  519.     write $LogFile "       Message to "$sendto" entered in "$PostConf" instead\n"
  520.     set $errmsg = "Invalid conference selection: "$conf
  521.     gosub FixJoinErr
  522.     set $oldconf = ""
  523.     goto einpost
  524. einpost2:
  525.     gosub Startlogfile
  526.     write $LogFile "Error: User "$sendto" in not a member of conference "$conf"\n"
  527.     write $LogFile "       Message entered in "$PostConf" instead\n"
  528.     set $errmsg = "User "$sendto" in not a member of conference "$conf
  529.     goto einpost
  530. einpost1:
  531.     gosub Startlogfile
  532.     write $LogFile "Error: Conference "$conf" is READ ONLY\n"
  533.     write $LogFile "       Message to "$sendto" entered in "$PostConf" instead\n"
  534.     set $errmsg = "Conference "$conf" is READ ONLY"
  535. einpost:
  536.     set $conf = $PostConf
  537.     goto doconf
  538.  
  539. sendmsgto:
  540.     if $sendto == "^X" then goto smt1
  541.     send $sendto"\n"
  542.     return
  543. smt1:
  544.     set $sendto = $UserName
  545.     send "^X"
  546.     return
  547.  
  548.  
  549. ;************************************************
  550. ; Reply message subroutine
  551. ; Uses variables:
  552. ;    $conf         - conference for message
  553. ;    $replyto     - reply to message
  554. ;    $subject    - subject of message
  555. ;    $msgfile    - file message is in
  556. ;    $private    - private message (y/n)
  557. ;    $sendto        - user the message is to
  558. ReplyMsg:
  559.     if !EXISTS $Path$msgfile then return
  560.  
  561.     when "READ ONLY conference you" goto readonlyconf
  562.     when "Invalid conference selec" goto invalidconf
  563.     when "Topics are:"              goto invalidtopic
  564.     when "not available for reply." goto notavail
  565.     when "not a member of this con" goto nomember
  566.  
  567.     if $conf == $oldconf then goto InConf2
  568.  
  569.     converse "Command" "J "$conf"\n"
  570.     if !$fixtimeout == "" then gosub SetupTimeout
  571.     if !$dtmpfile == "" then gosub DelDFwhens
  572.     if !$dropconfcap == "" then gosub DropConfCap
  573.  
  574.     set $oldconf = $conf
  575. InConf2:
  576.     converse "Command" "R RE "$replyto"\n"
  577.     if !$fixtimeout == "" then gosub SetupTimeout
  578.     if !$dtmpfile == "" then gosub DelDFwhens
  579.     if !$dropconfcap == "" then gosub DropConfCap
  580.  
  581.     set $dlrewhen = "FALSE"
  582.     set $dox = "^X"
  583.     gosub SendMessage
  584.  
  585.     if $dlrewhen == "TRUE" then goto DlReWhenDone
  586.     dlwhen
  587.     dlwhen
  588.     dlwhen
  589.     dlwhen
  590.     dlwhen
  591.  
  592.     set $dlrewhen = "TRUE"
  593. DlReWhenDone:
  594.     return
  595.  
  596. readonlyconf:
  597.     gosub Startlogfile
  598.     write $LogFile "Error: Conference "$conf" is READ ONLY, unable to reply message "$replyto"\n"
  599.     write $LogFile "       Message entered in "$PostConf" instead\n"
  600.     set $errmsg = "Conference "$conf" is READ ONLY, unable to reply message "$replyto
  601.     set $conf = $PostConf
  602.  
  603.     goto na1
  604.  
  605. invalidconf:
  606.     gosub Startlogfile
  607.     write $LogFile "Error: Invalid conference selection: "$conf"\n"
  608.     write $LogFile "       Unable to reply message "$replyto"\n"
  609.     write $LogFile "       Message entered in "$PostConf" instead\n"
  610.     set $errmsg = "Invalid conference selection: "$conf"\n  Unable to reply message "$replyto
  611.  
  612.     set $conf = $PostConf
  613.  
  614.     gosub FixJoinErr
  615.  
  616.     goto na1
  617.  
  618. invalidconf:
  619.     gosub Startlogfile
  620.     write $LogFile "Error: Invalid conference topic: "$conf"\n"
  621.     write $LogFile "       Unable to reply message "$replyto"\n"
  622.     write $LogFile "       Message entered in "$PostConf" instead\n"
  623.     set $errmsg = "Invalid conference topic: "$conf"\n  Unable to reply message "$replyto
  624.     set $conf = $PostConf
  625.     send "\n"
  626.     goto na1
  627.  
  628. nomember:
  629.     gosub Startlogfile
  630.     write $LogFile "Error: "$sendto" is not member of conference: "$conf"\n"
  631.     write $LogFile "       Unable to reply message "$replyto"\n"
  632.     write $LogFile "       Message entered in "$PostConf" instead\n"
  633.     set $errmsg = $sendto" is not a member of conference: "$conf"\n  Unable to reply message "$replyto 
  634.  
  635.     set $conf = $PostConf
  636.  
  637.     goto na1
  638.  
  639. notavail:
  640.     if $private == "y" then goto napriv
  641.  
  642.     gosub Startlogfile
  643.     write $LogFile "Error: Message "$replyto" in "$conf" not available for reply\n"
  644.     write $LogFile "       Message entered instead\n"
  645.     set $errmsg = "Message "$replyto" not available for reply"
  646.  
  647.     goto na1
  648.  
  649. napriv:
  650.     gosub Startlogfile
  651.     write $LogFile "Error: Message "$replyto" in "$conf" not available for reply\n"
  652.     write $LogFile "       Message entered in "$PostConf" instead\n"
  653.     set $errmsg = "Message "$replyto" in "$conf" is not available for reply"
  654.  
  655.     set $conf = $PostConf
  656.  
  657. na1:
  658.     set $dlrewhen = "TRUE"
  659.     dlwhen
  660.     dlwhen
  661.     dlwhen
  662.     dlwhen
  663.     dlwhen
  664.     goto Entermsg
  665.  
  666. ;************************************************
  667. ; Subroutine for sending message
  668. SendMessage:
  669.     when "--7-" goto sendit
  670.     converse "Subject" $dox$subject"\n"
  671.     wait "--7-"
  672. sendit:
  673.     dlwhen
  674.     if $userinfo == "FALSE" then goto nouserinfo
  675.  
  676.     if $BBSType == "ABBS"     then gosub SendABBSClear
  677.     if $BBSType == "ABBS_QWK" then gosub SendABBSClear
  678.  
  679.     if $BBSType == "MBBS"     then send "^KC" 
  680.     if $BBSType == "MBBS_QWK" then send "^KC" 
  681.     
  682. nouserinfo:
  683.     send "^KZ"
  684.     if $errmsg == "" then goto noerrmsg
  685.     send "Thor scripting error:\n  "$errmsg"\n\n"
  686.     set $errmsg = ""
  687. noerrmsg:
  688.     ascsend $Path$msgfile
  689.  
  690.     send "\w^Z^Z"
  691.     return
  692.  
  693. ;************************************************
  694. ; ABBS clear editor
  695. SendABBSClear:
  696.     send "^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y" 
  697.     send "^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y" 
  698.     send "^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y" 
  699.     send "^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y" 
  700.     send "^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y" 
  701.     send "^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y" 
  702.     send "^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y" 
  703.     send "^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y" 
  704.     send "^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y" 
  705.     send "^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y" 
  706.     send "^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y" 
  707.     send "^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y" 
  708.     send "^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y" 
  709.     send "^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y" 
  710.     send "^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y" 
  711.     send "^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y" 
  712.     return
  713.  
  714. ;************************************************
  715. ; Download file subroutine
  716. ; Uses variables:
  717. ;    $filename - name of file to download
  718. DownloadFile:
  719.     converse "Command" "F ADD "$filename"\n"
  720.     if !$fixtimeout == "" then gosub SetupTimeout
  721.     if !$dtmpfile == "" then gosub DelDFwhens
  722.     if !$dropconfcap == "" then gosub DropConfCap
  723.  
  724.     set $dtmpfile = $filename
  725.     capture "t:filedesc.txt"
  726.     when "File not found!" gosub fnotfound
  727.     when "You are not allowed" gosub fnotaccess
  728.     when "ate files may not be move" gosub dferr
  729.     set $gethold = "TRUE"
  730.     return
  731.  
  732. dferr:
  733.     converse "Command" "F D "$dtmpfile"\n"
  734.     gosub NoTimeout
  735.     return
  736.  
  737. dfPlain:
  738.     set $docmd = "F D "$filename"\n"
  739.     gosub DoCommand
  740.  
  741.     set $dtmpfile = $filename
  742.     capture "t:filedesc.txt"
  743.     when "File not found!" gosub fnotfound
  744.     when "You are not allowed" gosub fnotaccess
  745.     when "ate files may not be move" gosub dfPlain
  746.     gosub NoTimeout
  747.  
  748.     return
  749.  
  750. fnotaccess:
  751.     gosub Startlogfile
  752.     write $LogFile "Error: Unable to download file \""$dtmpfile"\", you don't have download access\n"
  753.     return
  754.  
  755. fnotfound:
  756.     gosub Startlogfile
  757.     write $LogFile "Error: Unable to download file \""$dtmpfile"\", file not found\n"
  758.     return
  759.  
  760. DelDFwhens:
  761.     dwhen "File not found!"
  762.     dwhen "You are not allowed"
  763.     dwhen "ate files may not be move"
  764.     set $dtmpfile = ""
  765.     capture off
  766.     return
  767.  
  768. ;************************************************
  769. NoTimeout:
  770.     set $fixtimeout = "d"
  771.     timeout 0
  772.     return
  773.  
  774. SetupTimeout:
  775.     set $fixtimeout = ""
  776.     set $Timeouts = "0"
  777.     timeout 60 gosub sendreturn
  778.     return
  779.  
  780. ;************************************************
  781. GetConfList:
  782.     set $docmd = ""
  783.     gosub DoCommand
  784.  
  785.     cli "Delete >nil: "$Path"Conferences.txt"
  786.     capture $Path"Conferences.txt"
  787.  
  788.     when "<U>nread" SEND "A\n"
  789.     send "R SH\n"
  790.     set $dropconfcap = "j"
  791.  
  792.     return
  793.  
  794. DropConfCap:
  795.     dwhen "<U>nread"
  796.     capture off
  797.     set $dropconfcap = ""
  798.     return
  799.  
  800. ;************************************************
  801. ; Upload file subroutine
  802. ; Uses variables:
  803. ;    $filename    - name of file to upload
  804. ;    $filedescr    - short description of file
  805. ;    $notify        - download notification (y/n)
  806. ;    $detailed    - detailed description (y/n)
  807. ;    $sendto        - private upload to user (empty string/"ALL" = public file)
  808. ;    $localfile    - path/filename to upload.
  809. ;    $conf        - Try to make file private to conf (if $conf != "")
  810.  
  811. UploadFile:
  812.     set $msgfile = ""
  813.  
  814.     if $localfile == "" then set $localfile = $UpLoadDir$filename
  815.     if !exists $localfile then goto nofileupload
  816.  
  817.     if !$conf == "" then gosub JoinConf
  818.  
  819.     when "enter both the first AND" goto puperr
  820.     when "that name is not registered" goto puperr
  821.     when "ALL is not allowed here!" goto puperr
  822.  
  823.     when "Invalid file name!" goto upinvfile
  824.     when "File exists already!" goto fexists
  825.     when "each download" send $notify"\n"
  826.  
  827.     when "file to be publicly ava" send "\n"
  828.     when "Directory name, <?>=lis" send "\n"
  829.  
  830.     if  $conf == "" then when "rivate to confer" send "n\n"
  831.     if !$conf == "" then when "rivate to confer" send "y\n"
  832.  
  833.     if !$sendto == "" then set $docmd = "F PUP "$sendto"\n"
  834.     if $sendto == "ALL" then set $docmd = "F UP\n"
  835.     if $sendto == "" then set $docmd = "F UP\n"
  836.  
  837.     if $doctrlx == "TRUE" then send "^X"
  838.     converse "Command" $docmd
  839.     if !$fixtimeout == "" then gosub SetupTimeout
  840.     if !$dtmpfile == "" then gosub DelDFwhens
  841.     if !$dropconfcap == "" then gosub DropConfCap
  842.  
  843.     converse "ile name" $filename"\n"
  844.     converse "ion of file" $filedescr"\n"
  845.  
  846.     wait "B01"
  847.  
  848.     upload $localfile,Z
  849.     gosub NoTimeout
  850.  
  851.     when "Command" goto uplfail
  852.  
  853.     if $detailed == "" then goto NoDetailed
  854.  
  855.     converse "description (Enter=Y)" "Y\n"
  856.     gosub SetupTimeout
  857.     set $msgfile = $detailed
  858.     gosub SendMessage
  859.     goto fixfail
  860.  
  861. NoDetailed:
  862.     converse "description (Enter=Y)" "N\n"
  863.  
  864. fixfail:
  865.     dlwhen    
  866. fixupl: dlwhen
  867.     dlwhen
  868.     dlwhen
  869.     dlwhen
  870.     dlwhen
  871.     dlwhen
  872.     dlwhen
  873.  
  874.     wait "Command"
  875.     set $doctrlx = "TRUE"
  876.     return
  877.  
  878. puperr:
  879.     gosub Startlogfile
  880.     write $LogFile "Error: Unable to do a private upload of "$filename"\n"
  881.     write $LogFile "       User "$sendto" is not registered\n"
  882.     send "^X\n"
  883.     goto fixupl
  884.  
  885. upinvfile:
  886.     gosub Startlogfile
  887.     write $LogFile "Error: Unable to upload "$filename", filename is invalid\n"
  888.     send "^X\n"
  889.     goto fixupl
  890.  
  891. fexists:
  892.     gosub Startlogfile
  893.     write $LogFile "Error: Unable to upload "$filename", file already exists\n"
  894.     send "^X\n"
  895.     goto fixupl
  896.  
  897. nofileupload:
  898.     gosub Startlogfile
  899.     write $LogFile "Error: Unable to upload "$filename", file not found\n"
  900.     return    
  901.  
  902. uplfail:
  903.     gosub Startlogfile
  904.     write $LogFile "Error: Unable to upload "$filename", upload failed\n"
  905.     goto fixfail
  906.  
  907. ;************************************************
  908. ; Join conference
  909. ; Uses variables:
  910. ;    $conf - conference to join
  911. JoinConf:
  912.     when "Invalid conference sele" gosub joinerr
  913.     when "Topics are:" gosub topicserr
  914.  
  915.     set $docmd = "J "$conf"\n"
  916.     gosub DoCommand
  917.     set $oldconf = $conf
  918.  
  919.     wait "Command"
  920.     dwhen "Invalid conference sele"
  921.     dwhen "Topics are:"
  922.     set $doctrlx = "TRUE"
  923.     
  924.     return
  925.  
  926. joinerr:
  927.     gosub Startlogfile
  928.     write $LogFile "Error: Invalid conference selection: "$conf", Unable to join\n"
  929.     gosub FixJoinErr
  930.     set $oldconf = ""
  931.     return
  932.  
  933. topicserr:
  934.     gosub Startlogfile
  935.     write $LogFile "Error: Invalid conference topic: "$conf", Unable to join\n"
  936.     send "\n"
  937.     set $oldconf = ""
  938.     return
  939.     
  940.     
  941. ;************************************************
  942. ; Resign conference
  943. ; Uses variables:
  944. ;    $conf - conference to resign
  945. ResignConf:
  946.     when "Invalid conference sel" goto reserr
  947.  
  948.     converse "Command" "J "$conf"\n"
  949.     if !$fixtimeout == "" then gosub SetupTimeout
  950.     if !$dtmpfile == "" then gosub DelDFwhens
  951.     if !$dropconfcap == "" then gosub DropConfCap
  952.  
  953.     converse "Command" "RES Y\n"
  954.     if !$fixtimeout == "" then gosub SetupTimeout
  955.     if !$dtmpfile == "" then gosub DelDFwhens
  956.     if !$dropconfcap == "" then gosub DropConfCap
  957.  
  958.     set $oldconf = ""
  959. fixresign:
  960.     dlwhen
  961.  
  962.     return
  963.  
  964. reserr:
  965.     gosub Startlogfile
  966.     write $LogFile "Error: Invalid conference selection: "$conf", Unable to resign\n"
  967.  
  968.     gosub FixJoinErr
  969.     
  970.     goto fixresign
  971.  
  972. ;************************************************
  973. Startlogfile:
  974.     if !exists $LogFile then write $LogFile "Messages from script:\n"
  975.     return
  976.  
  977. ;************************************************
  978. ; Send user info
  979. ; Uses variables:
  980. ;    $msgfile    - file user info is in
  981. SendUserInfo:
  982.     converse "Command" "Q EDIT\n"
  983.     if !$fixtimeout == "" then gosub SetupTimeout
  984.     if !$dtmpfile == "" then gosub DelDFwhens
  985.     if !$dropconfcap == "" then gosub DropConfCap
  986.  
  987.     converse "number displayed (Enter=" "y\n"
  988.  
  989.     set $userinfo = "TRUE"
  990.  
  991.     gosub SendMessage
  992.  
  993.     set $userinfo = "FALSE"
  994.  
  995.     return
  996.  
  997. ;************************************************
  998. FixJoinErr:
  999.     if $BBSType == "MBBS" then converse "name to join" "\n"
  1000.     if $BBSType == "MBBS_QWK" then converse "name to join" "\n"
  1001.  
  1002.     if $BBSType == "ABBS" then send "^K"
  1003.     if $BBSType == "ABBS" then converse "Join conference:" "\n"
  1004.  
  1005.     return
  1006.  
  1007. ;************************************************
  1008. RenameGrab:
  1009.     set $rengrab = ""
  1010.     cli "thor:bin/ScriptServ \""$BBSName"\" RENAMEGRAB"
  1011.     cli "run >nil: sys:rexxc/rx 'address THOR.01 RESCAN'"
  1012.     return
  1013.     
  1014. ;************************************************
  1015. ; Append a file to the en of the other.
  1016. ; Uses variables:
  1017. ;  $appendsource - File to append.
  1018. ;  $appenddest   - Destination.
  1019. AppendFile:
  1020.     if !exists $appenddest then goto afNotExists
  1021.  
  1022.     cli "join >nil: \""$appenddest"\" \""$appendsource"\" TO \""$appenddest".tmp\""
  1023.     cli "delete >nil: \""$appenddest"\""
  1024.     cli "rename >nil: \""$appenddest".tmp\" \""$appenddest"\""
  1025.     cli "delete >nil: \""$appendsource"\""
  1026.     return    
  1027.  
  1028. afNotExists:
  1029.     cli "rename >nil: \""$appendsource"\" \""$appenddest"\""
  1030.     return
  1031.  
  1032. ;************************************************
  1033. ; Do a custom command
  1034. ; Uses variables:
  1035. ;  $commandstring - Command to execute.
  1036. CommandEvent:
  1037.     write $LogFile "Executing custom command:\n"
  1038.  
  1039.     converse "Command" $commandstring"\n"
  1040.     if !$fixtimeout == "" then gosub SetupTimeout
  1041.     if !$dtmpfile == "" then gosub DelDFwhens
  1042.     if !$dropconfcap == "" then gosub DropConfCap
  1043.     capture $LogFile
  1044.  
  1045.     wait "Command"
  1046.     capture off
  1047.     write $LogFile "\n"
  1048.     set $doctrlx = "TRUE"
  1049.     return
  1050.  
  1051. ;************************************************
  1052. GetNewFiles:
  1053.     set $NewFiles = "y"
  1054.     wait "Command"
  1055.     set $doctrlx = "TRUE"
  1056.     return
  1057.  
  1058. ;************************************************
  1059. ; Set the autologoff flag.
  1060. ; Uses variables:
  1061. ;  $boolean - Logoff (y/n)
  1062. AutoLogOff:
  1063.     set $AutoLogoff = $boolean
  1064.     wait "Command"
  1065.     set $doctrlx = "TRUE"
  1066.     return
  1067.  
  1068. ;************************************************
  1069. ; Set up BBS configuration
  1070. ConfigureBBS:
  1071.     if $BBSType == "MBBS" then goto SetMBBSMode
  1072.     if $BBSType == "MBBS_QWK" then goto SetMBBSMode
  1073.  
  1074.     set $docmd = "R\n"
  1075.     gosub DoCommand
  1076.     when "Read Ref Co" set $readmode = "1"
  1077.     when "Read Co" set $readmode = "2"
  1078.     wait "Command"
  1079.     dlwhen
  1080.     dlwhen
  1081.     send "^X"
  1082.     if $readmode == "2" then goto AfterSetMode
  1083.     set $docmd = "MODE\n"
  1084.     gosub DoCommand
  1085.     goto AfterSetMode
  1086.  
  1087. SetMBBSMode:
  1088.     set $qwkcfg = "TRUE"
  1089.  
  1090.     set $docmd = "R MODE M\n"
  1091.     gosub DoCommand
  1092.  
  1093. AfterSetMode:
  1094.     set $docmd = "u m y "$UseColors" "$UseColors" y n y\n"
  1095.     gosub DoCommand
  1096.     if $BBSType == "ABBS" then set $docmd = "sp n n\n"
  1097.     if $BBSType == "ABBS" then gosub DoCommand
  1098.  
  1099.     return
  1100.