Valhalla Legends Archive

Programming => Battle.net Bot Development => Topic started by: The-FooL on June 07, 2004, 04:16 PM

Title: Accepting Invites
Post by: The-FooL on June 07, 2004, 04:16 PM
I am working on getting my bot to accept invites into a WC3 Clan.  It can already send invites, but when accepting I get kicked off battle.net.

Case &H79 'CLAN INVITE
       Dim accp As Boolean, token As Long
       token = Asc(Mid(data, 2, 4))
       cookie = Asc(Mid(data, 5, 4))
       clantag = StrReverse(Mid$(data, 9, 4))
       clanname = KillNull(Mid$(data, 13))
       pos = 14 + Len(clanname)
       creator = KillNull(Mid$(data, pos))
       frmMain.AddChat ">>[Clan] You have been invited to join Clan: " & clanname & "[", vbYellow, True
       ..............
        With tcp
       If accp Then 'send invite response
           .InsertDWORD token
           .InsertDWORD cookie
           .InsertDWORD Asc(StrReverse(clantag))
           .InsertNTString creator
           .InsertBYTE &H6
           .sendPacket &H79
           frmMain.AddChat ">>[Clan] You have accepted the Invitation", vbGreen
       Else
           .InsertDWORD token
           .InsertDWORD cookie
           .InsertDWORD Asc(StrReverse(clantag))
           .InsertNTString creator
           .InsertBYTE &H6
           .sendPacket &H79
           frmMain.AddChat ">>[Clan] You have declined the Invitation", vbRed
       End If
       End With


Where I have the .... I ask the user if they want to accept the invite, and I have the accp value hold a True/False.  Everything is parsed fine as far as the Server>Client side, the tag, clan name, and person inviting are all being displayed correctly.  But I am disconnected upon sending the reply packet.  Ive looked on BNET Docs.  First of all, on the S>C message it does not show that there are actually 2 DWORDS before the Clan Tag.  And I have tried sending the response both with the token value and without, both times I am disconnected.  Anyone see what I am doing wrong?
Title: Re:Accepting Invites
Post by: Stealth on June 07, 2004, 07:46 PM
.InsertDWORD Asc(StrReverse(clantag))

I'm pretty sure taking Asc() of more than one character at a time is not a good idea.
Title: Re:Accepting Invites
Post by: The-FooL on June 07, 2004, 09:18 PM
Yeah, thats not the prob, I already fixed that lol.
Title: Re:Accepting Invites
Post by: BaDDBLooD on June 07, 2004, 09:39 PM
Could you post The Packet Format? Send / Recieve ( Or What you know so far )

EDIT: Also Packetlog?
Title: Re:Accepting Invites
Post by: Stealth on June 07, 2004, 09:54 PM
Judging only from the code you posted, you appear to be sending exactly the same packet both times.

Wouldn't it have to be different to decline the invitation? Perhaps change that BYTE?
Title: Re:Accepting Invites
Post by: LordNevar on June 07, 2004, 10:01 PM
Stealth is correct, in order to decline you should be using the byte &H4, not &H6.
Title: Re:Accepting Invites
Post by: BaDDBLooD on June 07, 2004, 10:44 PM
i Noticed that.. but i just figured he had the same thing Twice because he just Copied it ( he hadn't done Decline yet )
Title: Re:Accepting Invites
Post by: The-FooL on June 08, 2004, 02:43 PM
Yeah, there are a buncha mistakes there.  I'm just gonna get unlazy and packet log my wc client.  I'll post the corrected code when I'm done.

[Edit]
In case anyone else has problems:

strCookie = Mid$(data, 5, 4)
       clantag = StrReverse(Mid$(data, 9, 4))
       cl = Mid(data, 9, 4) 'unmodified clan tag
       clanname = KillNull(Mid$(data, 13))
       pos = 14 + Len(clanname)
       creator = KillNull(Mid$(data, pos))

..............
If accp Then 'send invite response
           .InsertNonNTString strCookie
           .InsertNonNTString cl
           .InsertNTString creator
           .InsertBYTE &H6
           .sendPacket &H79
           frmMain.AddChat ">>[Clan] You have accepted the Invitation", vbGreen
       Else
       Dim toasend As Long
           .InsertNonNTString strCookie
           .InsertNonNTString cl
           .InsertNTString creator
           .InsertBYTE &H4
           .sendPacket &H79
           frmMain.AddChat ">>[Clan] You have declined the Invitation", vbRed
       End If
       End With


And packet logs of the wc client declining.  Note that the username of the inviter(our channel's bot) has the same name as the clan's name(don't get confused).


S>C
0000016E  ff 79 26 00 11 0e 06 00  x78 42 54 78 54 68 65 2d .y&..... xBTxThe-
0000017E  42 72 65 74 68 72 65 6e  00 54 68 65 2d 42 72 65 Brethren .The-Bre
0000018E  74 68 72 65 6e 00                                thren.

C>S
0000005A  ff 79 1a 00 11 0e 06 00  x78 B42 T54 x78 54 68 65 2d .y...... xBTxThe-
0000006A  42 72 65 74 68 72 65 6e  00 04                   Brethren ..