home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 25 / amigaformatcd25.iso / websites / f1_gp / ftp / rexx / mdapprove.lha / Majordomo_approve.thor < prev    next >
Text File  |  1997-05-01  |  3KB  |  139 lines

  1. /* $VER: Majordomo_approve.thor 1.1 (1.5.97)
  2. **
  3. ** Author: Oliver Roberts
  4. ** E-Mail: Oliver@poboxes.com
  5. **    WWW: http://www.nanunanu.org/~oliver/
  6. **
  7. ** Brief Description:
  8. **
  9. ** Arexx script for Majordomo list owners.  Allows automatic handling of
  10. ** the most common messages that Majordomo will send you which require
  11. ** approval
  12. **
  13. ** Must be started from THOR.
  14. */
  15.  
  16. conf = 'EMail'                /* e-mail conference name */
  17.  
  18. /* Password configuration - entries should be in the following form */
  19.  
  20. password.donut_makers = 'BigSecret'
  21.  
  22. /********************* DO NOT MODIFY BELOW HERE *************************/
  23. options results
  24.  
  25. thorport = address()
  26.  
  27. if ~show('p', 'BBSREAD') then do
  28.     address command
  29.         "run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead"
  30.         "WaitForPort BBSREAD"
  31. end
  32.  
  33. address(thorport)
  34.  
  35. CURRENTMSG stem MSG
  36. if(rc ~= 0) then
  37. do
  38.     REQUESTNOTIFY TEXT '"No current message."' BT '"_Ok"'
  39.     exit
  40. end
  41.  
  42. bbs = MSG.BBSNAME
  43.  
  44. address(bbsread)
  45.  
  46. /* Get a unique message for the event */
  47.  
  48. UNIQUEMSGFILE bbsname '"'bbs'"' stem UNIQUEFILE
  49. if(rc ~= 0) then goto quit
  50.  
  51. /* Read the data on the message that is to be forwarded */
  52.  
  53. READBRMESSAGE bbsname '"'MSG.BBSNAME'"' confname '"'MSG.CONFNAME'"' msgnr MSG.MSGNR headstem HEADTAGS textstem TEXTTAGS 
  54. if(rc ~= 0) then goto quit
  55.  
  56. /* Setup message variables */
  57.  
  58. domain = right(HEADTAGS.FROMADDR,length(HEADTAGS.FROMADDR) - pos('@',HEADTAGS.FROMADDR))
  59. listname = left(word(HEADTAGS.SUBJECT,2),length(word(HEADTAGS.SUBJECT,2)))
  60.  
  61. if (pos('@',listname) ~= 0) then do
  62.     listname = left(listname,pos('@',listname)-1)
  63. end
  64.  
  65. if (pos(':',listname) ~= 0) then do
  66.     listname = left(listname,pos(':',listname)-1)
  67. end
  68.  
  69. if (symbol('password.'listname) = "VAR") then do
  70.     passwd = value('password.'listname)
  71. end
  72. else do
  73.     passwd = ''
  74. end
  75.  
  76. if (passwd = '') then do
  77.     address(thorport)
  78.     REQUESTSTRING TITLE '"Enter password:"' BT '" _Ok | _Cancel "' MAXCHARS 20
  79.     if(rc ~= 0) then exit
  80.     passwd = result
  81. end
  82.  
  83. address(BBSREAD)
  84.  
  85. /* Create message file */
  86.  
  87. if(~open(fh, UNIQUEFILE.NAME, W)) then 
  88. do
  89.     address(thorport)
  90.     REQUESTNOTIFY TEXT '"Unable to open file:' UNIQUEFILE.NAME '"' BT '"_Ok"'
  91.     exit
  92. end
  93.  
  94. /* Build the message */
  95.  
  96. if (LEFT(HEADTAGS.SUBJECT,7) = 'BOUNCE ') then do
  97.     toaddress = listname || '@' || domain
  98.     call writeln(fh,'')
  99.     call writeln(fh, 'Approved: ' || passwd)
  100.     do n=1 to TEXTTAGS.TEXT.COUNT
  101.         call writeln(fh, TEXTTAGS.TEXT.n)
  102.     end
  103. end
  104.  
  105. if (LEFT(HEADTAGS.SUBJECT,8) = 'APPROVE ') then do
  106.     toaddress = 'majordomo@' || domain
  107.     do n=1 to TEXTTAGS.TEXT.COUNT
  108.         if ((compress(word(TEXTTAGS.TEXT.n,1),'09'x) = 'approve') & (word(TEXTTAGS.TEXT.n,2) = 'PASSWORD')) then do
  109.             call writeln(fh, 'approve ' || passwd || ' ' || right(TEXTTAGS.TEXT.n,length(TEXTTAGS.TEXT.n) - pos('PASSWORD',TEXTTAGS.TEXT.n) - 8))
  110.         end
  111.     end
  112. end
  113.  
  114. call close(fh)
  115.  
  116. /* Post it */
  117.  
  118. drop EVENT.
  119.  
  120. EVENT.SUBJECT = 'Re: '||HEADTAGS.SUBJECT
  121. EVENT.TOADDR = toaddress
  122. EVENT.CONFERENCE = conf
  123. EVENT.MSGFILE = UNIQUEFILE.FILEPART
  124.  
  125. WRITEBREVENT bbsname '"'bbs'"' event 0 stem EVENT
  126. if(rc ~= 0) then goto quit
  127.  
  128. address(thorport)
  129.  
  130. if(bbs ~= MSG.BBSNAME) then
  131.     PACKEVENTS '"'bbs'"'
  132.  
  133. exit
  134.  
  135. quit:
  136.     address(thorport)
  137.     REQUESTNOTIFY TEXT '"'BBSREAD.LASTERROR'"' BT '"_Ok"'
  138.     exit
  139.