I am creating a lock down function that does not use queue (made for stopping floods). I was wondering if there is any type of function that can make it not send to times.
If Form1.chklock = vbChecked Then Form1.Send "/ban " & username & " Lockdown" & lockname
Message = "/ban " & username & " Lockdown" & lockname
Message is the one that needs to not be repeated
I don't see what you're having a problem with. It doesn't seem very difficult,does it?
I know a few great bots that use a queue and can ban flood bots, if it tries to
Yea but very few.. I tested my bot on evey flood i could find and banned titan 4 times on 4 rj and turtle bot 2 times on 2 1 rj floods. The project seems wirth the time.
Here is an example on what you could do,
If Not Message = LastMessage then
'Do whatever
End If
Quote from: Gangz on December 30, 2003, 05:40 PM
Yea but very few.. I tested my bot on evey flood i could find and banned titan 4 times on 4 rj and turtle bot 2 times on 2 1 rj floods. The project seems wirth the time.
Sounds like really inefficient coding. You should be using a queue for messages and delay sends appropriately, otherwise you could easily spam yourself off Battle.net. A message queue will also allow you to check for duplicated op commands which you can exclude.
I do have a queue that can be customized by commands, but it seems that if I do lockdowns it sends 2 messages withought queue for the speed and then goes into the queue. I just want to avoid sending the same message twice just incase it was a mulitple flood or somthing.
ok. you arent using a queue for lockdown
'on user joins
SplitUserName = Split(UCase(UserName), "#")(0)
If GetTickCount - LastTick > 4000 And InOps And InStr(SafeList, "<" & SplitUserName & ">") = 0 Then
If ChannelProtect Or InStr(ShitList, "<" & SplitUserName & ">") Or flags = 32 Or flags = 48 Then
Ban UserName: LastTick = GetTickCount
Else
For xx = 1 To UBound(TagList)
If UCase(SplitUserName) Like UCase(TagList(xx)) Then Ban UserName: LastTick = GetTickCount: Exit For
Next xx
End If
End If
Quote from: o.OV on December 30, 2003, 08:03 PM
ok. you arent using a queue for lockdown
'on user joins
SplitUserName = Split(UCase(UserName), "#")(0)
If GetTickCount - LastTick > 4000 And InOps And InStr(SafeList, "<" & SplitUserName & ">") = 0 Then
If ChannelProtect Or InStr(ShitList, "<" & SplitUserName & ">") Or flags = 32 Or flags = 48 Then
Ban UserName: LastTick = GetTickCount
Else
For xx = 1 To UBound(TagList)
If UCase(SplitUserName) Like UCase(TagList(xx)) Then Ban UserName: LastTick = GetTickCount: Exit For
Next xx
End If
End If
What incredibly horrible code! Among other failings, it tries to treat a bitmask as discrete values. Use bitwise and to test their flags.
Quote from: Kp on December 30, 2003, 08:30 PM
Quote from: o.OV on December 30, 2003, 08:03 PM
ok. you arent using a queue for lockdown
'on user joins
SplitUserName = Split(UCase(UserName), "#")(0)
If GetTickCount - LastTick > 4000 And InOps And InStr(SafeList, "<" & SplitUserName & ">") = 0 Then
If ChannelProtect Or InStr(ShitList, "<" & SplitUserName & ">") Or flags = 32 Or flags = 48 Then
Ban UserName: LastTick = GetTickCount
Else
For xx = 1 To UBound(TagList)
If UCase(SplitUserName) Like UCase(TagList(xx)) Then Ban UserName: LastTick = GetTickCount: Exit For
Next xx
End If
End If
What incredibly horrible code! Among other failings, it tries to treat a bitmask as discrete values. Use bitwise and to test their flags.
.. well how would u rather do it
i know u are a better coder then me so help us out instead of telling me that my coding is horrid and please point out the other horrible parts of my coding .. then i can improve on it. thx kp
Ah.
Look kP
' Spht's example
If (flags and &H20) Then
its an example i found on bitmask comparison
now what other improvements can be done for the code i provided?
Quote from: o.OV on December 30, 2003, 10:07 PM
now what other improvements can be done for the code i provided?
Well, I'd suggest storing your safelist and banlist in a true list of some sort rather than as a massive string with illegal characters to delimit entries. As I recall, VB's support for such things tends to be rather poor though, so you may have some difficulty making it work. I'll leave it to the VB gurus to explain how to implement the list (it'd be trivial in C, not so in VB afaik).
Quote from: o.OV on December 30, 2003, 10:07 PM
Ah.
Look kP
' Spht's example
If (flags and &H20) Then
its an example i found on bitmask comparison
now what other improvements can be done for the code i provided?
I don't believe that's my example. I usually check if the result is actually equal to what I'm checking, and not only checking if it's greater than zero. If you only check if it's greater than zero, you may run into some unwanted happenings.
Quote from: Kp on December 30, 2003, 11:01 PM
Quote from: o.OV on December 30, 2003, 10:07 PM
now what other improvements can be done for the code i provided?
Well, I'd suggest storing your safelist and banlist in a true list of some sort rather than as a massive string with illegal characters to delimit entries. As I recall, VB's support for such things tends to be rather poor though, so you may have some difficulty making it work. I'll leave it to the VB gurus to explain how to implement the list (it'd be trivial in C, not so in VB afaik).
Nah, quite easy to do in VB, really. To wit:
Private Function OpenList(ByVal ListName As String) As ADODB.Recordset
Dim rs As ADODB.Recordset
Dim fso As Scripting.FileSystemObject
Dim sFile As String
Set fso = New Scripting.FileSystemObject
sFile = fso.BuildPath(App.Path, ListName & ".xml")
Set rs = New ADODB.Recordset
rs.CursorLocation = adUseClient
If fso.FileExists(sFile) = True Then
rs.Open sFile
Else
rs.Fields.Append "UserName", adVarChar, 30
rs.Fields.Append "Namespace", adVarChar, 30
rs.Fields.Append "Flags", adInteger
rs.Fields.Append "DateAdded", adDate
rs.Fields.Append "LastSeen", adDate
rs.Fields.Append "Notes", adVarChar, 200
rs.Open
rs.Save sFile, adPersistXML
End If
Set OpenList = rs
End Function
Quote from: Spht on December 30, 2003, 11:35 PM
Quote from: o.OV on December 30, 2003, 10:07 PM
Ah.
Look kP
' Spht's example
If (flags and &H20) Then
its an example i found on bitmask comparison
now what other improvements can be done for the code i provided?
I don't believe that's my example. I usually check if the result is actually equal to what I'm checking, and not only checking if it's greater than zero. If you only check if it's greater than zero, you may run into some unwanted happenings.
Oh =\
I thought that was you. Perhaps I misread the post.
Quote from: Spht on July 09, 2003, 10:38 AM
Quote from: ______ on July 09, 2003, 09:08 AM
put this on your join command
If flags = &H20 Then
cleanslatebot2.send "/ban " & username & " Ban Evasion Detected"
endif
Note that would fail if the user has "plug" (0x10). You should be doing a bitmask comparison for this type of thing. Example:
If (flags and &H20) Then
Ok. So maybe that wasn't you or maybe it was.
But if what you say is true and I might run into unwanted happenings then how should I properly make the comparison?
Quote from: Kp on December 30, 2003, 11:01 PM
Quote from: o.OV on December 30, 2003, 10:07 PM
now what other improvements can be done for the code i provided?
Well, I'd suggest storing your safelist and banlist in a true list of some sort rather than as a massive string with illegal characters to delimit entries. As I recall, VB's support for such things tends to be rather poor though, so you may have some difficulty making it work. I'll leave it to the VB gurus to explain how to implement the list (it'd be trivial in C, not so in VB afaik).
Reason why I avoid an array is because I normally use a loop to go through an array. I'll go look at the filter function again perhaps I missed something
Quote from: Kp on December 30, 2003, 11:01 PM
Quote from: o.OV on December 30, 2003, 10:07 PM
now what other improvements can be done for the code i provided?
Well, I'd suggest storing your safelist and banlist in a true list of some sort rather than as a massive string with illegal characters to delimit entries. As I recall, VB's support for such things tends to be rather poor though, so you may have some difficulty making it work. I'll leave it to the VB gurus to explain how to implement the list (it'd be trivial in C, not so in VB afaik).
I don't expect a response from you since u said you will let the VB gurus explain how to implement the list.
But I took a look at the filter function and this is the best I can come up with.
Private Sub Form_Load()
sArray = Array("<test1>", "<test>", "<3test>", "<4test4>")
strng = "<test>"
result = Filter(sArray, strng)
Debug.Print result(0)
'For x = LBound(result) To UBound(result)
' Debug.Print result(x)
'Next x
End Sub
I wish to avoid any type of VB loop.
Quote from: Grok on December 31, 2003, 08:09 AM
Quote from: Kp on December 30, 2003, 11:01 PM
Quote from: o.OV on December 30, 2003, 10:07 PM
now what other improvements can be done for the code i provided?
Well, I'd suggest storing your safelist and banlist in a true list of some sort rather than as a massive string with illegal characters to delimit entries. As I recall, VB's support for such things tends to be rather poor though, so you may have some difficulty making it work. I'll leave it to the VB gurus to explain how to implement the list (it'd be trivial in C, not so in VB afaik).
Nah, quite easy to do in VB, really. To wit:
Private Function OpenList(ByVal ListName As String) As ADODB.Recordset
Dim rs As ADODB.Recordset
Dim fso As Scripting.FileSystemObject
Dim sFile As String
Set fso = New Scripting.FileSystemObject
sFile = fso.BuildPath(App.Path, ListName & ".xml")
Set rs = New ADODB.Recordset
rs.CursorLocation = adUseClient
If fso.FileExists(sFile) = True Then
rs.Open sFile
Else
rs.Fields.Append "UserName", adVarChar, 30
rs.Fields.Append "Namespace", adVarChar, 30
rs.Fields.Append "Flags", adInteger
rs.Fields.Append "DateAdded", adDate
rs.Fields.Append "LastSeen", adDate
rs.Fields.Append "Notes", adVarChar, 200
rs.Open
rs.Save sFile, adPersistXML
End If
Set OpenList = rs
End Function
Wow Grok.
Quote from: o.OV on December 31, 2003, 11:05 AM
Ok. So maybe that wasn't you or maybe it was.
You got me.
If (flags and &H20) = &H20 Then
To explain why, run this:
Dim i As Long
Dim flags As Long
flags = &H20
Debug.Print "Checking &H" & Hex(flags) & " with flags 0 to 255 using If (flags And i) = i Then:"
For i = 1 To &HFF
If (flags And i) = i Then Debug.Print "(&H" & Hex(flags) & " And &H" & Hex(i) & ") = &H" & Hex(flags And i)
Next i
Debug.Print "Checking &H" & Hex(flags) & " with flags 0 to 255 using If (flags And i) Then:"
For i = 1 To &HFF
If (flags And i) Then Debug.Print "(&H" & Hex(flags) & " And &H" & Hex(i) & ") = &H" & Hex(flags And i)
Next i
Quote from: o.OV on December 31, 2003, 12:25 PM
sArray = Array("<test1>", "<test>", "<3test>", "<4test4>")
strng = "<test>"
What's with the angle brackets?
Quote from: Spht on December 31, 2003, 12:45 PM
Quote from: o.OV on December 31, 2003, 12:25 PM
sArray = Array("<test1>", "<test>", "<3test>", "<4test4>")
strng = "<test>"
What's with the angle brackets?
without it..
Private Sub Form_Load()
sArray = Array("test1", "test", "3test", "4test4")
strng = "test"
result = Filter(sArray, strng)
'Debug.Print result(0)
For x = LBound(result) To UBound(result)
Debug.Print result(x)
Next x
End Sub
it would return all 4 items in the array
Quote from: Spht on December 31, 2003, 12:43 PM
Quote from: o.OV on December 31, 2003, 11:05 AM
Ok. So maybe that wasn't you or maybe it was.
You got me.If (flags and &H20) = &H20 Then
To explain why, run this: Dim i As Long
Dim flags As Long
flags = &H20
Debug.Print "Checking &H" & Hex(flags) & " with flags 0 to 255 using If (flags And i) = i Then:"
For i = 1 To &HFF
If (flags And i) = i Then Debug.Print "(&H" & Hex(flags) & " And &H" & Hex(i) & ") = &H" & Hex(flags And i)
Next i
Debug.Print "Checking &H" & Hex(flags) & " with flags 0 to 255 using If (flags And i) Then:"
For i = 1 To &HFF
If (flags And i) Then Debug.Print "(&H" & Hex(flags) & " And &H" & Hex(i) & ") = &H" & Hex(flags And i)
Next i
Cool. I'll try that out right now Spht. =)
_____
I just tried it out and the results were quite long ^^
but it definitely showed the unwanted results =)
thx spht
Quote from: o.OV on December 31, 2003, 12:50 PM
Quote from: Spht on December 31, 2003, 12:43 PM
Quote from: o.OV on December 31, 2003, 11:05 AM
Ok. So maybe that wasn't you or maybe it was.
You got me.If (flags and &H20) = &H20 Then
To explain why, run this: Dim i As Long
Dim flags As Long
flags = &H20
Debug.Print "Checking &H" & Hex(flags) & " with flags 0 to 255 using If (flags And i) = i Then:"
For i = 1 To &HFF
If (flags And i) = i Then Debug.Print "(&H" & Hex(flags) & " And &H" & Hex(i) & ") = &H" & Hex(flags And i)
Next i
Debug.Print "Checking &H" & Hex(flags) & " with flags 0 to 255 using If (flags And i) Then:"
For i = 1 To &HFF
If (flags And i) Then Debug.Print "(&H" & Hex(flags) & " And &H" & Hex(i) & ") = &H" & Hex(flags And i)
Next i
Cool. I'll try that out right now Spht. =)
_____
I just tried it out and the results were quite long ^^
but it definitely showed the unwanted results =)
thx spht
I took another look at it..
flags = &H20
If (flags And &H30) = &H30 or (flags And &H20) = &H20 Then
or
flags = 32
If flags = 48 or flags = 32 Then
or
flags = &H20
If flags = &H30 or flags = &H20 Then
is code execution faster with the first one?
does it make any difference or should i use the first example so the code would look proper
am i going at this the wrong way?
if i use
flags = &H20
If (flags And &H20) Then
i may get TWO unwanted results:
&H22
&H32
and there are other flags i dont rememeber
such as bnet rep and flags for special icons
and yes. i see why using &H would be a better idea
flags make more sense
Quote from: o.OV on December 31, 2003, 12:25 PM
Quote from: Kp on December 30, 2003, 11:01 PM
Quote from: o.OV on December 30, 2003, 10:07 PM
now what other improvements can be done for the code i provided?
Well, I'd suggest storing your safelist and banlist in a true list of some sort rather than as a massive string with illegal characters to delimit entries. As I recall, VB's support for such things tends to be rather poor though, so you may have some difficulty making it work. I'll leave it to the VB gurus to explain how to implement the list (it'd be trivial in C, not so in VB afaik).
I don't expect a response from you since u said you will let the VB gurus explain how to implement the list.
But I took a look at the filter function and this is the best I can come up with.
Private Sub Form_Load()
sArray = Array("<test1>", "<test>", "<3test>", "<4test4>")
strng = "<test>"
result = Filter(sArray, strng)
Debug.Print result(0)
'For x = LBound(result) To UBound(result)
' Debug.Print result(x)
'Next x
End Sub
I wish to avoid any type of VB loop.
To remove a String Item .. I use Replace
-current
To remove a GUI Listbox Item .. I use RemoveItem
-I hate using Form based items
Now how do I remove an array item without using a loop?
You can't? :-\
Quote from: o.OV on December 31, 2003, 02:42 PMNow how do I remove an array item without using a loop?
It is possible, but requires you to first learn how arrays are stored in memory. Then you can write a utility function to remove a specific item by copying the [n+1] elements memory down to [n]'s address, then adjusting the array's header so it knows the new number of elements.
TheMinistered may have already researched this, you should ask him.
P.S. This appears to be more about Visual Basic than BnetBot Development. Do you have any BnetBot Development questions?
Quote from: Grok on January 02, 2004, 10:43 AM
Quote from: o.OV on December 31, 2003, 02:42 PMNow how do I remove an array item without using a loop?
It is possible, but requires you to first learn how arrays are stored in memory. Then you can write a utility function to remove a specific item by copying the [n+1] elements memory down to [n]'s address, then adjusting the array's header so it knows the new number of elements.
TheMinistered may have already researched this, you should ask him.
P.S. This appears to be more about Visual Basic than BnetBot Development. Do you have any BnetBot Development questions?
Here is a link I found on the subject:
http://www.developerfusion.com/show/3367/2/
I'm tinkering with it now..
If you can redirect me to a better resource page, please do. =) thx
________
The example they give still uses a loop..