Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IRC Bot, Anti-Flood 1

Status
Not open for further replies.

Falagar

Technical User
Jan 7, 2005
7
0
0
DK
Hey i am working on a IRC bot, i am not a hardcore program at all. And i am stuck right now, cause my IRC-bot floods and gets kicked from networks as it is now.

only way i can think of to stop this, is to time everthing i send from the bot to the server, and only have 1 user at the time.
This is a really crappy solution, so i were hoping that some one got a better one i might use.

i am wondering if i can make somekind of "On Send" thingy that controlls that not to much data is send and halt the program if there is.

Falagar

ps. Great forum! have helped me alot on other things :)
 
i Use Winsock to send and recive data from IRC server.
 
Use a timer. Send a string, wait a couple of seconds, and send some more.

Chip H.


____________________________________________________________________
Click here to learn Ways to help with Tsunami Relief
If you want to get the best response to a question, please read FAQ222-2244 first
 
So you need to avoid sending too many characters at once?

Maybe try some sort of "Queue" data structure together with a Timer control.

Imagine you want to send the words "Hello, how are you?" Except rather than just writing it directly to your Winsock, you put each CHARACTER of the string into an array.

Next your timer would be set to something like 300 milliseconds. Every time the Timer event fires you send one character from the array.

If you wanted to make it seem more realistic then, inside the Timer event, choose a random number from 0 to 3 and send that number of characters each time... so that it sort of stutters like real typing.

Another bit of faking you could do would be to choose a few letters that are frequently mistyped... perhaps they are close together on the keyboard like Y and U. Well you could have it type a U then send a BACKSPACE... then the Y.

Instead of using an array, where you would have to keep track of the current position and know when to wrap around to the front... you could just use a Collection object as your Queue. Something like this:

Code:
Private mcolSendQueue As New Collection
Private miWaitForChars As Integer

Private Sub Form_Load()
    Timer1.Interval = 300
End Sub

Sub SendString(ByVal strMsg As String)
  'Pass the string that you want to send to this subroutine
  
  Do While (Len(strMsg) > 0)
    mcolSendQueue.Add (Left(strMsg, 1))
    strMsg = Mid(strMsg, 2)
  Loop
End Sub

Private Sub Winsock1_SendComplete()
    'Clear wait flag
    miWaitForChars = 0
End Sub

Private Sub Timer1_Timer()
    Dim iMax As Integer
    Dim iCount As Integer
    Dim strToSend As String
    
    'Exit if previous Send operation not yet complete
    If (miWaitForChars > 0) Then Exit Sub
    
    'Choose a random number from 0 to 3
    iMax = Int(4 * Rnd)
    
    'Build the string to send.
    'if iMax is 0 then we won't enter for/next loop
    For iCount = 1 To iMax
        'exit loop if nothing in send queue
        If (mcolSendQueue.Count < 1) Then Exit For
        
        'take the next character in the queue
        strToSend = strToSend & mcolSendQueue(1)
        
        'remove character from the queue
        mcolSendQueue.Remove 1
    Next
    
    'Send data here
    If (Len(strToSend) > 0) Then Winsock1.SendData strToSend
        
    'Set wait flag
    miWaitForChars = Len(strToSend)
End Sub








 
No problem -- they're actually different solutions. Which one to use will likely depend on what the anti-bot code looks for (people typing at insanely fast speeds or people sending line after line with no delay between them).

Chip H.


____________________________________________________________________
Click here to learn Ways to help with Tsunami Relief
If you want to get the best response to a question, please read FAQ222-2244 first
 
Thx alot for the answers..

Ill try Sheco's solution.

Falagar
 
Ok i got it work on a hole other way.

if any later should be interrestet i can summon up here what i did.

i made a "dim bytessent integer" for keeping bytes send by my program. And then on every send i have alittle code that do "bytessent = bytessent + len(what i just sended string)"

and then i made a timer that counts down the bytessent integer over a time i specified. So that every time the timer is called it with draws 200 from the integer


and then on "sub Winsock1_SendComplete()"

useing a do-loop i check the amount of data send towards what i max want to be send. if the bytessend is to high then the program stalls until the bytessent (over time) has fallen below the set max.

Falagar

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top