• Welcome to Valhalla Legends Archive.
 

Phrasing Chat String reference?

Started by Tontow, May 14, 2005, 03:17 PM

Previous topic - Next topic

Tontow

Dose anyone know of a chat string phrasing reference? (ie: what the numbers mean in "1002 JOIN mamanex6 0000 [D2XP]" )
I'd rather use a reference then copy someone else code.

Eric

#1
The first numbers are the event ID's:
http://bnetdocs.valhallalegends.com/content.php?Section=m&Code=35

0x01 = 1001
0x02 = 1002
etc.

The last numbers are the flags.

The three strings (event, username and game ID) are pretty self-explanitory.

Tontow


Tontow

2010 NAME me]r[lin
1007 CHANNEL "Public Chat 1"

The numbers that start with a 1 are the event id's, but what about the ones that start with 2?

UserLoser.

Quote from: Tontow on May 15, 2005, 03:35 PM
2010 NAME me]r[lin
1007 CHANNEL "Public Chat 1"

The numbers that start with a 1 are the event id's, but what about the ones that start with 2?

All the first parameters are event ids, while second parameter is event name, and third is name.  Every message will have these three parameters

tA-Kane

Quote from: Tontow on May 15, 2005, 03:35 PMThe numbers that start with a 1 are the event id's, but what about the ones that start with 2?
To answer your question (more correctly than UserLoser did), anything that starts with '1' is an event ID. 2010 isn't an event ID, it's a packet ID. 1007 is packet 0x0F with event ID 0x07, while 2010 is packet 0x0A. The first number basically specifies what type of message is being received while the last three numbers are message type parameters, in decimal. So, 1023 is packet 0x0F with event ID 0x17.

Note that the flags (in "1001 USER someuser 0010 [CHAT]", the 0010 is the flags) are hexadeimal (if I remember correctly), and *CAN* exceed 4 bytes in length (eg, while I'm on chat, I've seen people with flags 100000 and such). So the best way to get the users flags is to use a non-length-specified parser, such as NthField(Message, " ", 4) (if you're using VB), and then use val("&h" & flagstr) on that. If the flags aren't hexadecimal, then I think that the flags may actually be octal (eg, 0-7 instead of 0-F). My memory is kinda iffy on that subject right now... :(
Macintosh programmer and enthusiast.
Battle.net Bot Programming: http://www.bash.org/?240059
I can write programs. Can you right them?

http://www.clan-mac.com
http://www.eve-online.com

Ban

And of course if its octal you can simply change that 'val("&h" & flagstr)' to 'val("&o" & flagstr)' :)

But of course it isn't ocatal, why would it be octal? You can fit so many more numbers in less space with hexadecimal (which is why we use it, instead of octal o_0)

tA-Kane

Quote from: Ban on May 18, 2005, 10:22 AMBut of course it isn't ocatal, why would it be octal? You can fit so many more numbers in less space with hexadecimal (which is why we use it, instead of octal o_0)
While you're at it, you can fit so many more numbers in less space with a long than a nibble.

As I said, I didn't remember very well. The reson I was thinking it may be octal is that I've never seen any specific digit be greater than 7, and couldn't be arsed to look up what flag was &h8 or higher, set that to myself, and see what I get on CHAT.
Macintosh programmer and enthusiast.
Battle.net Bot Programming: http://www.bash.org/?240059
I can write programs. Can you right them?

http://www.clan-mac.com
http://www.eve-online.com

Joe[x86]

#8
TAHCBot v2 Source Code (VisualBasic).
See my parsing code.

EDIT: Heres the TAHCBot v3 parser. It was never tested, but eh?
'---------------------------------------------------------------------------------------
' Module    : clsBnChatParse
' Author    : Joe[x86]
' Purpose   : Does the actual parsing for clsBnChatCore
'---------------------------------------------------------------------------------------

'// Our Events
'// Each of these will be "raised" when it occurs
'// These will be passed down to the BnChatCore, and then sent to the form.
Public Event LoggedOnAs(Username As String)
Public Event JoinedChannel(Channel As String)
Public Event UserInChannel(Username As String, Flags As Integer, Product As String)
Public Event Info(Message As String)
Public Event Error(Message As String)
Public Event UserTalks(Username As String, Message As String)
Public Event UserJoins(Username As String, Flags As Integer, Product As String)
Public Event UserLeaves(Username As String, Flags As Integer)
Public Event Out(sData As String)
Public Event sckConnecting()
Public Event sckConnected()
Public Event sckError()

'// Assembles a logon packet.
Public Function GetLogonPacket(sUsername As String, sPassword As String) As String
    '// 0x03
    '// 0x04
    '// Username
    '// 0x13 0x10 'ENTER
    '// Username
    '// 0x13 0x10 'ENTER
    GetLogonPacket = Chr(3) & Chr(4) & sUsername & vbCrLf & sPassword
End Function

'// This does all the actual parsing
Public Sub ParseBNET(sData As String)
    Select Case Split(sData, Space(1))(1)
        Case "from", "Password:", "NULL", "'anonymous'", "your"
            '// Bunch of BS bnet sends us. Lets ignore it, shall we?
            Exit Sub
        Case "NAME"
            RaiseEvent RetInfo("NAME", Splt(2))
        Case "CHANNEL"
            RaiseEvent RetInfo("CHAN", GetString(sData))
        Case "USER"
            RaiseEvent RetInfo("USER", Splt(2) & "|" & Val("&H" & Splt(3)) & "|" & Mid(Splt(3), 2, 4))
        Case "INFO"
            RaiseEvent RetInfo("INFO", GetString(sData))
        Case "ERROR"
            RaiseEvent RetInfo("EROR", GetString(sData))
        Case "TALK"
            RaiseEvent RetInfo("TALK", Splt(2) & "|" & GetString(sData))
        Case "JOIN"
            RaiseEvent RetInfo("JOIN", Splt(2) & "|" & Val("&H" & Splt(3)) & "|" & Mid(Splt(3), 2, 4))
        Case "LEAVE"
            RaiseEvent RetInfo("LEAV", Splt(2) & "|" & Val("&H" & Splt(3)))
        Case Else
            RaiseEvent RetInfo("UNHD", sData)
    End Select
End Sub

'// This will be used to get STRING[]'s from the data
Private Function GetString(s As String) As String
    GetString = Mid(s, InStr(1, s, Chr(34)) + 1, Len(s) - (InStr(1, s, Chr(34)) + 1))
End Function
Quote from: brew on April 25, 2007, 07:33 PM
that made me feel like a total idiot. this entire thing was useless.

Eric

Alphanumeric comparisons are much faster than string comparisons.

Hdx

Also.. that would messup any time someone used "s, You sould check from the end of the string for the 1st ".
Reverse the string then use Instr() is jsut an idea.
~-~(HDX)~-~

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

Kp

Quote from: LoRd[nK] on May 19, 2005, 11:39 PMAlphanumeric comparisons are much faster than string comparisons.
It'll also tend to produce the correct answer more reliably. :)  BNCS-chat designates both user-is-present and flags-update as "USER" in the output.  (One is 1001, the other 1009, so they're different numerically.)  Joe's code will incorrectly lump the two types into one, which will probably give strange results when a user's flags change.
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

Joe[x86]

I used to use numerical, but this was easier to do in my head when needbe.
Quote from: brew on April 25, 2007, 07:33 PM
that made me feel like a total idiot. this entire thing was useless.