• Welcome to Valhalla Legends Archive.
 

BNet Chat bot?

Started by Ozzapoo, November 05, 2008, 02:35 AM

Previous topic - Next topic

Ozzapoo

#45
Alright thanks, I'll try that.

EDIT: Where did Receive() come from?

EDIT: W00T! It works!!
May be crude, but works fine.
    Sub DetectIncoming()


        Dim bnetStream As NetworkStream = bnetClient.GetStream()
        Do
            Dim header(3) As Byte
            bnetStream.Read(header, 0, 4)
            If header(0) = 0 Then
                Continue Do
            End If
            Dim packetsize As Int16
            If header(0) = &HFF Then
                packetsize = BitConverter.ToInt16(header, 2)
            End If
            Dim packet(packetsize - 5) As Byte
            If packetsize > 4 Then
                bnetStream.Read(packet, 0, packetsize - 4)
            End If
            Dim rec() As Byte = ConcatenateByteArray(header, packet)
            header = Nothing
            packet = Nothing
            If rec(1) = &HF Then
                Dim packetreader As New BncsReader(rec)
                Dim eventid As Int32 = packetreader.ReadInt32()
                Dim userflags As Int32 = packetreader.ReadInt32()
                Dim ping As Int32 = packetreader.ReadInt32()
                packetreader.ReadInt32()
                packetreader.ReadInt32()
                packetreader.ReadInt32()
                Dim username As String = packetreader.ReadCString()
                Dim text As String = packetreader.ReadCString()
                Select Case eventid
                    Case &H2
                        Console.WriteLine("-INFO- User " + username + " has joined the channel.")
                    Case &H3
                        Console.WriteLine("-INFO- User " + username + " has left the channel.")
                    Case &H4
                        Console.WriteLine("<" + username + "> has whispered: " + text)
                    Case &H5
                        Console.WriteLine("<" + username + "> " + text)
                    Case &H6
                        Console.WriteLine("-BROADCAST- " + text)
                    Case &H7
                        Console.WriteLine("-JOINED CHANNEL- " + text)
                    Case &H9
                        Console.WriteLine("User Flags Update: " + text)
                    Case &HA
                        Console.WriteLine("-WHISPER SENT-")
                    Case &HD
                        Console.WriteLine("Error! Channel Full!")
                    Case &HE
                        Console.WriteLine("Error! Channel does not exist!")
                    Case &HF
                        Console.WriteLine("Error! Channel is restricted!")
                    Case &H12
                        Console.WriteLine("-INFORMATION- " + text)
                    Case &H13
                        Console.WriteLine("Error! " + text)
                    Case &H17
                        Console.WriteLine("-INFO- Emote Used by " + username)
                End Select
            ElseIf rec(1) = &H0 Then
                SendNull(bnetStream)
            End If
        Loop
    End Sub


And also, which packet returns all the people currently in the channel?

Hdx

EID_SHOWUSER
Crude, but works i guess, think about it a little more and you can clean it up.

Proud host of the JBLS server www.JBLS.org.
JBLS.org Status:
JBLS/BNLS Server Status

Ozzapoo

#47
Alright Thanks! But can you give me any ideas on how I can clean it up?

MyndFyre

Quote from: Ozzapoo on November 13, 2008, 11:20 PM
Alright thanks, I'll try that.

EDIT: Where did Receive() come from?
I commented about it:
                    // I wrote Receive().  It guarantees a buffer filled with as many bytes as you request and blocks until it comes in,
                    // or else returns null.


It's inherited from ConnectionBase (source).
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.

Ozzapoo

But does it really matter? Read() seems to work fine.

Hdx

IIRC Read will read data from the socket, but does not guarantee that it is of the length you specify.
For example, if in some fluke the BNCS header comes in two tcp segments, {\xff\x51 in the 1st and \x10\x00 in the second}
Your Read() function will read 2 bytes and then return. So you'd have a header value of: \xff\x51\x00\x00
But, this is just speaking of C, I don't know if VB.net's Read() is diffrent.

Proud host of the JBLS server www.JBLS.org.
JBLS.org Status:
JBLS/BNLS Server Status

MyndFyre

Quote from: Hdx on November 14, 2008, 03:33 PM
IIRC Read will read data from the socket, but does not guarantee that it is of the length you specify.
For example, if in some fluke the BNCS header comes in two tcp segments, {\xff\x51 in the 1st and \x10\x00 in the second}
Your Read() function will read 2 bytes and then return. So you'd have a header value of: \xff\x51\x00\x00
But, this is just speaking of C, I don't know if VB.net's Read() is diffrent.
Nope.  That's exactly how Socket.Read() works.  That's why it modifies a buffer you pass it as a parameter, and its return value is the number of bytes read.
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.

Ozzapoo

Uh..I've stumbled across a bit of an off-topic problem...

Is there any way I can modify the properties of a control on another thread (yes) from a piece of code on a different module (not sure)?

MyndFyre

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.

Ozzapoo

Alright. Thanks. I've pretty much got my bot set up now! :D

Ozzapoo

Just wondering, but how would I do an IP Ban, because the User IP thing is labeled DEFUNCT, so you can't exactly just grab someone's IP.

Barabajagal

Squelch is by IP. If you squelch an account, any other accounts that are squelched are on the same IP. Simply ban anyone who's squelched.

Ozzapoo

Wait, so if in Stealthbot, for example, you do /exile username

And it kicks, bans, and squelches 'username', does it just ban anyone who then attemps to join who is also squlched? If so, wouldn't it also ban other people who join your channel but are squelched? (Who are actually different people?)

l2k-Shadow

Quote from: Ozzapoo on November 17, 2008, 02:40 AM
Wait, so if in Stealthbot, for example, you do /exile username

And it kicks, bans, and squelches 'username', does it just ban anyone who then attemps to join who is also squlched? If so, wouldn't it also ban other people who join your channel but are squelched? (Who are actually different people?)

yes. however, why would the bot squelch unless it was for the purpose of IP ban?
Quote from: replaced on November 04, 2006, 11:54 AM
I dunno wat it means, someone tell me whats ix86 and pmac?
Can someone send me a working bot source (with bnls support) to my email?  Then help me copy and paste it to my bot? ;D
Já jsem byl určenej abych tady žil,
Dával si ovar, křen a k tomu pivo pil.
Tam by ses povídaj jak prase v žitě měl,
Já nechci před nikym sednout si na prdel.

Já nejsem z USA, já nejsem z USA, já vážně nejsem z USA... a snad se proto na mě nezloběj.

Barabajagal

That's why one doesn't typically chat via moderation bot...

|