home *** CD-ROM | disk | FTP | other *** search
/ .net 1999 December / netCD65.iso / pc / Software / VirtualA / 32bit / vasetup.exe / %MYDIR% / SYSOP2.EBS < prev    next >
Encoding:
Text File  |  1999-10-06  |  6.8 KB  |  223 lines

  1. 'T:SYSOP2.EBS for CompuServe
  2. ' VA 4.52 release
  3.  
  4. Global Const IM_DELETE    = 2048
  5.  
  6. Const fRECEIPT = 1       'CIS mail receipt
  7. Const fDONTCOPY = 16     'don't copy the message back to you
  8.  
  9. Declare Function UniqueFileName$
  10. Declare Function QueueFile(service As String, sfilename As String, queueflags As Long) As Boolean
  11. Declare Sub ReportSuccess(id As String)
  12. Declare Function GoForum(ByVal forum As String) As Boolean
  13. Declare Function StartCapture(pseudo As String)
  14. Declare Function MyDate$
  15. Dim nummessages as Integer
  16. Declare Function GoSysOp(forum As String)
  17.  
  18. Dim syslog As String               ' Location of SysOp logs
  19. Dim ErrorDetected As Boolean        ' Error detected while running script
  20. Dim sMsgStatFile as string        ' Unique name for capture file
  21. Dim msMessageLine() As String        ' Message Lines
  22.  
  23. 'T:AsciiListOfMailUsers (subroutine) (CompuServe)
  24. Sub AsciiListOfMailUsers(id as String, forum As String, TheDate as String, SendMailToUsers as String)
  25.     Dim NewUserData as String
  26.     Dim ImportNewUserNames As String
  27.     Dim BSCFile As String
  28.     Dim t1 as tracker, t2 as Tracker
  29.  
  30.     If Not GoSysOp(forum) Then
  31.         LogResult "Unable to access " + forum + "to get list of new users"
  32.         Exit Sub
  33.     End If
  34.  
  35.     ' Send the command
  36.     Comms.Send "so;mai;mem;lis;djn;" + TheDate + "\r"
  37.     Terminal.Status "Capturing New User Information"
  38.     WaitFor "Public CO Rooms :"
  39.     Terminal.Enabled = False
  40.     Set t1 = CreateTracker("NewUser", "Name : ", "NewUserCounter")
  41.     Set t2 = CreateTracker("PromptSOList", "\nList Membership !", "", True)
  42.                            
  43.     NewUserData = UniqueFilename$()
  44.     Capture CAPTURE_ON, NewUserData
  45.  
  46.     'Wait until I get back to the prompt.
  47.     Do
  48.         TimedWaitForPrompt "Prompt", 45
  49.     Loop Until PromptMatches("PromptSOList")
  50.  
  51.     Capture CAPTURE_OFF
  52.     t1.Delete
  53.     t2.delete
  54.     Terminal.Enabled = True
  55.     Terminal.Status "Processing New User Information"
  56.  
  57.     ImportNewUserNames = UniqueFileName$()
  58.  
  59.     Open NewUserData For Input Access Read Shared As #1
  60.     Open ImportNewUserNames For Output Access Write Shared As #3
  61.     
  62.     Print #3, "!start "+forum+"/Membership New_Joiners"
  63.     Print #3, "People who have joined the forum since " + TheDate
  64.     Print #3, " "
  65.  
  66.     If UCase$(SendMailToUsers) = "Y" then
  67.         BSCFile = Session.ServicePath
  68.         AddBackslash BSCFile
  69.         BSCFile = BSCFIle & Session.Service & ".bsc"
  70.         Open BSCFile For Append Access Write Shared As #2
  71.  
  72.         Print #3, "These people will all be mailed the 'welcome to the forum'"
  73.         Print #3, "text the next time you do a connect to CompuServe."
  74.         Print #3, " "
  75.         While Not Eof(1)
  76.             Line Input #1, inpline
  77.             If Left$(inpline, 7) = "Name : " then
  78.                 print #2, ";-; id:" & Chr(9) & "system type:" & Chr(9) & "script script:" & Chr(9) & "Send Welcome Mail to User priority:" & Chr(9) & "30 #:" & Chr(9) & forum & " #:" & Chr(9) & Right$(inpline, len(inpline) -7)
  79.                 print #2, "WelcomeMailTo"
  80.                 print #2, forum
  81.                 print #2, Right$(inpline, len(inpline) -7)
  82.                 print #3, Right$(inpline, len(inpline) -7)
  83.             End If
  84.         Wend
  85.         close #2
  86.     Else
  87.         Print #3, " "
  88.         While Not Eof(1)
  89.             Line Input #1, inpline
  90.             If Left$(inpline, 7) = "Name : " then
  91.                 print #3, Right$(inpline, len(inpline) -7)
  92.             End If
  93.         Wend
  94.     End If
  95.  
  96.     Print #3, " "
  97.     Close #3
  98.     close #1
  99.     b = QueueFile(Session.Service, ImportNewUserNames, IM_DELETE)
  100.  
  101.     Comms.Send "mes\r"
  102.     WaitForPrompt "Prompt"
  103.     ReportSuccess id & " : got info"
  104. End Sub
  105.  
  106. 'T:NewUserCounter (subroutine) (CompuServe)
  107. ' Display number of messages downloaded
  108. Sub NewUserCounter(t As Tracker)
  109.     nummessages = nummessages + 1
  110.     Terminal.CaptureStatus nummessages, "Collecting new joinee names"
  111.     t.reset
  112. End Sub
  113.  
  114. 'T:AsciiListHeldMessages (subroutine) (CompuServe)
  115. Sub AsciiListHeldMessages(id As String, forum As String, sections As String)
  116.     Dim nFOld As Integer
  117.     Dim nFNew As Integer
  118.     Dim sScanOld As String
  119.     Dim sScanNew As String
  120.     Dim sNextLine As String
  121.     Dim nTextBreak As Integer
  122.     Dim sMsgNumber as String
  123.     Dim sMsgSection as String
  124.     Dim nIndex as Integer
  125.         
  126.     On Error Goto AsciiListHeldMessages_Error
  127.  
  128.     If Not GoForum(forum) Then
  129.         LogResult id + " : Failed : Unable to collect messages from " + forum
  130.         Exit Sub
  131.     End If
  132.  
  133.     sScanOld = StartCapture(forum + "/Sysop_Logs Held_Messages")
  134.     
  135.     Terminal.Status "Collecting Held List ... Please Wait"
  136.  
  137.     Comms.Send "mess;ss "+sections+";sca hold\r"
  138.  
  139.     WaitForPrompt "Prompt"
  140.     CaptureRewind 7
  141.     CaptureText Basic.Eoln$+"!end"+Basic.Eoln$
  142.     Capture CAPTURE_OFF
  143.  
  144.     ' Create file new file to hold converted data
  145.     sScanNew = UniqueFileName$() 
  146.     nFNew = FreeFile
  147.     Open sScanNew For Output Access Write Shared As #nFNew
  148.     
  149.     ' Open old file and start reading
  150.     nFOld = FreeFile
  151.     Open sScanOld For Input Shared As #nFOld
  152.     Print #nFNew, "!start "+forum+"/Sysop_Logs Held_Messages"
  153.     Print #nFNew, "Messages on Hold"
  154.     Print #nFNew, ""
  155.     
  156.     Do While Not EOF(nFOld)
  157.         
  158.         ' Get line
  159.         Line Input #nFOld,sNextLine
  160.                 
  161.         ' Check for message number
  162.         If Left$(sNextLine,2) = "#:" Then
  163.                 
  164.             ' Parse line
  165.             sNextLine = Trim$(sNextLine)
  166.             sNextLine = Mid$(sNextLine,4)
  167.             nTextBreak = Instr(1,sNextLine," ")
  168.             sMsgNumber = Mid$(sNextLine,1,nTextBreak-1)
  169.             sMsgSection = Mid$(sNextLine,nTextBreak+5)
  170.             
  171.             ' Add underscores
  172.             For nIndex = 1 to Len(sMsgSection)
  173.                 Select case Mid$(sMsgSection,nIndex,1)
  174.                     Case "/"," "
  175.                         Mid$(sMsgSection,nIndex,1) = "_"
  176.                 End Select
  177.             Next nIndex
  178.             
  179.             Print #nFNew, "VA:Cis:" + forum + "/" + sMsgSection + "#" + sMsgNumber
  180.         End If
  181.     Loop
  182.     Print #nFNew, "!end"
  183.     
  184.     ' Close open files
  185.     Close #nFOld
  186.     Close #nFNew
  187.     
  188.     ' Delete the old scan file
  189.     Kill sScanOld
  190.  
  191.     ' Add to import queue
  192.     If QueueFile(Session.Service, sScanNew, IM_DELETE) Then
  193.         ReportSuccess id & " : Held Message List for forum " & forum & " collected"
  194.     Else
  195.         ReportSuccess id & " : Held Message List for forum " & forum & " failed"
  196.     End If
  197.     
  198.     Terminal.Status ""
  199.     Exit Sub
  200.     
  201. AsciiListHeldMessages_Error:
  202.     LogResult "Error running Held Message List script"    
  203. End Sub
  204.  
  205. 'T:WelcomeMailTo (subroutine) (CompuServe)
  206. Sub WelcomeMailTo(id As String, forum As String, user As String)
  207.     Dim fname As String
  208.  
  209.     fname = Session.ServicePath
  210.     AddBackslash fname
  211.     If InStr(forum, ":")<>0 Then
  212.         fname = fname + Mid$(forum, InStr(forum, ":")+1, 8)+".wel"
  213.     Else
  214.         fname = fname + Mid$(forum, 1, 8)+".wel"
  215.     End If
  216.  
  217.     MailTo "Welcome", user, fRECEIPT+fDONTCOPY, _
  218.            "Welcome to the "+forum+" Forum", fname
  219.     SendMail "Welcome"
  220.     ReportSuccess id & " : Welcome message sent to " & user
  221. End Sub
  222.  
  223.