home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 2 / FFMCD02.bin / new / comm / fido / spot / rexx / twit.spot < prev    next >
Text File  |  1993-12-21  |  5KB  |  167 lines

  1. /*******************************************************************/
  2. /*                    Twit script for Spot                         */
  3. /*                                                                 */
  4. /* This script will go through all your unread messages looking    */
  5. /* for messages to or from unwanted users or containing trivial    */
  6. /* subjects. See enclosed Twit.cfg for examples of setup.          */
  7. /* These messages will either be marked as READ or DELETED.        */
  8. /*                                                                 */
  9. /* Place Twit.cfg in MAIL: or update TwitFile variable to reflect  */
  10. /* position.                                                       */
  11. /*                                                                 */
  12. /*                                                                 */
  13. /* Twit.spot knows two switches:                                   */
  14. /*                                                                 */
  15. /* DELETE   All matching messages will be deleted                  */
  16. /*          (Default is to mark messages as READ)                  */
  17. /*                                                                 */
  18. /* QUIET    You will not be presented with a BailOut requester.    */
  19. /*          (Default is to ask if you're sure you want to twit)    */
  20. /*                                                                 */
  21. /* WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING!  */
  22. /*                                                                 */
  23. /* This script is potentionally dangerous, therefore I DO          */
  24. /* NOT recommend you to use arguments DELETE or QUIET until you    */
  25. /* are familiar with the inner workings of this script!!!          */
  26. /*                                                                 */
  27. /* I take no responsibility for any damage done to your            */
  28. /* message-base. Use at your own RISK!!!                           */
  29. /*                                                                 */
  30. /* 'nuff serious stuff, let's Twit :-)                             */
  31. /*                                                                 */
  32. /*                 $VER: Twit.spot 1.0 (7.8.93)                    */
  33. /*                                                                 */
  34. /*       Author: Brian Jacobsen   FidoNet: 2:230/311.17            */
  35. /*******************************************************************/
  36.  
  37. address 'SPOT'
  38. signal on syntax
  39. options results
  40. PARSE UPPER ARG arg1 arg2
  41.  
  42. Twitfile = 'MAIL:Twit.cfg'                                /* Name of config     */
  43. Writers. = 0                                            /* Stem for writers   */
  44. Receivers. = 0                                            /* Stem for receivers */
  45. Subjects. = 0                                            /* Stem for subjects  */
  46.  
  47. IF arg1 = 'DELETE' | arg2 = 'DELETE' THEN                /* Delete....         */
  48.     DO
  49.         DeleteMessages = 1                                /* At your own risk   */
  50.         Action = 'delete'
  51.     END
  52. ELSE                                                    /* Mark as READ       */
  53.     DO
  54.         DeleteMessages = 0
  55.         Action = 'clear UNREAD flag for'
  56.     END
  57.  
  58. IF arg1 = 'QUIET' | arg2 = 'QUIET' THEN                    /* Be quiet...        */
  59.     Quiet = 1
  60. ELSE                                                    /* Accept requester   */
  61.     Quiet = 0
  62.  
  63.  
  64. CALL ReadCfg Twitfile                                    /* Read config        */
  65. 'lockgui'                                                /* Lock Spot's GUI    */
  66.  
  67. 'arealist'                                                /* Goto arealist      */
  68. 'unreadarea'
  69. 'messagelist'
  70. 'getareaname'
  71. FirstArea = result
  72. DO UNTIL FirstArea = result
  73.     DO i = 1 TO Writers.0
  74.         SpotArgs = '"'Writers.i'" FROM UNREAD NOGUI NOREQ'
  75.         'include' SpotArgs
  76.     END
  77.     DO i = 1 TO Receivers.0
  78.         SpotArgs = '"'Receivers.i'" TO UNREAD NOGUI NOREQ'
  79.         'include' SpotArgs
  80.     END
  81.     DO i = 1 TO Subjects.0
  82.         SpotArgs = '"'Subjects.i'" SUBJECT UNREAD NOGUI NOREQ'
  83.         'include' SpotArgs
  84.     END
  85.  
  86.     'getnumselected'
  87.     SelectedCount = result
  88.     IF SelectedCount > 0 THEN                            /* Did we find msgs?  */
  89.         DO
  90.             BailOut = 0
  91.             IF Quiet = 0 THEN
  92.                 DO
  93.                     requestdata = 'TITLE "Last chance..." PROMPT "Okay to' action SelectedCount 'messages?"'
  94.                     'requestresponse' requestdata
  95.                     IF rc ~= 0 THEN BailOut = 1
  96.                 END
  97.  
  98.             IF ~BailOut THEN
  99.                 IF DeleteMessages THEN
  100.                     'deletemessage NOREQ'
  101.                 ELSE
  102.                     'clearflags UNREAD'
  103.         END
  104.     'unreadarea'
  105.     'getareaname'
  106. END
  107. 'arealist'
  108. 'unlockgui'
  109. EXIT
  110.  
  111. ReadCfg: PROCEDURE EXPOSE Writers. Receivers. Subjects.
  112. ARG CfgFileName
  113. SubjectCounter  = 0
  114. WriterCounter   = 0
  115. ReceiverCounter = 0
  116.  
  117. IF open('cfghandle',CfgFileName,'Read') ~= 1 THEN
  118.     DO
  119.         requestdata = 'PROMPT "Could not open' CfgFileName 'for reading.."'
  120.         'requestnotify' requestdata
  121.         SIGNAL exit
  122.     END
  123.  
  124. inline = READLN('cfghandle')
  125.  
  126. DO WHILE ~EOF('cfghandle')
  127.     PARSE VAR inline keyword argument
  128.     argument = STRIP(argument,'B')
  129.     SELECT
  130.         WHEN keyword = 'FROM' THEN                                /* Twit from */
  131.             DO
  132.                 WriterCounter = WriterCounter + 1
  133.                 Writers.0 = WriterCounter
  134.                 Writers.WriterCounter = argument
  135.             END
  136.         WHEN keyword = 'TO' THEN                                /* Twit to   */
  137.             DO
  138.                 ReceiverCounter = ReceiverCounter + 1
  139.                 Receivers.0 = ReceiverCounter
  140.                 Receivers.ReceiverCounter = argument
  141.             END
  142.         WHEN keyword = 'SUBJECT' THEN                            /* Twit subj */
  143.             DO
  144.                 SubjectCounter = SubjectCounter + 1
  145.                 Subjects.0 = SubjectCounter
  146.                 Subjects.SubjectCounter = argument
  147.                 
  148.             END
  149.         WHEN keyword = '' | keyword = ';' THEN NOP
  150.         OTHERWISE
  151.             DO
  152.                 requestdata = 'PROMPT "Unknown keyword' keyword 'in' CfgFileName'"'
  153.                 'requestnotify' requestdata
  154.                 SIGNAL exit
  155.             END
  156.     END
  157.     inline = READLN('cfghandle')
  158. END
  159. CALL CLOSE('cfghandle')
  160. RETURN
  161.  
  162. syntax:
  163. say rc errortext(rc) 'in line' SIGL
  164. exit:
  165. 'unlockgui'
  166. EXIT
  167.