; $VER: AMBBS.script 1.31 (31.10.93) ; Script for Ultima THOR System ; By Eivind Nordseth, Ultima Thule Software REQUEST OFF set $dox = "" set $oldconf = "" set $gethold = "FALSE" set $errmsg = "" set $fixtimeout = "" set $dtmpfile = "" set $dropconfcap = "" set $readmode = "" set $private = "" set $userinfo = "FALSE" set $repfile = "" set $qwkcommand = "Q QWK" set $qwkcfg = "FALSE" set $qwkerr = "TRUE" set $rengrab = "" cli "thor:bin/ScriptServ \""$BBSName"\" WRITECFG" if exists "t:privupl"$BBSName then cli "delete >nil: \"t:privupl"$BBSName"\"" if exists "t:NoLogOut" then cli "delete >nil: t:NoLogOut" varfile "t:"$BBSName".CONFIG" readvar $BBSID readvar $BBSType readvar $UserName readvar $Path readvar $PostConf readvar $UpLoadDir readvar $NewFiles readvar $AutoPDnl readvar $AutoLogoff readvar $UseColors varfile close cli "delete >nil: \"t:"$BBSName".CONFIG\"" set $LogFile = $Path"ScriptMsg.txt" when "\r\nNO CARRIER\r\n" goto AllDone send "^K\n\n" autoxfer off ; Turn off G&R commands autoup off ; Turn off Zmodem autoupload autodown on ; Turn on Zmodem autodownload resume off ; Turn off Zmodem resume if !$BBSType == "MBBS_SP_QWK" then goto noSPMBBS set $qwkcommand = "Q SP QWK" set $BBSType = "MBBS_QWK" noSPMBBS: if $BBSType == "MBBS" then menuselect TRANSLATE 1 8 ; Use IBN character set if $BBSType == "ABBS" then menuselect TRANSLATE 1 0 ; Use ISO character set if $BBSType == "MBBS_QWK" then menuselect TRANSLATE 1 8 ; Use IBN character set if $BBSType == "ABBS_QWK" then menuselect TRANSLATE 1 0 ; Use ISO character set converse "FIRST name?" $UserName" Q\n" converse "will echo):" "\p\n" ; ^K^K slettet her. if $BBSType == "ABBS_QWK" then menuselect TRANSLATE 1 8 ; Use IBN character set when "--more--" send "C" when "coming online" gosub SysOp when "Include original" send "\n" when "Private message" send $private"\n" when "other users (Enter=N)" send "\n" when "The following private file(s)" gosub GotPrivUpl gosub SetupTimeout if $BBSType == "MBBS" then set $docmd = "CHAT N U L 0 S IBN\n" if $BBSType == "ABBS" then set $docmd = "CHAT N U L 0 S ISO GF MBBS\n" if $BBSType == "MBBS_QWK" then set $docmd = "CHAT N U L 0 S IBN\n" if $BBSType == "ABBS_QWK" then set $docmd = "CHAT N U L 0 S IBN GF QWK\n" gosub DoCommand dlwhen ; Last when not needed anymore ;***************** Event loop while exists "t:"$BBSName".EVENT" DO varfile "t:"$BBSName".EVENT" readvar $eventnr readvar $event readvar $sendto readvar $conf readvar $msgfile readvar $replyto readvar $subject readvar $private readvar $filename readvar $notify readvar $filedescr readvar $detailed readvar $frommsgnr readvar $tomsgnr readvar $localfile varfile close if $event == "0" then gosub EnterMsg if $event == "1" then gosub ReplyMsg if $event == "2" then gosub JoinConf if $event == "3" then gosub ResignConf if $event == "4" then gosub DownloadFile if $event == "5" then gosub UploadFile if $event == "6" then gosub GetConfList if $event == "8" then gosub SendUserInfo cli "thor:bin/ScriptServ \""$BBSName"\" DONE "$eventnr endwhile set $rengrab = "y" ;***************** Grab messages if $BBSType == "MBBS_QWK" then goto HandleMBBSQWK if $BBSType == "ABBS_QWK" then goto HandleABBSQWK set $docmd = "R DUMP ALL\n" gosub DoCommand gosub NoTimeout when "<0>" goto grabd converse "Command" "SE Z\n^K" gosub NoTimeout grabd: dlwhen goto AfterGrabing ;***************** Do ABBS_QWK packet handling HandleABBSQWK: if !exists $UpLoadDir$BBSID".REP" then goto NoABBSRepFile set $docmd = "MU\n" gosub DoCommand when "Reading REP" set $qwkerr = "FALSE" when "Unknown to user" set $qwkerr = "TRUE" wait "B01" upload $UpLoadDir$BBSID".REP",Z gosub NoTimeout capture $Path"QWKMsg.txt" wait "Command" capture off gosub SetUpTimeout dlwhen if $qwkerr == "FALSE" then cli "delete >nil: "$UpLoadDir$BBSID".REP" if $qwkerr == "FALSE" then cli "thor:bin/ScriptServ \""$BBSName"\" PACKAGEDONE" if exists $LogFile then cli "join >nil: "$LogFile" "$Path"QWKMsg.txt TO "$LogFile".tmp" if exists $LogFile then cli "delete >nil: "$LogFile if exists $LogFile then cli "rename >nil: "$LogFile".tmp "$LogFile if exists $LogFile then cli "delete >nil: "$Path"QWKMsg.txt" if !exists $LogFile then cli "rename >nil: "$Path"QWKMsg.txt "$LogFile send "^X" NoABBSRepFile: set $docmd = "GRAB\n" gosub DoCommand gosub NoTimeout goto AfterGrabing ;***************** Do MBBS_QWK packet handling HandleMBBSQWK: set $docmd = $qwkcommand"\n" gosub DoCommand wait "QWK (? for menu)" if $qwkcfg == "FALSE" then goto NoQWKConfig send "C" converse "ation (? for menu)" "P" converse "se a packer" "L" converse "ation (? for menu)" "O" converse "se a protocol" "Z" wait "ation (? for menu)" set $qwkfilelist = "y" when "New file list Off" set $qwkfilelist = "n" send "F" wait "ation (? for menu)" dlwhen if $qwkfilelist == $NewFiles then goto NoChgQWKList send "F" wait "ation (? for menu)" NoChgQWKList: send "R" wait "QWK (? for menu)" NoQWKConfig: if !exists $UpLoadDir$BBSID".REP" then goto NoRepFile when "REP-file ok." set $repfile = "OK" send "U" wait "B01" upload $UpLoadDir$BBSID".REP",Z gosub NoTimeout wait "Reading REP" capture $Path"QWKMsg.txt" wait "QWK (? for menu)" capture off dlwhen gosub SetUpTimeout if !$repfile == "OK" then goto RepFileFail cli "delete >nil: "$UpLoadDir$BBSID".REP" cli "thor:bin/ScriptServ \""$BBSName"\" PACKAGEDONE" ; cli "delete >nil: "$Path"QWKMsg.txt" ; goto NoRepFile RepFileFail: if exists $LogFile then cli "join >nil: "$LogFile" "$Path"QWKMsg.txt TO "$LogFile".tmp" if exists $LogFile then cli "delete >nil: "$LogFile if exists $LogFile then cli "rename >nil: "$LogFile".tmp "$LogFile if exists $LogFile then cli "delete >nil: "$Path"QWKMsg.txt" if !exists $LogFile then cli "rename >nil: "$Path"QWKMsg.txt "$LogFile NoRepFile: send "D" gosub NoTimeout when "Something's gone wrong!" goto QWKWrong when "transferred with the packet?" send "N" converse "QWK (? for menu)" "R" timeout 3 goto QWKDone QWKLoop: wait "" goto QWKLoop QWKWrong: wait "Command" gosub Startlogfile write $LogFile "Error: MBBS-QWK failed making package\n" QWKDone: dlwhen dlwhen gosub SetUpTimeout send "^X" ;***************** Rename the grab AfterGrabing: set $rengrab = "y" ;***************** Auto dnload private files if !$AutoPDnl == "y" then goto NoPrivUpl if $BBSType == "ABBS" then goto NoPrivUpl if $BBSType == "ABBS_QWK" then goto NoPrivUpl if !exists "t:privupl"$BBSName then goto NoPrivUpl varfile "t:privupl"$BBSName readvar $filename readvar $filename readvar $nextline PrivLoop: gosub dfPlain set $filename = $nextline readvar $nextline if $nextline == "EOF" then goto PrivLoopEnd if $filename == "" then goto PrivLoopEnd goto PrivLoop PrivLoopEnd: varfile close NoPrivUpl: ;***************** Get files in hold if exists "t:privupl"$BBSName then cli "delete >nil: \"t:privupl"$BBSName"\"" if !$gethold == "TRUE" then goto NoHold set $docmd = "F GET\n" gosub DoCommand gosub NoTimeout set $docmd = "F DEL *\n" gosub DoCommand NoHold: if $BBSType == "MBBS_QWK" then goto AfterNewFiles if !$NewFiles == "y" then goto AfterNewFiles ;***************** Capture Newfiles.txt set $docmd = "" gosub DoCommand when "Detailed list (Enter=N):" send "n\n" cli "Delete >nil: "$Path"Newfiles.txt" capture $Path"Newfiles.txt" send "F N ;;\n" gosub NoTimeout wait "File Command" dwhen "Detailed list (Enter=N):" capture off send "^X" AfterNewFiles: ;***************** Ready for logout if $AutoLogoff == "n" then goto NoLogOut if exists "t:NoLogOut" then goto NoLogOut set $docmd = "G Y N Y\n" gosub DoCommand when "\r\nNO CARRIER\r\n" goto Hanged delay 2 repeat hangup delay 2 until !CARRIER Hanged: dlwhen goto AllDone NoLogOut: set $docmd = "CHAT A U L 26 W R\n" gosub DoCommand dwhens timeout 0 wait "\r\nNO CARRIER\r\n" AllDone: request on end SendReturn: if $Timeouts == "2" then timeout 20 gosub Hung if $Timeouts == "1" then set $Timeouts = "2" if $Timeouts == "0" then set $Timeouts = "1" send "^X" return Hung: beep message "\nI think the board has hung." message "\nTurn off this script within 20 seconds to stop me from logging out !!" delay 20 beep message "\nWARNING: Logout in progress.\n" hangup goto AllDone SysOp: send "Sorry, you are trying to chat with a script.\n" send "Please put me back to the BBS at once.\n" set $Timeouts = "0" wait "SYSOP is going offline!" set $Timeouts = "0" return ;************************************************ DoCommand: converse "Command" $docmd if !$fixtimeout == "" then gosub SetupTimeout if !$dtmpfile == "" then gosub DelDFwhens if !$dropconfcap == "" then gosub DropConfCap if !$rengrab == "" then gosub RenameGrab return ;************************************************ ; Enter message subroutine ; Uses variables: ; $conf - conference for message ; $sendto - user message is to (Empty string is equal to ALL) ; $subject - subject of message ; $msgfile - file message is in ; $private - private message (y/n) EnterMsg: if !EXISTS $Path$msgfile then return when "enter both the first AND" gosub etomyself when "that name is not registered" gosub etomyself when "ALL is not allowed here!" gosub etomyself when "READ ONLY conference. Us" goto einpost1 when "not a member of this con" goto einpost2 when "Invalid conference selec" goto einpost3 when "Send message to" gosub sendmsgto doconf: if $conf == $oldconf then goto InConf converse "Command" "J "$conf"\n" if !$fixtimeout == "" then gosub SetupTimeout if !$dtmpfile == "" then gosub DelDFwhens if !$dropconfcap == "" then gosub DropConfCap set $oldconf = $conf InConf: if $sendto == "" then set $sendto = "ALL" converse "Command" "E\n" if !$fixtimeout == "" then gosub SetupTimeout if !$dtmpfile == "" then gosub DelDFwhens if !$dropconfcap == "" then gosub DropConfCap set $dlewhen = "FALSE" set $dox = "" gosub SendMessage if $dlewhen == "TRUE" then goto DlEWhenDone dlwhen dlwhen dlwhen dlwhen dlwhen dlwhen dlwhen set $dlewhen = "TRUE" DlEWhenDone: return etomyself: gosub Startlogfile write $LogFile "Error: Conference "$conf", unable to enter message to "$sendto"\n" write $LogFile " Message entered to yourself\n" set $errmsg = "Unable to enter message to "$sendto set $sendto = "^X" return einpost3: gosub Startlogfile write $LogFile "Error: Invalid conference selection: "$conf"\n" write $LogFile " Message to "$sendto" entered in "$PostConf" instead\n" set $errmsg = "Invalid conference selection: "$conf gosub FixJoinErr set $oldconf = "" goto einpost einpost2: gosub Startlogfile write $LogFile "Error: User "$sendto" in not a member of conference "$conf"\n" write $LogFile " Message entered in "$PostConf" instead\n" set $errmsg = "User "$sendto" in not a member of conference "$conf goto einpost einpost1: gosub Startlogfile write $LogFile "Error: Conference "$conf" is READ ONLY\n" write $LogFile " Message to "$sendto" entered in "$PostConf" instead\n" set $errmsg = "Conference "$conf" is READ ONLY" einpost: set $conf = $PostConf goto doconf sendmsgto: if $sendto == "^X" then goto smt1 send $sendto"\n" return smt1: set $sendto = $UserName send "^X" return ;************************************************ ; Reply message subroutine ; Uses variables: ; $conf - conference for message ; $replyto - reply to message ; $subject - subject of message ; $msgfile - file message is in ; $private - private message (y/n) ; $sendto - user the message is to ReplyMsg: if !EXISTS $Path$msgfile then return when "READ ONLY conference you" goto readonlyconf when "Invalid conference selec" goto invalidconf when "not available for reply." goto notavail when "not a member of this con" goto nomember if $conf == $oldconf then goto InConf2 converse "Command" "J "$conf"\n" if !$fixtimeout == "" then gosub SetupTimeout if !$dtmpfile == "" then gosub DelDFwhens if !$dropconfcap == "" then gosub DropConfCap set $oldconf = $conf InConf2: converse "Command" "R RE "$replyto"\n" if !$fixtimeout == "" then gosub SetupTimeout if !$dtmpfile == "" then gosub DelDFwhens if !$dropconfcap == "" then gosub DropConfCap set $dlrewhen = "FALSE" set $dox = "^X" gosub SendMessage if $dlrewhen == "TRUE" then goto DlReWhenDone dlwhen dlwhen dlwhen dlwhen set $dlrewhen = "TRUE" DlReWhenDone: return readonlyconf: gosub Startlogfile write $LogFile "Error: Conference "$conf" is READ ONLY, unable to reply message "$replyto"\n" write $LogFile " Message entered in "$PostConf" instead\n" set $errmsg = "Conference "$conf" is READ ONLY, unable to reply message "$replyto set $conf = $PostConf goto na1 invalidconf: gosub Startlogfile write $LogFile "Error: Invalid conference selection: "$conf"\n" write $LogFile " Unable to reply message "$replyto"\n" write $LogFile " Message entered in "$PostConf" instead\n" set $errmsg = "Invalid conference selection: "$conf"\n Unable to reply message "$replyto set $conf = $PostConf gosub FixJoinErr goto na1 nomember: gosub Startlogfile write $LogFile "Error: "$sendto" is not member of conference: "$conf"\n" write $LogFile " Unable to reply message "$replyto"\n" write $LogFile " Message entered in "$PostConf" instead\n" set $errmsg = $sendto" is not a member of conference: "$conf"\n Unable to reply message "$replyto set $conf = $PostConf goto na1 notavail: gosub Startlogfile write $LogFile "Error: Message "$replyto" in "$conf" not available for reply\n" write $LogFile " Message entered instead\n" set $errmsg = "Message "$replyto" not available for reply" na1: dlwhen dlwhen dlwhen dlwhen goto Entermsg ;************************************************ ; Subroutine for sending message SendMessage: when "--7-" goto sendit converse "Subject" $dox$subject"\n" wait "--7-" sendit: dlwhen if $userinfo == "FALSE" then goto nouserinfo if $BBSType == "ABBS" then send "^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y" if $BBSType == "ABBS" then send "^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y" if $BBSType == "ABBS" then send "^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y" if $BBSType == "ABBS" then send "^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y" if $BBSType == "ABBS" then send "^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y" if $BBSType == "ABBS" then send "^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y" if $BBSType == "ABBS" then send "^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y" if $BBSType == "MBBS" then send "^KC" if $BBSType == "MBBS_QWK" then send "^KC" nouserinfo: send "^KZ" if $errmsg == "" then goto noerrmsg send "Thor scripting error:\n "$errmsg"\n\n" set $errmsg = "" noerrmsg: ascsend $Path$msgfile send "\w^Z^Z" return ;************************************************ ; Download file subroutine ; Uses variables: ; $filename - name of file to download DownloadFile: converse "Command" "F ADD "$filename"\n" if !$fixtimeout == "" then gosub SetupTimeout if !$dtmpfile == "" then gosub DelDFwhens if !$dropconfcap == "" then gosub DropConfCap set $dtmpfile = $filename when "File not found!" gosub fnotfound when "You are not allowed" gosub fnotaccess when "ate files may not be move" gosub dferr set $gethold = "TRUE" return dferr: converse "Command" "F D "$dtmpfile"\n" gosub NoTimeout return dfPlain: set $docmd = "F D "$filename"\n" gosub DoCommand set $dtmpfile = $filename when "File not found!" gosub fnotfound when "You are not allowed" gosub fnotaccess when "ate files may not be move" gosub dfPlain gosub NoTimeout return fnotaccess: gosub Startlogfile write $LogFile "Error: Unable to download file \""$dtmpfile"\", you don't have download access\n" return fnotfound: gosub Startlogfile write $LogFile "Error: Unable to download file \""$dtmpfile"\", file not found\n" return DelDFwhens: dwhen "File not found!" dwhen "You are not allowed" dwhen "ate files may not be move" set $dtmpfile = "" return ;************************************************ GotPrivUpl: capture "t:privupl"$BBSName wait "Comman" send "^X" capture off return ;************************************************ NoTimeout: set $fixtimeout = "d" timeout 0 return SetupTimeout: set $fixtimeout = "" set $Timeouts = "0" timeout 60 gosub sendreturn return ;************************************************ GetConfList: if $BBSType == "MBBS" then goto SetMBBSMode if $BBSType == "MBBS_QWK" then goto SetMBBSMode set $docmd = "R\n" gosub DoCommand when "Read Ref Co" set $readmode = "1" when "Read Co" set $readmode = "2" wait "Command" dlwhen dlwhen send "^X" if $readmode == "2" then goto AfterSetMode set $docmd = "MODE\n" gosub DoCommand goto AfterSetMode SetMBBSMode: set $qwkcfg = "TRUE" set $docmd = "R MODE M\n" gosub DoCommand AfterSetMode: set $docmd = "u m y "$UseColors" "$UseColors" y n y\n" gosub DoCommand if $BBSType == "ABBS" then set $docmd = "sp n n\n" if $BBSType == "ABBS" then gosub DoCommand set $docmd = "" gosub DoCommand cli "Delete >nil: "$Path"Conferences.txt" capture $Path"Conferences.txt" when "nread" SEND "A\n" send "R SH\n" set $dropconfcap = "j" return DropConfCap: dwhen "nread" capture off set $dropconfcap = "" return ;************************************************ ; Upload file subroutine ; Uses variables: ; $filename - name of file to upload ; $filedescr - short description of file ; $notify - download notification (y/n) ; $detailed - detailed description (y/n) ; $sendto - private upload to user (empty string/"ALL" = public file) ; $localfile - path/filename to upload. ; $conf - Try to make file private to conf (if $conf != "") UploadFile: set $msgfile = "" if $localfile == "" then set $localfile = $UpLoadDir$filename if !exists $localfile then goto nofileupload if !$conf == "" then gosub JoinConf when "enter both the first AND" goto puperr when "that name is not registered" goto puperr when "ALL is not allowed here!" goto puperr when "Invalid file name!" goto upinvfile when "File exists already!" goto fexists when "each download" send $notify"\n" if $conf == "" then when "rivate to confer" send "n\n" if !$conf == "" then when "rivate to confer" send "y\n" if !$sendto == "" then set $docmd = "F PUP "$sendto"\n" if $sendto == "ALL" then set $docmd = "F UP\n" if $sendto == "" then set $docmd = "F UP\n" converse "Command" $docmd if !$fixtimeout == "" then gosub SetupTimeout if !$dtmpfile == "" then gosub DelDFwhens if !$dropconfcap == "" then gosub DropConfCap converse "ile name" $filename"\n" converse "ion of file" $filedescr"\n" wait "B01" upload $localfile,Z gosub NoTimeout when "Command" goto uplfail if $detailed == "" then goto NoDetailed converse "description (Enter=Y)" "Y\n" gosub SetupTimeout set $msgfile = $detailed gosub SendMessage goto fixfail NoDetailed: converse "description (Enter=Y)" "N\n" fixfail: dlwhen fixupl: dlwhen dlwhen dlwhen dlwhen dlwhen dlwhen dlwhen if !$msgfile == "" then goto retupl timeout 2 send "^X" retupl: return puperr: gosub Startlogfile write $LogFile "Error: Unable to do a private upload of "$filename"\n" write $LogFile " User "$sendto" is not registered\n" send "^X\n" goto fixupl upinvfile: gosub Startlogfile write $LogFile "Error: Unable to upload "$filename", filename is invalid\n" send "^X\n" goto fixupl fexists: gosub Startlogfile write $LogFile "Error: Unable to upload "$filename", file already exists\n" send "^X\n" goto fixupl nofileupload: gosub Startlogfile write $LogFile "Error: Unable to upload "$filename", file not found\n" return uplfail: gosub Startlogfile write $LogFile "Error: Unable to upload "$filename", upload failed\n" goto fixfail ;************************************************ ; Join conference ; Uses variables: ; $conf - conference to join JoinConf: when "Invalid conference sele" gosub joinerr set $docmd = "J "$conf"\n" gosub DoCommand set $oldconf = $conf wait "Command" dwhen "Invalid conference sele" send "^X" return joinerr: gosub Startlogfile write $LogFile "Error: Invalid conference selection: "$conf", Unable to join\n" gosub FixJoinErr set $oldconf = "" return ;************************************************ ; Resign conference ; Uses variables: ; $conf - conference to resign ResignConf: when "Invalid conference sel" goto reserr converse "Command" "J "$conf"\n" if !$fixtimeout == "" then gosub SetupTimeout if !$dtmpfile == "" then gosub DelDFwhens if !$dropconfcap == "" then gosub DropConfCap converse "Command" "RES Y\n" if !$fixtimeout == "" then gosub SetupTimeout if !$dtmpfile == "" then gosub DelDFwhens if !$dropconfcap == "" then gosub DropConfCap set $oldconf = "" fixresign: dlwhen return reserr: gosub Startlogfile write $LogFile "Error: Invalid conference selection: "$conf", Unable to resign\n" gosub FixJoinErr goto fixresign ;************************************************ Startlogfile: if !exists $LogFile then write $LogFile "Messages from script:\n" return ;************************************************ ; Send user info ; Uses variables: ; $msgfile - file user info is in SendUserInfo: converse "Command" "Q EDIT\n" if !$fixtimeout == "" then gosub SetupTimeout if !$dtmpfile == "" then gosub DelDFwhens if !$dropconfcap == "" then gosub DropConfCap converse "number displayed (Enter=" "y\n" set $userinfo = "TRUE" gosub SendMessage set $userinfo = "FALSE" return ;************************************************ FixJoinErr: if $BBSType == "MBBS" then converse "name to join" "\n" if $BBSType == "MBBS_QWK" then converse "name to join" "\n" if $BBSType == "ABBS" then send "^K" if $BBSType == "ABBS" then converse "Join conference:" "\n" return ;************************************************ RenameGrab: set $rengrab = "" cli "thor:bin/ScriptServ \""$BBSName"\" RENAMEGRAB" return