home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 5 / FreshFish_July-August1994.bin / bbs / comm / bbbbs-7.2.lha / BBBBS / BBBBS72.lha / rexx / bbsMail.rexx < prev    next >
OS/2 REXX Batch file  |  1994-04-09  |  31KB  |  1,154 lines

  1. /* $VER: bbsMail.rexx 7.2 (9.4.94) Copyright © 1994 Richard Lee Stockton
  2.  * BBBBS mail reader/sender with optional file attach
  3.  * FREELY DISTRIBUTABLE
  4.  * Thanks to Matt English for "SendFile.rexx"
  5.  * Thanks to John Ruckart for additional "detail work".
  6. */
  7.  
  8. IF ~SHOW('P','QuickSortPort') THEN CALL setup.rexx()
  9. IF ~SHOW('P','QuickSortPort') THEN EXIT 666
  10.  
  11. title.=''
  12. title.1='bbsMail for BBBBS'
  13. title.2='Version 7.2'
  14. title.3='30-Mar-94'
  15.  
  16. def=''
  17. pen1=''
  18. pen2=''
  19. pen3=''
  20. lineup='1B'x'M'
  21. changed=0
  22. linesperpage=20
  23. namemask=COMPRESS(XRANGE(),XRANGE('A','Z')' _-')
  24.  
  25. topath='RAM:'
  26. figarg='s:CONFIG.BBS'
  27. IF ~EXISTS(figarg) THEN figarg='BBS:BBS_TEXT/CONFIG.BBS'
  28. x=OPEN(f,figarg,'R')
  29. IF x=0 THEN
  30.   DO
  31.     SAY 's:CONFIG.BBS and BBS:BBS/CONFIG.BBS are both missing!'
  32.     EXIT
  33.   END
  34. lynes.=''
  35. DO i=1 TO 40
  36.   lynes.i=READLN(f)
  37. END
  38. CALL CLOSE(f)
  39.  
  40. compos=POS('/*',lynes.1)
  41. IF compos>0 THEN lynes.1=LEFT(lynes.1,compos-1)
  42. bbsname=STRIP(lynes.1)
  43. sysop=WORD(lynes.2,1)
  44. compos=POS('/*',lynes.3)
  45. IF compos>0 THEN lynes.3=LEFT(lynes.3,compos-1)
  46. bbsdevice=word(lynes.4,1)
  47. sysoplevel=WORD(lynes.5,1)
  48. bbspath=WORD(lynes.6,1)
  49. IF ~EXISTS(bbspath) THEN
  50.   DO
  51.     SAY bbspath 'does not exist!'
  52.     EXIT
  53.   END
  54. testchar=RIGHT(bbspath,1)
  55. IF testchar~='/' & testchar~=':' THEN bbspath=bbspath'/'
  56. msgpath=WORD(lynes.7,1)
  57. IF ~EXISTS(msgpath) THEN
  58.   DO
  59.     SAY msgpath 'does not exist!'
  60.     EXIT
  61.   END
  62. testchar=RIGHT(msgpath,1)
  63. IF testchar~='/' & testchar~=':' THEN msgpath=msgpath'/'
  64. msgpath=msgpath'MSG'
  65. IF WORD(lynes.25,1)=1 THEN scratch=bbspath'Scratch'
  66. ELSE scratch='RAM:Scratch'
  67. CALL MAKEDIR(scratch)
  68.  
  69. OPTIONS PROMPT ' Are you 'sysop'? (Yn) > '
  70. PULL answer
  71. IF answer='N' THEN
  72.   DO
  73.     SAY
  74.     OPTIONS PROMPT ' Please enter your name > '
  75.     PULL name
  76.     name=cleanstring(name)
  77.     IF name='' THEN EXIT 
  78.     IF ~EXISTS(bbspath'Users/'name) THEN
  79.       DO
  80.         SAY name 'does not exist!'
  81.         EXIT
  82.       END
  83.   END
  84. ELSE name=sysop
  85. userfile=bbspath'Users/'name
  86. CALL OPEN(f,userfile,'R')
  87. data.=''
  88. DO i=1
  89.   line=READLN(f)
  90.   IF EOF(f) THEN LEAVE i
  91.   data.i=line
  92. END
  93. CALL CLOSE(f)
  94. data.0=i-1
  95. city=docity(data.3)
  96. password=data.5
  97. level=data.20
  98.  
  99. passprompt=pen3' Please Enter Password: '
  100. DO tries=1 TO 3
  101.   OPTIONS PROMPT passprompt
  102.   PULL newpassword
  103.   SAY def
  104.   IF(password=newpassword) THEN LEAVE tries; /* correct password */
  105.   IF tries=3 THEN
  106.     DO
  107.       SAY 
  108.       SAY 'Access terminated.'
  109.       SAY '*** Bad password ***' newpassword '***'
  110.       EXIT
  111.     END
  112.   passprompt='Incorrect.  Password: ' /* ask again */
  113. END
  114. Friends.=''
  115. IF readopen(bbspath'Friends/'name) THEN
  116.   DO
  117.     DO i=1
  118.       Friends.i=READLN(f)
  119.       IF EOF(f) THEN LEAVE i
  120.     END
  121.     Friends.0=i-1
  122.     CALL CLOSE(f)
  123.   END
  124. SAY
  125. SAY' OK, 'name' here we go....'
  126. SAY
  127. IF level>sysoplevel THEN
  128.   DO
  129.     CALL showtext(bbspath'Email/'sysop'/NEW_FILES')
  130.     CALL showtext(bbspath'Lists/NEW_USERS')
  131.     CALL showtext(bbspath'Lists/CBV_USERS')
  132.   END
  133. DO FOREVER
  134.   replysubj=''
  135.   thechosen.=''
  136.   SAY
  137.   DO i=1 TO 3
  138.     SAY CENTER(title.i,74)
  139.   END
  140.   SAY
  141.   CALL readmail()
  142.   IF temp='Q' THEN CALL seeya
  143. END
  144.  
  145.  
  146.  
  147. /* SUBROUTINES */
  148.  
  149.  
  150. readmail:
  151. line='Find Email ['pen3'T'def']o You or ['pen3'W'def']rite New Email (Twq) > 'def
  152. temp=getinput(1 1 line)
  153. IF temp='W' THEN
  154.   DO
  155.     CALL editor()
  156.     RETURN
  157.   END
  158. ELSE IF temp='Q' THEN CALL seeya
  159. SAY 'Checking your mailbox..'
  160. nomail=1
  161. CALL MAKEDIR(bbspath'EMail/'name)
  162. mailist=sortnumbers(SHOWDIR(bbspath'Email/'name))
  163. IF WORDS(mailist)=0 THEN
  164.   DO
  165.     SAY lineup'Your mailbox is empty.  '
  166.     SAY
  167.     RETURN
  168.   END
  169. line=WORDS(mailist)
  170. IF line>1 THEN line=line 'letters'
  171. ELSE line=line 'letter'
  172. line=line 'waiting.'
  173. SAY line
  174. DO ii=1 TO WORDS(mailist)
  175.   SAY 'Email:' pen3||WORD(mailist,ii)||def
  176. END
  177. onename=''
  178. IF WORDS(mailist)>3 THEN
  179.   DO
  180.     IF getinput(1 1 'Read all private mail? (nY) > ')='N' THEN
  181.       DO
  182.         onename=getinput(1 0 'Read ONLY private mail from? > ')
  183.         onename=SPACE(STRIP(UPPER(onename)),1,'_')
  184.         onename=COMPRESS(onename,'.,:/*#?^ ')
  185.         IF onename='' THEN RETURN
  186.         IF ~EXISTS(bbspath'Users/'onename) & picklist.1~='BBBBS' THEN
  187.           DO
  188.             SAY '***'pen3 onename def'does not exist!'
  189.             RETURN
  190.           END
  191.       END
  192.   END
  193. DO letter=1 TO WORDS(mailist)
  194.   readname=WORD(mailist,letter)
  195.   uname=readname
  196.   caret=LASTPOS('.',uname)
  197.   IF caret>2 THEN uname=LEFT(uname,caret-1)
  198.   IF onename~='' & onename~=uname THEN ITERATE letter
  199.   arg=bbspath'Email/'name'/'readname
  200.   CALL readlines(arg 1)
  201.   delnum=WORD(lynes.1,2)
  202.   CALL seelines(1)
  203.   nomail=0
  204.   nonstop=0
  205.   mailfile=''
  206.   IF UPPER(WORD(lynes.1,3))='FILE:' THEN mailfile=WORD(lynes.1,4)
  207.   ELSE IF UPPER(WORD(lynes.2,3))='FILE:' THEN mailfile=WORD(lynes.2,4)
  208.   IF mailfile~='' & readname~='NEW_FILES' & readname~='FILELISTS_REPORT' & readname~='INACTIVE_USERS' & LEFT(readname,3)~='MSG' THEN
  209.     DO
  210.       IF LEFT(RIGHT(mailfile,4),1)~='.' & LEFT(readname,6)='BBBBS.' THEN
  211.         DO
  212.           SAY
  213.           SAY pen3'The attached file is unarchived and may be incomplete.'
  214.           SAY 'If the archiver is still building this file, downloading will fail.'def
  215.           IF getinput(1 1 'Do you want to try to download it anyway? (Ny) > ')~='Y' THEN ITERATE letter
  216.           SAY
  217.         END
  218.       curdir=PRAGMA('D')
  219.       CALL setdir(bbspath'EmailFiles/'name)
  220.       ADDRESS COMMAND 'C:List >*' mailfile 'DATES'
  221.       SAY ' Attached file:' pen3||mailfile||def
  222.       junk=getinput(1 1 'Leave file in your EmailFiles? (Ny) > ')
  223.       IF junk='Y' THEN mailfile=''
  224.       ELSE
  225.         DO
  226.           junk=getinput(1 1 'Deleting Mail will also delete file. Copy somewhere now? (Ny) > ')
  227.           IF junk='Y' THEN
  228.             DO
  229.               tofile=GetFile(150,36,topath,mailfile,' Select Destination Name ')
  230.               ADDRESS COMMAND 'C:Copy' PRAGMA('D')'/'mailfile tofile
  231.             END
  232.         END
  233.     END
  234.   IF readname~='NEW_FILES' & readname~='FILELISTS_REPORT' & readname~='INACTIVE_USERS' & LEFT(readname,3)~='MSG' & LEFT(readname,6)~='BBBBS.' THEN
  235.     DO
  236.       tempchar='A'
  237.       DO WHILE tempchar='A'
  238.         tempchar=getinput(1 1 '['pen3'A'def']gain  ['pen3'C'def']ontinue  ['pen3'R'def']eply? (acR) > ')
  239.         IF tempchar='' THEN tempchar='R'
  240.         IF tempchar='A' THEN CALL seelines(1)
  241.       END
  242.       IF tempchar='R' THEN
  243.         DO
  244.           IF WORDS(lynes.4)<2 THEN replysubj='?'
  245.           ELSE replysubj=SUBSTR(lynes.4,WORDINDEX(lynes.4,2))
  246.           CALL editor(uname)
  247.           replysubj=''
  248.         END
  249.     END
  250.   IF LEFT(readname,6)~='BBBBS.' THEN
  251.     DO
  252.       tempchar='A'
  253.       DO WHILE tempchar='A'
  254.         tempchar=getinput(1 1 'Forward mail from'pen3 uname def'to other users? (aNy) > ')
  255.         IF tempchar='A' THEN CALL seelines(1)
  256.       END
  257.       IF tempchar='Y' THEN
  258.         DO
  259.           IF selectchosen(1 pen3'Forward Email To: 'def)=0 THEN
  260.             DO ei=1 TO thechosen.0 WHILE thechosen.ei~=''
  261.               CALL MAKEDIR(bbspath'EMail/'thechosen.ei)
  262.               forwardarg=bbspath'Email/'thechosen.ei'/'readname
  263.               ADDRESS COMMAND 'C:COPY' bbspath'Email/'name'/'readname forwardarg
  264.               CALL readlines(forwardarg 1)
  265.               lynes.1=lynes.1'  Forwarded to you by' name TIME('C') DATE()
  266.               CALL DELETE(forwardarg)
  267.               CALL savelines(forwardarg)
  268.               IF WORDS(lynes.2)>3 THEN
  269.                 DO
  270.                   forname=bbspath'EmailFiles/'name'/'WORD(lynes.2,4)
  271.                   IF EXISTS(forname) THEN
  272.                     DO
  273.                       CALL MAKEDIR(bbspath'EmailFiles/'thechosen.ei)
  274.                       ADDRESS COMMAND 'C:COPY' forname bbspath'EmailFiles/'thechosen.ei
  275.                     END
  276.                 END
  277.               line='Mail' pen3||readname||def 'forwarded to' pen3||thechosen.ei||def
  278.               IF emailonline>=0 THEN emailonline=emailonline+1
  279.               SAY line
  280.             END
  281.         END
  282.     END
  283.   tempchar=''
  284.   tempstr='Delete the mail ('pen3||delnum||def') from'pen3 uname def'that you just read?'
  285.   IF mailfile='' THEN tempchar=getinput(1 1 tempstr '(nqY) > ')
  286.   ELSE
  287.     DO WHILE tempchar~='N' & tempchar~='Q' & tempchar~='Y'
  288.       tempchar=getinput(1 1 tempstr '(nqy) > ')
  289.     END
  290.   IF tempchar='Q' THEN
  291.     DO
  292.       IF getinput(1 1 'Quit reading your Email