• Welcome to Valhalla Legends Archive.
 

better queue system

Started by Gangz, June 05, 2004, 03:52 PM

Previous topic - Next topic

Gangz

Currently i have my queue checking every 3 seconds if there is a message that needs to be sent. You can imagine when i need it to respond fast it does not.



Private Sub tmrQueue_Timer()
   If tmrQueue.Interval = tmrQueue.Interval * GetStuff("Config", "Queue", "Reset") Then
       tmrQueue.Interval = GetStuff("Config", "Queue", "Delay")
   End If
If Left(cboQueue.List(0), 4) = "/ban" Then
splt = Split(cboQueue.List(0), "/ban ")(1)
splt = Split(splt, " ")(0)
For i = 0 To Form1.safelist.ListCount - 1
   If LCase(Form1.safelist.List(i)) = LCase(splt) Then
       cboQueue.RemoveItem 0
       cboQueue.AddItem "This user cannot be banned due to the safelist!"
       Exit Sub
   End If
Next i
ElseIf Left(cboQueue.List(0), 5) = "/kick" Then
splt = Split(cboQueue.List(0), "/kick ")(1)
splt = Split(splt, " ")(0)
For i = 0 To Form1.safelist.ListCount - 1
   If LCase(Form1.safelist.List(i)) = LCase(splt) Then
       cboQueue.RemoveItem 0
       cboQueue.AddItem "This user cannot be kicked due to the safelist!"
       Exit Sub
   End If
Next i
ElseIf Left(cboQueue.List(0), 8) = "/squelch" Then
splt = Split(cboQueue.List(0), "/squelch ")(1)
splt = Split(splt, " ")(0)
For i = 0 To Form1.safelist.ListCount - 1
   If LCase(Form1.safelist.List(i)) = LCase(splt) Then
       cboQueue.RemoveItem 0
       cboQueue.AddItem "This user cannot be ignored due to the safelist!"
       Exit Sub
   End If
Next i
ElseIf Left(cboQueue.List(0), 7) = "/ignore" Then
splt = Split(cboQueue.List(0), "/ignore ")(1)
splt = Split(splt, " ")(0)
For i = 0 To Form1.safelist.ListCount - 1
   If LCase(Form1.safelist.List(i)) = LCase(splt) Then
       cboQueue.RemoveItem 0
       cboQueue.AddItem "This user cannot be ignored due to the safelist!"
       Exit Sub
   End If
Next i
End If

   If cboQueue.List(0) <> "" Then
   Dim y As Integer, X As Integer
       Form1.Send cboQueue.List(0)
       cboQueue.RemoveItem 0
       tmrQueue.Interval = tmrQueue.Interval + GetStuff("Config", "Queue", "Add")
       lblDelay.Caption = "Delay: " & tmrQueue.Interval
   End If
End Sub


any suggestions?

CrAz3D

Make it check at a shorter interval?...
rebundance - having or being in excess of sheer stupidity
(ré-bun-dance)
Quote from: Spht on June 22, 2004, 07:32 PMSlap.
Quote from: Adron on January 28, 2005, 09:17 AMIn a way, I believe that religion is inherently evil, which includes Christianity. I'd also say Christianity is eviller than Buddhism (has more potential for evil).
Quote from: iago on April 19, 2005, 01:06 PM
CrAz3D's ... is too big vertically, at least, too big with ... iago ...

MyndFyre

Quote from: CrAz3D on June 05, 2004, 04:03 PM
Make it check at a shorter interval?...

I have my incoming queue checked every 10 ms or so.  That is sometimes barely enough time for a given thread to complete.  :)
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

Gangz

So make the interval about 5-10ms and then change it back to 3000 when there is more then 1 msg to be sent?

Eli_1

#4
There's a good flood protection on the botdev website somewhere in the documents section. Go read the code and figure out how it works[/u][/i], then model a similar flood protection after it.

Gangz

LoL Im not talking about flood protection. Im talking about the queue as a whole.

CrAz3D

Flood protection is so YOUR CLIENT doesn't flood.  It should be flood prevention, or something like that.
rebundance - having or being in excess of sheer stupidity
(ré-bun-dance)
Quote from: Spht on June 22, 2004, 07:32 PMSlap.
Quote from: Adron on January 28, 2005, 09:17 AMIn a way, I believe that religion is inherently evil, which includes Christianity. I'd also say Christianity is eviller than Buddhism (has more potential for evil).
Quote from: iago on April 19, 2005, 01:06 PM
CrAz3D's ... is too big vertically, at least, too big with ... iago ...

Dyndrilliac

I posted a Queue System a few days ago that I finally got working perfectly.

Public Queue() As String
Public QNum    As Integer
Public QDelay  As Single
Public sFloodThresh As String
Public iFloodThresh As Single

Public Sub AddQ(Message As String)
   On Error GoTo ErrorHandle
   If sFloodThresh = Message Or Len(sFloodThresh) = Len(Message) Then
       iFloodThresh = iFloodThresh + 1
       If iFloodThresh >= 4 Then
           Pause 2, True
           iFloodThresh = 0
       End If
   Else
       iFloodThresh = 0
   End If
TryAgain:
   Do Until Queue(QNum) = vbNullString
       QNum = QNum + 1
   Loop
   Queue(QNum) = Message
   sFloodThresh = Message
   Exit Sub
ErrorHandle:
   QNum = 0
   ReDim Preserve Queue(1000)
   Queue(0) = vbNullString
   GoTo TryAgain
End Sub

Private Sub tQueue_Timer()
   If Connected = False Then
       Exit Sub
   End If

   If Queue(QNum) = vbNullString Then
       Exit Sub
   End If

   Dim i As Integer
   For i = 0 To QNum
       QDelay = ((Len(Queue(i)) / 10) / 2)
       If Len(Queue(i)) <= 10 & QDelay <= 0.5 Then
           QDelay = QDelay + 0.5
       End If
       Pause QDelay, True
       QDelay = 0
       Send Queue(i)
       Queue(i) = vbNullString
   Next i
End Sub


My Timer's Interval is set at 50ms.
Quote from: Edsger W. DijkstraIt is practically impossible to teach good programming to students that have had a prior exposure to BASIC; as potential programmers they are mentally mutilated beyond hope of regeneration.

Gangz

Instead of using someone elses coding i just added


   If Form1.cboQueue.ListCount < 2 Then tmrQueue.Interval = GetStuff("Config", "Queue", "Delay")
   If Form1.cboQueue.ListCount > 1 Then tmrQueue.Interval = GetStuff("Config", "Queue", "Delay2")


it seems to be working okay now.

hismajesty

You shouldn't use a form control for your queue.

BinaryzL

Quote from: Eli_1 on June 05, 2004, 05:50 PM
There's a good flood protection on the botdev website somewhere in the documents section. Go read the code and figure out how it works[/u][/i], then model a similar flood protection after it.

Yeah, so that is of no use basically.

Adron

Quote from: Gangz on June 05, 2004, 07:46 PM
it seems to be working okay now.

Won't that code make you flood if you're typing fast (as opposed to pasting or automatically generating)? Sounds like you'll first send one message fast,  because it's the only one, then another, then another, and ... flood.

Gangz

Quote from: Adron on June 06, 2004, 04:52 AM
Quote from: Gangz on June 05, 2004, 07:46 PM
it seems to be working okay now.

Won't that code make you flood if you're typing fast (as opposed to pasting or automatically generating)? Sounds like you'll first send one message fast,  because it's the only one, then another, then another, and ... flood.

Actually If you type fast enough to send more then 1 message a second then it raises the queue. My bot is a moderation bot withought a chat inferface. If You are using commands at 1 msg per second then your probably abuse the the use of the bot and deserve to have it dropped.

CrAz3D

WHAT kind of logic is that?!  Moderation bots are supposed to stay up no matter what.
rebundance - having or being in excess of sheer stupidity
(ré-bun-dance)
Quote from: Spht on June 22, 2004, 07:32 PMSlap.
Quote from: Adron on January 28, 2005, 09:17 AMIn a way, I believe that religion is inherently evil, which includes Christianity. I'd also say Christianity is eviller than Buddhism (has more potential for evil).
Quote from: iago on April 19, 2005, 01:06 PM
CrAz3D's ... is too big vertically, at least, too big with ... iago ...

Gangz

Its true, but the chances of anyone dropping it is [bold]VERY[/bold] slim. I added everyone i know and did my best to try and drop it and it could not be done. The only possbile way to drop it is add a chat interface and spam all over