Help - Search - Members - Calendar
Full Version: [BETA] SplitQueue
StealthBot.net > StealthBot > Scripting and Plugins > Plugin Projects
Jack
CODE
Private FSO
Private followBot

Private Const Master = "IdleBoT"
Private Const all = "IdleBoT, Slave-One, Slave-Two, Slave-Three, Slave-Four"
Private c

Script("Name") = "SplitQueue"
Script("Author") = "Jack"
Script("Major") = 0           ' script   major version
Script("Minor") = 3           ' script   minor version
Script("Revision") = 0        ' script   version revision
Script("Description") = "Splits the queue."  


Sub Event_Load()
  
   Set FSO = CreateObject("Scripting.FileSystemObject")
End Sub

Sub Event_UserTalk(Username, Flags, Message, Ping)
  
   Call SplitQueue_processMessage(Username, Message)
End Sub

Sub Event_UserEmote(Username, Flags, Message)
  
   Call SplitQueue_processMessage(Username, Message)
End Sub

Sub Event_MessageQueued(MessageID, Message, Tag)
  
   If followBot = "" Then Exit Sub
  
   If Left(Message, 1) = "/" And Not Left(Message, 4) = "/me " Then Exit Sub
   If Message = "%%%%%blankqueuemessage%%%%%" Or Message = "" Then Exit Sub
  
   If (GetVirtualQueueSize() > 0 Or Queue.Count > 1) And Not Tag = "SplitQueue" Then
      Queue.RemoveItemByID(MessageID)
      AddToVirtualQueue(Message)
   End If
End Sub

Sub Event_UserJoins(Username, Flags, Message, Ping, Product, Level, OriginalStatstring, Banned)
  
   If InStr(all, Username) Then resetBots()
End Sub

Sub Event_UserLeaves(Username, Flags)
  
   If InStr(all, Username) Then resetBots()
End Sub

Sub Event_UserInChannel(Username, Flags, Message, Ping, Product, StatUpdate)
  
   If Username = Master Then c = True
  
   If Username = Channel.Self.DisplayName And c = True Then
      resetBots()
      c = False
   End If
End Sub

Sub Event_ChannelJoin(ChannelName, Flags)
  
   followBot = ""
End Sub

Sub Event_PressedEnter(Text)
  
   If LCase(Text) = "/scq" Or LCase(Text) = "/cq" Then
      VetoThisMessage
      ClearQueue()
   End If
End Sub


' // Script functions
Sub SplitQueue_processMessage(Username, Message)
  
   If Username = followBot Then
      If GetVirtualQueueSize() > 0 Then
         msg = FirstVirtualMessageAndDelete()
         AddQ msg, , "SplitQueue"
      End If
   End If
      
   Set cmd = IsCommand(Message)
   If cmd.Name = "cq" Or cmd.Name = "scq" Then
      If HasAccess(Username, cmd.Name, cmd.Args) Then
         ClearQueue()
      End If
   End If
   Set cmd = Nothing
  
   If LCase(Message) = BotVars.Trigger & "followbot" Then
      AddQ "I am following bot [" & followBot & "]"
   End If
End Sub

Sub resetBots()
  
   ' // not in same channel as master bot
   If Channel.GetUserIndex(Master) = 0 Then
      followBot = ""
   Else
      For Each name In Split(all, ", ")
         If Channel.GetUserIndex(name) > 0 Then
            a = a & name & ", "
         End If
      Next
      a = Left(a, Len(a) - 2)
      
      AddChat vbMagenta, a
      
      bots = Split(a, ", ")
      For i = 0 To UBound(bots)
         If bots(i) = Channel.Self.DisplayName Then
            If i = 0 Then i = UBound(bots) + 1
            followBot = bots(i - 1)
            Exit For
         End If
      Next
   End If
  
   If followBot = Channel.Self.DisplayName Then followBot = ""
   AddChat vbCyan, "I am following bot [" & followBot & "]"
End Sub


' // Queue functions
Sub AddToVirtualQueue(msg)
  
   Set f = FSO.OpenTextFile("queue.txt", 8, True)
   f.WriteLine msg
   f.Close
End Sub

Sub ClearQueue()
  
   Set f = FSO.OpenTextFile("queue.txt", 2, True)
   f.Close
End Sub

Function GetVirtualQueueSize()
  
   Set f = FSO.OpenTextFile("queue.txt", 1, True)
   Do While Not f.AtEndOfStream
      l = f.ReadLine
      GetVirtualQueueSize = GetVirtualQueueSize + 1
   Loop
   f.Close
End Function

Function FirstVirtualMessageAndDelete() ' // also known as "pop" :D
  
   Set f = FSO.OpenTextFile("queue.txt", 1, True)
   msgs = Split(f.ReadAll, vbCrLf)
   f.Close
  
   Set f = FSO.OpenTextFile("queue.txt", 2, True)
   For i = 1 To UBound(msgs)
      If msgs(i) <> "" Then f.WriteLine msgs(i)
   Next
   f.Close
  
   FirstVirtualMessageAndDelete = msgs(0)
End Function




Bot will work if it is the master and has slaves in the same channel. Slaves will not work by themselves.


No you may not edit it, fuck off noobs. It is my script and if you do edit it don't share it because you are a noob, yes you awakening.

Post bugs here.
AwaKening
QUOTE
No you may not edit it, fuck off noobs. It is my script and if you do edit it don't share it because you are a noob, yes you awakening.


Well I don't need to share it because you already are, (sharing my fixes). Except that you ruined some of my fixes by trying to do it your way.

It turns me on to see you so angry for fixing your code though. Maybe I'll throw you some more bugs for amusement.
Jack
QUOTE(AwaKening @ Apr 10 2009, 01:49 AM) *

QUOTE
No you may not edit it, fuck off noobs. It is my script and if you do edit it don't share it because you are a noob, yes you awakening.


Well I don't need to share it because you already are, (sharing my fixes). Except that you ruined some of my fixes by trying to do it your way.

It turns me on to see you so angry for fixing your code though. Maybe I'll throw you some more bugs for amusement.

My original script had no "bugs." It just wasn't complete because it was just a script I threw together. This script also has no "bugs" and I did not steal any ideas from you at all, nor did I "ruin" any of your fixes because I didn't look at your script, I started with my original.
nate
Unless I am missing something, all the bots need to be running on the same machine as the queue is stored locally in a text file correct?
Jack
QUOTE(Nate @ Apr 10 2009, 09:08 AM) *

Unless I am missing something, all the bots need to be running on the same machine as the queue is stored locally in a text file correct?

For mine, yes. I could however easily modify it to use a server like botnet or pynet to send the messages around.
Sui(C)ide
So like, the variable "all", do bots names get stored there?
2. Does ech bot have this?
3. Guide please.
Pyro
Stop posting on this board. Use the new one.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2019 Invision Power Services, Inc.