Valhalla Legends Forums Archive | Battle.net Bot Development | Phrasing Chat String reference?

AuthorMessageTime
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.
May 14, 2005, 8:17 PM
LoRd
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.
May 14, 2005, 8:46 PM
Tontow
thanks, that helps alot
May 14, 2005, 11:49 PM
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?
May 15, 2005, 8:35 PM
UserLoser.
[quote author=Tontow link=topic=11589.msg112574#msg112574 date=1116189342]
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?
[/quote]

All the first parameters are event ids, while second parameter is event name, and third is name.  Every message will have these three parameters
May 15, 2005, 9:13 PM
tA-Kane
[quote author=Tontow link=topic=11589.msg112574#msg112574 date=1116189342]The numbers that start with a 1 are the event id's, but what about the ones that start with 2?[/quote]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... :(
May 15, 2005, 9:31 PM
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)
May 18, 2005, 3:22 PM
tA-Kane
[quote author=Ban link=topic=11589.msg112870#msg112870 date=1116429761]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)[/quote]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.
May 19, 2005, 1:15 AM
JoeTheOdd
TAHCBot v2 Source Code (VisualBasic).
See my parsing code.

EDIT: Heres the TAHCBot v3 parser. It was never tested, but eh?
[code]'---------------------------------------------------------------------------------------
' 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[/code]
May 20, 2005, 1:04 AM
LoRd
Alphanumeric comparisons are much faster than string comparisons.
May 20, 2005, 4:39 AM
HdxBmx27
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)~-~
May 20, 2005, 4:45 AM
Kp
[quote author=LoRd[nK] link=topic=11589.msg113090#msg113090 date=1116563975]Alphanumeric comparisons are much faster than string comparisons.[/quote]
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.
May 20, 2005, 5:00 AM
JoeTheOdd
I used to use numerical, but this was easier to do in my head when needbe.
May 21, 2005, 12:37 AM

Search