Valhalla Legends Forums Archive | Battle.net Bot Development | Adding Chat Options

AuthorMessageTime
haZe
I need to add chat options (Talking and Receiving chat) to my bot. I'm not quite sure how to, though. Everytime I add them, nothing happens. (I don't send/receive chat).
January 13, 2003, 8:43 PM
SiMi
grrr , i dont get it
January 13, 2003, 8:50 PM
haZe
HOW DO I ADD CHAT OPTIONS TO MY BOT? When I say 'chat options', I mean Sending messages to other people and receiving messages! My bot connects and joins priv channels, now all it needs to do is that!
January 13, 2003, 9:02 PM
RhiNo
Well first off you could start by parsing the data then from there its pretty easy
January 13, 2003, 10:24 PM
Grok
Haze,  I'll help.  You may not think this is helping, but it is, and if you do this, you'll appreciate it later.

Hopefully you're starting by writing a text-protocol bot(that which the community calls chat) rather than a record-protocol bot(that which we call binary).  If you're starting out with a binary bot, stop reading now.  Stop programming now too.  You're not ready for that.

First I want you to understand what you're doing by writing a bot.  The whole purpose of your bot is to connect to battle.net, log on, receive battle.net text, display it to your user, allow the user to enter text, and send that text to battle.net.  Everything else are extras.

*  Open a telnet session to a battle.net chat server on port 6112.
*  Log on with your battle.net username and password.
*  Look at and study the format of each line being sent to you.
*  Document on paper the different types of information, and the structure of each.

This is very good practice for someday moving up to binary.  All of the early bot writers had to do this same process.  That is how we acquired our knowledge, by direct examination of the actual data!

*  Try all the chat abilities...
--- talk
--- emote
--- join
--- kick
--- ban
--- friends lists
--- help
--- etc..

Look at the replies to each.  Document how each command response is formatted.  This documentation will be part of your bot program specification.
January 14, 2003, 6:33 AM
haZe
KThx Grok. That would be a big help, yeah. good thing today is a half day in school. Thx Grok..
January 14, 2003, 7:16 AM
haZe
OK. I got my bot to receive chat and respond to all the other events. Heres the code I use now to raise the events.
[code]
Case ID_TALK
RaiseEvent OnTalk(Username, Flags, Message, Ping)
Exit Sub
Case ID_EMOTE
RaiseEvent OnEmote(Username, Flags, Message)
Exit Sub
Case ID_CHAN
RaiseEvent OnChannel(Message, Flags)
Exit Sub
Case ID_USER
RaiseEvent OnUser(Username, Flags, Message, Ping)
Exit Sub
Case ID_JOIN
RaiseEvent OnJoin(Username, Flags, Message, Ping)
Exit Sub
Case ID_LEAVE
RaiseEvent OnLeave(Username, Flags)
Exit Sub
Case ID_WHISPTO
RaiseEvent OnWhisperTo(Username, Flags, Message, Ping)
Exit Sub
Case ID_WHISPFROM
RaiseEvent OnWhisperFrom(Username, Flags, Message)
Exit Sub
Case ID_INFO
RaiseEvent OnInfo(Message)
Exit Sub
Case ID_FLAGS
RaiseEvent OnFlags(Username, Flags, Message, Ping)
Exit Sub
Case ID_BROADCAST
RaiseEvent OnInfo(Message)
Exit Sub
Case ID_ERROR
RaiseEvent OnError(Message)
Exit Sub
Case Else
RaiseEvent OnUnknown(Message)
Exit Sub
[/code]
My event coding is very simple though. All it does is addtext of the event that occured.
Also, How can I made for instance this
[code]
addText "" & Username & " has joined the channel with " & ping & "ms ping.", vbGrayText
[/code]
appear in a dif color? for instance, I want the username to appear in vbgraytext and the ping to display in vbGreen. Everything i've tried says type mismatch.
January 14, 2003, 2:10 PM
Grok
first of all, what the heck are all those Exit Subs doing in your Select Case?  Because you Exit Sub after every Case, it is sufficient to have one Exit Sub after your End Select:

[code]
   Select Case CmdID
   Case ID_TALK
       RaiseEvent OnTalk(Username, Flags, Message, Ping)
   Case ID_EMOTE
       RaiseEvent OnEmote(Username, Flags, Message)
   Case ID_CHAN
       RaiseEvent OnChannel(Message, Flags)
   Case ID_USER
       RaiseEvent OnUser(Username, Flags, Message, Ping)
   Case ID_JOIN
       RaiseEvent OnJoin(Username, Flags, Message, Ping)
   Case ID_LEAVE
       RaiseEvent OnLeave(Username, Flags)
   Case ID_WHISPTO
       RaiseEvent OnWhisperTo(Username, Flags, Message, Ping)
   Case ID_WHISPFROM
       RaiseEvent OnWhisperFrom(Username, Flags, Message)
   Case ID_INFO
       RaiseEvent OnInfo(Message)
   Case ID_FLAGS
       RaiseEvent OnFlags(Username, Flags, Message, Ping)
   Case ID_BROADCAST
       RaiseEvent OnInfo(Message)
   Case ID_ERROR
       RaiseEvent OnError(Message)
   Case Else
       RaiseEvent OnUnknown(Message)
   End Select
   Exit Sub
[/code]

Now to your question.  It depends on what your AddText function looks like.  If you're using the same one most of us are, that uses a ParamArray, you can do something like this:

[code]
AddText( "" & Username & " has joined the channel with ", vbGrayText, ping & "ms ping.", vbGreen
[/code]

If your AddText does not support ParamArray, go to botdev documents or vl.com, or elsewhere on this forum to get it.
January 14, 2003, 3:00 PM
zorm
hes pasting my code, thats while all the exit subs are there heh. and doesn't vb keep checking the other cases even after it finds a match?
January 14, 2003, 4:45 PM
Grok
No, Select Case can be compared to

If Cond1 then
else if Cond2 then
else if Cond3 then
else if Cond4 then
else
endif
January 14, 2003, 4:50 PM
haZe
no..thats not ur code...
January 14, 2003, 4:54 PM
zorm
ah k, *removes exit subs*
January 14, 2003, 4:54 PM

Search