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

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