Help - Search - Members - Calendar
Full Version: Queue++
StealthBot.net > StealthBot > Scripting and Plugins > Plugin Projects
AbsoluteMSTR
Like most Queue++ it simple and gets the job done.

What to do is go beyond and further.

Centralize one bot to handle all the scripts with other bots spiting the queue.

This are the bots you can assign
Master = Main bot with all the scripts
Slave = Split Queue of Master Bot
Client = Mimic the Master Bot
ClientSlave = Split Queue of Client bot

Have Features like
Auto Emote
Share Whisper
Forward Whisper
Merged Friends list
Moderation functionality (split queue for /ban /kick)
Mass Message Friends
Whisper List

Designed to handle a league in multiple channels

Probably going to use TextFile, Implement Database Later
Ribose
Since you have the beta, you can use the Event_MessageQueued(ID, Message, Tag) event to accomplish splitting the queue more universally than having to modify several scripts to support splitting the queue.
AbsoluteMSTR
should add, easy to implement with other scripts
long as it uses dsp, addq will work, just recommended you use dsp

Using a Text file was causing problems, probably going to switch to mysql
Jack
QUOTE(AbsoluteMSTR @ Jun 13 2009, 01:35 PM) *

should add, easy to implement with other scripts
long as it uses dsp, addq will work, just recommended you use dsp

Using a Text file was causing problems, probably going to switch to mysql

Uh, AddQ does not cause problems at all. I've already made the best SplitQueue released and it's flawless. Either do what Awakening did (copy my script and claim it all for yourself and that my script had perma bugs in it), or just use my script.
AwaKening
QUOTE(Jack @ Jun 13 2009, 12:40 PM) *

QUOTE(AbsoluteMSTR @ Jun 13 2009, 01:35 PM) *

should add, easy to implement with other scripts
long as it uses dsp, addq will work, just recommended you use dsp

Using a Text file was causing problems, probably going to switch to mysql

Uh, AddQ does not cause problems at all. I've already made the best SplitQueue released and it's flawless. Either do what Awakening did (copy my script and claim it all for yourself and that my script had perma bugs in it), or just use my script.


/signed lol

Jacks works great. I simply made my own, using a lot of Jack's code/ideas, before he fixed his (using my ideas), but whatever. I haven't given mine to anyone, and won't be since jack fixed his anyway. Point is, just use Jacks.
Jack
If you tell me what to add then I'll do it.
AbsoluteMSTR
If Jack, or Awakening can add it. The feature I desire most is the /w and /ban and /kick also being queued.

I could try playing around with both your codes. I figure using a database would be better then a text file. Since i never bothered to play around with access and learned first hand with mysql. I prefure using mysql more.
Jack
QUOTE(AbsoluteMSTR @ Jun 17 2009, 01:00 PM) *

If Jack, or Awakening can add it. The feature I desire most is the /w and /ban and /kick also being queued.

I could try playing around with both your codes. I figure using a database would be better then a text file. Since i never bothered to play around with access and learned first hand with mysql. I prefure using mysql more.

Ribose, or I doubt me, is going to be making a new version which connects to PyNet. It will be able to go across multiple computers. I'm sure that will fix this problem.
AbsoluteMSTR
PyNet? what that?
Pyro
http://pynet.no-ip.org/
AbsoluteMSTR
Not done, but the basic functionality is done.

MySQL structure is

CODE
CREATE TABLE `queue` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(15) NOT NULL,
  `message` varchar(255) NOT NULL,
  `queued` tinyint(1) NOT NULL DEFAULT '0',
  `sent` tinyint(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM;


CODE
Script("Name") = "QueuePlusPlus"
Script("Author") = "AbsoluteMSTR"
Script("Major") = 2
Script("Minor") = 0
Script("Revision") = 1

Public Database
' Database Variables
Const DBServer = "127.0.0.1"
Const DBDatabase = "stealthbot"
Const DBUser = "root"
Const DBPass = "root"

' QueuePlusPlus Variables
Const QueueBot = "AbsoluteMSTR GameServer"
' Auto Add /me
Const AutoEmote = True
' Let other Bots use /w
Const ForwardWhisper = True
' Let other bots send pad queue
Const SendPadQueue = False
' Must have one bot as operator else it will hinder proformance
Const SendBanKick = False


Public Bots
Public BotCount
Public BotIndex
Public QueuePlusPlus

Sub Event_Load()
  Database_Load
  Set QueuePlusPlus = New QueuePlusPlusClass
  Bots = Split(QueueBot)
  BotCount = UBound(Bots)+1
  BotIndex = 0
  Set MessageTimer = CreateObj("Timer", "CheckMessage")
  MessageTimer.Enabled = true
  MessageTimer.Interval = 50
End Sub

Sub Event_MessageQueued(MessageID, Message, Tag)
  If Message = "%%%%%blankqueuemessage%%%%%" Or Message = "" AND Not SendPadQueue Then Exit Sub
  If Not ForwardWhisper AND Left(Message, 3) = "/w " OR Left(Message, 9) = "/whisper " Then Exit Sub
  If Not SendBanKick AND Left(Message, 6) = "/kick " OR Left(Message, 5) = "/ban " Then Exit Sub
  If Left(Message, 1) = "/" And Not Left(Message, 3) = "/w " AND Not Left(Message, 9) = "/whisper " AND Not Left(Message, 6) = "/kick " AND Not Left(Message, 5) = "/ban " AND Not Left(Message, 3) = "/me" Then Exit Sub
  If Tag = "" Then
    If AutoEmote AND Not Left(Message, 1) = "/" Then Message = "/me " & Message
    Queue.RemoveItemByID(MessageID)
    BotIndex = (BotIndex + 1) Mod BotCount
    Bot = Bots(BotIndex)
    If Not QueuePlusPlus.IsOnline(Bot) Then
      Call Event_MessageQueued(MessageID, Message, Tag)
      Exit Sub
    ElseIf QueuePlusPlus.IsOperator(Bot) Then
      Call Event_MessageQueued(MessageID, Message, Tag)
      Exit Sub
    End If
    Call QueuePlusPlus.QueueMessage(Bot,Message)
  ElseIf Tag = "NoEmote" Then
    Queue.RemoveItemByID(MessageID)
    BotIndex = (BotIndex + 1) Mod BotCount
    Bot = Bots(BotIndex)
    If Not QueuePlusPlus.IsOnline(Bot) Then
      Call Event_MessageQueued(MessageID, Message, Tag)
      Exit Sub
    ElseIf QueuePlusPlus.IsOperator(Bot) Then
      Call Event_MessageQueued(MessageID, Message, Tag)
      Exit Sub
    End If
    Call QueuePlusPlus.QueueMessage(Bot,Message)
  ElseIf Tag = "NoQueue" Then
    Exit Sub
  End If
End Sub

Sub Event_MessageSent(MessageID, Message, Tag)
  If Tag <> "NoQueue" Then QueuePlusPlus.MarkAsSent(Tag)
End Sub

Sub CheckMessage_Timer()
  QueueMessage = QueuePlusPlus.RecieveMessage
  QueueID = QueuePlusPlus.LastID
  If Not QueueMessage = "" Then
    AddQ QueueMessage,,QueueID
  End If
End Sub

'
' QueuePlusPlus Class
'
Class QueuePlusPlusClass

  Public LastID

  Function RecieveMessage()
    Set RecieveData = Database.GetRow("queue","queued",0)
    If RecieveData.BOF and RecieveData.EOF Then
      RecieveMessage = ""
    Else
      If CStr(RecieveData("name")) = Channel.Self.Name Then
        MessageID = CInt(RecieveData("id"))
        LastID = MessageID
        If NextInLine = MessageID Then
          RecieveMessage = CStr(RecieveData("message"))
          Call Database.UpdateData("queue","queued",1,"id",CInt(RecieveData("id")))
        End If
      Else
        RecieveMessage = ""
      End If
    End If
  End Function
  
  Function NextInLine()
    Set NextInLineData = Database.GetRow("queue","sent",0)
    If NextInLineData.BOF and NextInLineData.EOF Then
      NextInLine = 0
    Else
      NextInLine = CInt(NextInLineData("id"))
    End If
  End Function
  
  Function GetQueueSize()
    GetQueueSize = Database.GetRowsCount("queue","queued",0)
  End Function
  
  Sub QueueMessage(Bot, Message)
    Call Database.InsertData("queue",Array("name","message"),Array(Bot,Message))
  End Sub
  
  Sub MarkAsSent(QueueID)
    Call Database.UpdateData("queue","sent",1,"id",QueueID)
  End Sub
  
  Function IsOperator(Name)
    ChannelIndex = Channel.GetUserIndex(Name)
    If ChannelIndex = 0 Then
      IsOperator = False
    Else
      IsOperator = Channel.Users(ChannelIndex).IsOperator
    End If
  End Function
  
  Function IsOnline(Name)
    ChannelIndex = Channel.GetUserIndex(Name)
    If ChannelIndex = 0 Then
      IsOnline = False
    Else
      IsOnline = True
    End If
  End Function
  
End Class

'
' Database Load
'
Sub Database_Load
  Set Database = New DatabaseClass
End Sub

'
' Database Class
'
Class DatabaseClass

  Private ConnectionString
  Private DB

  Private Sub Class_Initialize
    Set DB = CreateObject("ADODB.Connection")
    ConnectionString = "DRIVER={MySQL ODBC 5.1 Driver};SERVER=" & DBServer & ";DB=" & DBDatabase & ";USER=" & DBUser & ";PASSWORD=" & DBPass & ";OPTION=3;"
  End Sub

  Private Sub Class_Terminate
    Close
    Set DB = Nothing
  End Sub
  
  Private Sub Connect
    If DB.ConnectionString = "" Then
      DB.ConnectionString = ConnectionString
    End If
  End Sub

  Public Sub Open
    If Not CBool(DB.State) Then
      Connect
      DB.Open
    End If
  End Sub

  Public Sub Close
    If CBool(DB.State) Then
      DB.Close
    End If
  End Sub

  Public Function Query(SQL)
    Open
    Set Query = DB.Execute(SQL)
  End Function

  Public Function Count(Table)
    Set Row = Query("SELECT COUNT(*) From `" &Table&"`")
    Count = CInt(Row(0))
  End Function
  
  Function GetRow(From,Where,Find)
    Set GetRow = Database.Query("SELECT * FROM `"&From&"` WHERE `"&Where&"`='"&Find&"' Limit 1")
  End Function
  
  Function GetRows(From,Where,Find,Limit)
    Set GetRows = Database.Query("SELECT * FROM `"&From&"` WHERE `"&Where&"`='"&Find&"' Limit "&Limit)
  End Function
  
  Function GetRowsCount(From,Where,Find)
    Set Result = Database.Query("SELECT Count(*) FROM `"&From&"` WHERE `"&Where&"`='"&Find&"'")
    If Result.BOF And Result.EOF Then
      GetRowsCount = 0
    Else
      GetRowsCount = CInt(Result(0))
    End If
  End Function
  
  Sub UpdateData(Table,Key,Value,Where,Find)
    Database.Query("UPDATE `"&Table&"` SET `"&Key&"`='"&Value&"' WHERE `"&Where&"`='"&Find&"' LIMIT 1")
  End Sub
  
  Sub InsertData(Table,Keys,Values)
    Database.Query("INSERT INTO `"&Table&"` (`"&Join(Keys,"`,`")&"`) VALUES('"&Join(Values,"','")&"')")
  End Sub
End Class
Jack
Your code is ugly. =(
AbsoluteMSTR
Jack, its better then yours or to be fair it does more then yours right now.

QUOTE(Jack @ Jul 11 2009, 12:56 AM) *

Your code is ugly. =(


http://fiftytoo.no-ip.com:45000/websvn/fil...euePlusPlus.txt

more up to date
Jack
QUOTE(AbsoluteMSTR @ Jul 11 2009, 11:00 AM) *

Jack, its better then yours or to be fair it does more then yours right now.

QUOTE(Jack @ Jul 11 2009, 12:56 AM) *

Your code is ugly. =(


http://fiftytoo.no-ip.com:45000/websvn/fil...euePlusPlus.txt

more up to date

Does more? How? Mine perfectly splits up a queue between multiple bots and in the perfect order, I don't see anywhere in your shitty code where it does that. You got a simple timer and AddQ's which I doubt gets anywhere close to in order after you paste long text.

Also mine isn't designed to split up bans because my clan has a plugin for that already.
AbsoluteMSTR
are you saying this because you tried it out or you suck at reading code

yes my script does it in order
1
2
3
4
works fine
Jack
QUOTE(AbsoluteMSTR @ Jul 11 2009, 11:11 PM) *

are you saying this because you tried it out or you suck at reading code

yes my script does it in order
1
2
3
4
works fine

OK I'll try it out and watch it fuck up. Let me try to set this piece of shit up.

Wow I turn it on and before I even get a chance to type I get IPBanned. Fail.
AbsoluteMSTR
lol really funny.
Jack
I slightly approve after the horrible setup.
Ice.Mage
I have worked on setups like this before. I have used dbs with it though haven't fully finished with many parts to it but I hate how even with my bots splitting workload between them, stuff still gets pretty delayed at times due to how the queue is different now then how it was in 2.6 Anyways, I am interested into seeing how others do theirs especially because i still haven't finished mine and have plenty of things I want to do with it anyway.
FoxInTheBox
Can I use this? i just copy the text and put it in my bots plugin folder?
AbsoluteMSTR
Instructions:

Need MySQL ODBC 5.1
http://dev.mysql.com/downloads/connector/odbc/5.1.html

Need a MySQL Server
Recommend Uniform Server
http://www.uniformserver.com/

Afterwards run the SQL
CODE
CREATE TABLE `queue` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(15) NOT NULL,
  `message` varchar(255) NOT NULL,
  `queued` tinyint(1) NOT NULL DEFAULT '0',
  `sent` tinyint(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM;


Get the latest QueuePlusPlus Script at
http://fiftytoo.no-ip.com:45000/websvn/fil...euePlusPlus.txt

Put it in your bot, and configure the script.
Copy and paste it for each bot. Note this is for 2.7, not 2.6
FoxInTheBox
Ohh thanks anyways
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.