• Welcome to Valhalla Legends Archive.
 

Adding Chat Options

Started by haZe, January 13, 2003, 02:43 PM

Previous topic - Next topic

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).

SiMi

#1
grrr , i dont get it

haZe

#2
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!

RhiNo

#3
Well first off you could start by parsing the data then from there its pretty easy

Grok

#4
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.

haZe

#5
KThx Grok. That would be a big help, yeah. good thing today is a half day in school. Thx Grok..

haZe

#6
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.
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
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
addText "" & Username & " has joined the channel with " & ping & "ms ping.", vbGrayText
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.

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:

   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

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:

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

If your AddText does not support ParamArray, go to botdev documents or vl.com, or elsewhere on this forum to get it.

Zorm

#8
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?
"Now, gentlemen, let us do something today which the world make talk of hereafter."
- Admiral Lord Collingwood

Grok

#9
No, Select Case can be compared to

If Cond1 then
else if Cond2 then
else if Cond3 then
else if Cond4 then
else
endif

haZe

#10
no..thats not ur code...

Zorm

#11
ah k, *removes exit subs*
"Now, gentlemen, let us do something today which the world make talk of hereafter."
- Admiral Lord Collingwood