IPB

Welcome Guest ( Log In | Register )

2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 
Closed TopicStart new topic
> DQD Project, Dynamic Queue Delegator
Snap
post Mar 13 2009, 04:11 AM
Post #1


The following post is supplementry information
*****

Group: Global Moderators
Posts: 2,922
Joined: 29-January 06
From: Eugene Oregon
Member No.: 31



The Dynamic Queue Delegator Plugin for Beta R31+

Previously scripts to share a queue used some sort of 'SharedQueue' sub or an addq-replacement.
Avoiding both of these methods DQD interfaces with the queue object using Event_MessageQueued.
By doing this I introduce a shared-queue system globally which affects built-in commands as well as plugins, and regular chat. (You can even paste multi-lined text).

When a bot has nothing in it's queue - and hasn't sent a message in [x]ms it checks the database to see if it can pick up a message.
All "/" commands except for whispers aren't shared. This prevents any issues with plugin-reliant /whois requests & etc.

This will be a fairly light-weight plugin as the amount of code needed is small - however getting everything just right is taking some time.
QUOTE
[02:40:28 AM] <SCSF> Test 1
[02:40:29 AM] <Snapit> Test 2
[02:40:30 AM] <SCSF> Test 3
[02:40:32 AM] <Snapit> Test 3
[02:40:33 AM] <SCSF> Test 4
[02:40:34 AM] <Snapit> Test 5
[02:40:35 AM] <SCSF> Test 6
[02:40:38 AM] <SCSF> Test 7


52's helping me with the Race Conditions (What's causing that duplicate to exist) - after that's done there's some fine-tuning.
I'll probably have a usable version this weekend.

This post has been edited by Snap: Mar 13 2009, 04:14 AM


--------------------
~Life is all busy and stuff right now. - Car accident, lots of dr. appointments... Other stuff too. I still <3 StealthBot.net - - I'll be around.
Thinking about PMing me? Post it instead! CCX Forums | SnapNJacks Trivia Forums
IPB Image
IPB Image
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
AwaKening
post Mar 20 2009, 09:20 AM
Post #2


Don't u know who I am
***

Group: Sr. Members
Posts: 764
Joined: 19-February 06
From: Utah
Member No.: 275



Nice, I planned on doing something like this myself, but hadn't gotten around to it. How's it coming along?


--------------------
Rival Nations Reborn Map Creator

Clan RnR.com
If you're looking for a "REAL" dota league script, aim or pm me.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
The-Black-Ninja
post Mar 20 2009, 09:32 AM
Post #3


Pure Sex
********

Group: Moderators
Posts: 7,756
Joined: 13-August 06
Member No.: 7,372



Still don't see why you didn't just go with what I gave you tongue.gif You could've avoided this race issue all together. All my free time is spent doing the AGP, so I can't bounce ideas to you anymore sad.gif


--------------------
IPB Image

-My Plugins :: Thanks Pyro :)
IPB ImageIPB Image
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Jack
post Mar 21 2009, 12:47 PM
Post #4


Ultimate spammer.
********

Group: Sr. Members
Posts: 5,593
Joined: 28-January 06
Member No.: 28



CODE
'sq
'0.1

Private Const sq_bots = "Tech-Jack), Tech-Jack(, Tech-Jack-"
Private FSO

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

Sub sq_Event_UserTalk(Username, Flags, Message, Ping)
  
   bots = Split(sq_bots, ", ")
  
   For i = 0 To UBound(bots)
      If myUsername = bots(i) Then
         t = i
         If t = 0 Then t = UBound(bots) + 1
         If Username = bots(t-1) Then
            If GetVirtualQueueSize > 0 And Message = getLastMessage Then
               setLastMessage(FirstVirtualMessage())
               AddQ getLastMessage
               Call DeleteFirstVirtualMessage()
               Exit For
            End If
         End If
      End If
   Next
End Sub

Sub sq_Event_PressedEnter(Text)
  
   If Text = "/wtfhax" Then
      VetoThisMessage
      For i = 1 To 30
         sq_AddQ i & " wtf hax lawl"
      Next
      Exit Sub
   End If
   If Left(Text, 1) <> "/" Then
      VetoThisMessage
      Call sq_AddQ(Text)
   End If
End Sub

' ///
Sub sq_AddQ(Text)
  
   If Text = "" Then Exit Sub
   If GetQueueSize = 0 And GetVirtualQueueSize = 0 Then
      Call setLastMessage(Text)
      AddQ Text
   Else
      Set f = FSO.OpenTextFile("bqqhax.txt", 8, True)
      f.WriteLine Text
      f.Close
   End If
End Sub

Sub DeleteFirstVirtualMessage()
  
   Set f = FSO.OpenTextFile("bqqhax.txt", 1, True)
   msgs = Split(f.ReadAll, vbCrLf)
   f.Close
  
   Set f = FSO.OpenTextFile("bqqhax.txt", 2, True)
   For i = 1 To UBound(msgs)
      If msgs(i) <> "" Then f.WriteLine msgs(i)
   Next
   f.Close
End Sub

Sub setLastMessage(Text)
  
   Call SetSetting("sq", "LastMessage", Text, "", True)
End Sub

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

Function FirstVirtualMessage()
  
   Set f = FSO.OpenTextFile("bqqhax.txt", 1, True)
   FirstVirtualMessage = Split(f.ReadAll, vbCrLf)(0)
   f.Close
End Function

Function getLastMessage()
  
   getLastMessage = GetSetting("sq", "LastMessage")
End Function

Here's mine. I made it before all the dev releases and I think this was back in 2.697 or around there.

I loaded about 4 bots and then had someone spam "gamble; bet 50; roll; bet 50; roll" over and over again and it worked fine.








QUOTE
[13:35:33.330] <IdleBoT> We're no strangers to love
[13:35:34.759] <IdleSpamOne> You know the rules and so do I
[13:35:35.466] <IdleSpamTwo> A full commitment's what I'm thinking of
[13:35:36.378] <IdleSpamThree> You wouldn't get this from any other guy
[13:35:36.781] <IdleSpamFour> I just wanna tell you how I'm feeling
[13:35:37.322] <IdleBoT> Gotta make you understand
[13:35:38.457] <IdleSpamOne> Never gonna give you up
[13:35:39.049] <IdleSpamTwo> Never gonna let you down
[13:35:40.111] <IdleSpamThree> Never gonna run around and desert you
[13:35:41.460] <IdleSpamFour> Never gonna make you cry
[13:35:42.463] <IdleBoT> Never gonna say goodbye
[13:35:43.151] <IdleSpamOne> Never gonna tell a lie and hurt you
[13:35:44.112] <IdleSpamTwo> We've known each other for so long
[13:35:45.214] <IdleSpamThree> Your heart's been aching, but
[13:35:45.905] <IdleSpamFour> You're too shy to say it
[13:35:46.873] <IdleBoT> Inside we both know what's been going on
[13:35:47.776] <IdleSpamOne> We know the game and we're gonna play it
[13:35:48.978] <IdleSpamTwo> And if you ask me how I'm feeling
[13:35:49.927] <IdleSpamThree> Don't tell me you're too blind to see
[13:35:50.909] <IdleSpamFour> Never gonna give you up
[13:35:51.928] <IdleBoT> Never gonna let you down
[13:35:53.077] <Ribose[BoT]> holy shit win. ohmy.gif
[13:35:53.505] <IdleSpamOne> Never gonna run around and desert you
[13:35:54.642] <IdleSpamTwo> Never gonna make you cry
[13:35:55.417] <IdleSpamThree> Never gonna say goodbye
[13:35:55.990] <IdleSpamFour> Never gonna tell a lie and hurt you
[13:35:56.517] <IdleBoT> Never gonna give you up
[13:35:57.576] <IdleSpamOne> Never gonna let you down
[13:35:58.341] <IdleSpamTwo> Never gonna run around and desert you
[13:35:59.790] <IdleSpamThree> Never gonna make you cry
[13:36:00.583] <IdleSpamFour> Never gonna say goodbye
[13:36:01.423] <IdleBoT> Never gonna tell a lie and hurt you
[13:36:02.705] <IdleSpamOne> (Oooooooh, Give you up)
[13:36:03.328] <IdleSpamTwo> (Oooooooh, Give you UP)
[13:36:04.238] <IdleSpamThree> Never gonna give, never gonna give
[13:36:05.710] <IdleSpamFour> (Give you up)
[13:36:06.751] <IdleBoT> Never gonna give, never gonna give
[13:36:07.660] <IdleSpamOne> (Give you up)
[13:36:08.524] <IdleSpamTwo> We've known each other for so long
[13:36:09.152] <IdleSpamThree> Your heart's been aching, but
[13:36:10.127] <IdleSpamFour> You're too shy to say it
[13:36:11.144] <IdleBoT> Inside we both know what's been going on
[13:36:12.008] <IdleSpamOne> We know the game and we're gonna play it
[13:36:12.723] <IdleSpamTwo> I just wanna tell you how I'm feeling
[13:36:13.444] <IdleSpamThree> Gotta make you understand
[13:36:14.500] <IdleSpamFour> Never gonna give you up
[13:36:15.681] <IdleBoT> Never gonna let you down
[13:36:16.785] <IdleSpamOne> Never gonna run around and desert you
[13:36:17.694] <IdleSpamTwo> Never gonna make you cry
[13:36:18.603] <IdleSpamThree> Never gonna say goodbye
[13:36:19.165] <IdleSpamFour> Never gonna tell a lie and hurt you
[13:36:21.252] <IdleBoT> Never gonna give you up
[13:36:22.144] <IdleSpamOne> Never gonna let you down
[13:36:22.818] <IdleSpamTwo> Never gonna run around and desert you
[13:36:23.933] <IdleSpamThree> Never gonna make you cry
[13:36:24.996] <IdleSpamFour> Never gonna say goodbye
[13:36:25.522] <IdleBoT> Never gonna tell a lie and hurt you
[13:36:27.751] <IdleSpamOne> Never gonna give you up
[13:36:28.812] <IdleSpamTwo> Never gonna let you down
[13:36:29.912] <IdleSpamThree> Never gonna run around and desert you
[13:36:30.621] <IdleSpamFour> Never gonna make you cry
[13:36:34.600] <IdleBoT> Never gonna say goodbye
[13:36:35.937] <IdleSpamOne> Never gonna tell a lie and hurt you


New script:

CODE
Private FSO
Private followBot

Sub Data()
  
   Script("Name") = "SplitQueue"
   Script("Author") = "Jack"
   Script("Major") = 0           ' script major version
   Script("Minor") = 1           ' script minor version
   Script("Revision") = 0        ' script version revision
End Sub

Sub Event_Load()
  
   Set FSO = CreateObject("Scripting.FileSystemObject")
   bots = Split("IdleBoT, IdleSpamOne, IdleSpamTwo, IdleSpamThree, IdleSpamFour", ", ")
   For i = 0 To UBound(bots)
      If bots(i) = myUsername Then
         If i = 0 Then i = UBound(bots) + 1
         followBot = bots(i - 1)
         Exit For
      End If
   Next
  
   AddChat vbCyan, "I am following bot [" & followBot & "]"
End Sub

Sub Event_UserTalk(Username, Flags, Message, Ping)
  
   If Username = followBot Then
      If GetVirtualQueueSize() > 0 Then
         msg = FirstVirtualMessageAndDelete()
         REM AddChat vbMagenta, followBot & " SPEAKED! - " & msg
         AddQ msg, , "SplitQueue"
      End If
   End If
End Sub

Sub Event_UserEmote(Username, Flags, Message)
  
   If Username = followBot Then
      If GetVirtualQueueSize() > 0 Then
         msg = FirstVirtualMessageAndDelete()
         REM AddChat vbMagenta, followBot & " SPEAKED! - " & msg
         AddQ msg, , "SplitQueue"
      End If
   End If
End Sub

Sub Event_MessageQueued(MessageID, Message, Tag)
  
   If Left(Message, 1) = "/" And Not Left(Message, 4) = "/me " 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 AddToVirtualQueue(msg)

   Set f = FSO.OpenTextFile("queue.txt", 8, True)
   f.WriteLine msg
   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


--------------------
IPB Image
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
AbsoluteMSTR
post Mar 23 2009, 10:42 PM
Post #5


Full Member
***

Group: Beta Testers
Posts: 125
Joined: 5-August 07
Member No.: 27,229



Jack, your new one is better, fixes a lot of my problems

What about /cq and /scq?


--------------------
I offer hosting for ghost hosting on a dedicated server. PM for info
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
AwaKening
post Mar 28 2009, 08:09 PM
Post #6


Don't u know who I am
***

Group: Sr. Members
Posts: 764
Joined: 19-February 06
From: Utah
Member No.: 275



Added scq and cq functionality

CODE


Private FSO
Private followBot

Sub Data()
  
   Script("Name") = "SplitQueue"
   Script("Author") = "Jack"
   Script("Major") = 0           ' script major version
   Script("Minor") = 1           ' script minor version
   Script("Revision") = 1        ' script version revision
End Sub

Sub Event_Load()
  
   Set FSO = CreateObject("Scripting.FileSystemObject")
   bots = Split("IdleBoT, IdleSpamOne, IdleSpamTwo, IdleSpamThree, IdleSpamFour", ", ")
   For i = 0 To UBound(bots)
      If bots(i) = BotVars.Username Then
         If i = 0 Then i = UBound(bots) + 1
         followBot = bots(i - 1)
         Exit For
      End If
   Next
  
   AddChat vbCyan, "I am following bot [" & followBot & "]"
End Sub

Sub Event_PressedEnter(Text)
   If Text = "/cq" OR Text = "/scq" Then
         ClearVirtualQueue
   End If
End Sub

Sub Event_UserEmote(Username, Flags, Message)
   Event_UserTalk Username, Flags, Message, 0
End Sub

Sub Event_UserTalk(Username, Flags, Message, Ping)
  
   If Username = followBot Then
      If GetVirtualQueueSize() > 0 Then
         msg = FirstVirtualMessageAndDelete()
         REM AddChat vbMagenta, followBot & " SPEAKED! - " & msg
         AddQ msg, , "SplitQueue"
      End If
   ElseIf Message = BotVars.Trigger& "cq" OR Message = BotVars.Trigger& "scq" Then
          If HasAccess(Username, "cq") Then
                 ClearVirtualQueue
          End If
   End If
End Sub

Sub Event_MessageQueued(MessageID, Message, Tag)
  
   If Left(Message, 1) = "/" And Not Left(Message, 4) = "/me " 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 ClearVirtualQueue()
   Set f = FSO.OpenTextFile("queue.txt", 2, True)
   f.Close
   Set f = Nothing
End Sub

Sub AddToVirtualQueue(msg)

   Set f = FSO.OpenTextFile("queue.txt", 8, True)
   f.WriteLine msg
   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


I realized though, there are a few bugs with this script.

What if one of the bots is offline. Needs to be a check. One bot missing a queue will throw it all off.

This post has been edited by AwaKening: Mar 28 2009, 03:02 PM


--------------------
Rival Nations Reborn Map Creator

Clan RnR.com
If you're looking for a "REAL" dota league script, aim or pm me.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Jack
post Mar 28 2009, 08:16 PM
Post #7


Ultimate spammer.
********

Group: Sr. Members
Posts: 5,593
Joined: 28-January 06
Member No.: 28



QUOTE(AwaKening @ Mar 28 2009, 09:09 PM) *


I realized though, there are a few bugs with this script.

What if one of the bots is offline. Needs to be a check. One bot missing a queue will throw it all off.


Same with the other one... it's your job to check. I guess one day I'll make it so it auto recognizes the bots.


--------------------
IPB Image
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Pyro
post Mar 28 2009, 08:22 PM
Post #8


huh?
********

Group: Root Administrators
Posts: 9,073
Joined: 23-February 07
From: Orlando, Florida
Member No.: 19,243



QUOTE(AwaKening @ Mar 28 2009, 10:09 PM) *
Added scq and cq functionality

You could've done the checking for those commands a little better.

CODE
Set cmd = IsCommand(Message)
If cmd.Name = "cq" Or cmd.Name = "scq" Then
    If HasAccess(Username, cmd.Name, cmd.Args) Then
        'do code...
    End If
End If
Set cmd = Nothing


--------------------
Pyro
Chieftain of Clan BoT.
Host of pyro.no-ip.biz
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
AwaKening
post Mar 29 2009, 12:47 PM
Post #9


Don't u know who I am
***

Group: Sr. Members
Posts: 764
Joined: 19-February 06
From: Utah
Member No.: 275



QUOTE(PyroManiac @ Mar 28 2009, 08:22 PM) *

QUOTE(AwaKening @ Mar 28 2009, 10:09 PM) *
Added scq and cq functionality

You could've done the checking for those commands a little better.

CODE
Set cmd = IsCommand(Message)
If cmd.Name = "cq" Or cmd.Name = "scq" Then
    If HasAccess(Username, cmd.Name, cmd.Args) Then
        'do code...
    End If
End If
Set cmd = Nothing



How's that better? Seems like extra unnecessary steps.


--------------------
Rival Nations Reborn Map Creator

Clan RnR.com
If you're looking for a "REAL" dota league script, aim or pm me.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Eric
post Mar 29 2009, 12:53 PM
Post #10


The Causeless Cause
*****

Group: Root Administrators
Posts: 2,952
Joined: 26-December 05
Member No.: 2



QUOTE(AwaKening @ Mar 29 2009, 11:47 AM) *

QUOTE(PyroManiac @ Mar 28 2009, 08:22 PM) *

QUOTE(AwaKening @ Mar 28 2009, 10:09 PM) *
Added scq and cq functionality

You could've done the checking for those commands a little better.

CODE
Set cmd = IsCommand(Message)
If cmd.Name = "cq" Or cmd.Name = "scq" Then
    If HasAccess(Username, cmd.Name, cmd.Args) Then
        'do code...
    End If
End If
Set cmd = Nothing



How's that better? Seems like extra unnecessary steps.

While I wouldn't necessarily advocate IsCommand() in it's present stance, without it, you ignore several different trigger types and features:

ops:
ops,
all:
all,
username:
username,
& sometimes: ?, !

Your check also ignores multiple commands in a single string (i.e., when using "; "), ignores enabled/disabled command statuses, and won't adapt to changes in trigger types without recoding.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
AwaKening
post Mar 31 2009, 04:16 PM
Post #11


Don't u know who I am
***

Group: Sr. Members
Posts: 764
Joined: 19-February 06
From: Utah
Member No.: 275



The multiple command string I get; although I've never checked for multiple commands in any of my scripts.

The first thing you mentioned though seems irrelevant to this particular command, but thanks for at least showing me how it works.

Edit: Removed all the updated code i posted because Jack cries that I "improved" his code.

@Jack, your code works with bots that run scripts using no padqueues and no whispers. Also assuming that all of your bots are always in the same channel with no chance of getting disconnected because then the queue will just back up and never be fixed unless you clear it and restart. Your code is basically shit. I made it better, but keep thinking otherwise because I don't give a shit.

This post has been edited by AwaKening: Apr 1 2009, 05:20 PM


--------------------
Rival Nations Reborn Map Creator

Clan RnR.com
If you're looking for a "REAL" dota league script, aim or pm me.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Snap
post Apr 2 2009, 12:48 AM
Post #12


The following post is supplementry information
*****

Group: Global Moderators
Posts: 2,922
Joined: 29-January 06
From: Eugene Oregon
Member No.: 31



#1. You guys totally hijacked my topic.

#2. DQD while basically employing this 'shared' concept - works a lot different. - And doesn't have the potential to 'break' like Jacks does (bot leaves the channel, disconnects etc)

#3. @Awakening - In the future I would recommend doing "Edited by Awakening" - or in the version description "Awakenings edit". - Rather than "By [user] AND Awakening".

#4. I don't have multiple non-SC keys - so until I can work around lockdown - I can't really work much on this project. -- But I do plan on releasing what I have soon non-the-less.

#5. Locked; Start your own split queue topic.

This post has been edited by Snap: Apr 2 2009, 12:49 AM


--------------------
~Life is all busy and stuff right now. - Car accident, lots of dr. appointments... Other stuff too. I still <3 StealthBot.net - - I'll be around.
Thinking about PMing me? Post it instead! CCX Forums | SnapNJacks Trivia Forums
IPB Image
IPB Image
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Closed TopicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 23rd July 2019 - 12:46 PM
Skin by Andrea
Website Legal Information | Hosted by LunarPages