Skip to content

Commit b8186b5

Browse files
committed
fix: chat and invite type fixes
1 parent dcccd48 commit b8186b5

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed

client.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"github.com/golang/protobuf/proto"
1212
devents "github.com/paralin/go-dota2/events"
1313
// gcmm "github.com/paralin/go-dota2/protocol/dota_gcmessages_common_match_management"
14+
bgcm "github.com/paralin/go-dota2/protocol/base_gcmessages"
1415
gcm "github.com/paralin/go-dota2/protocol/dota_gcmessages_msgid"
1516
gcsdkm "github.com/paralin/go-dota2/protocol/gcsdk_gcmessages"
1617
gcsm "github.com/paralin/go-dota2/protocol/gcsystemmsgs"
@@ -94,9 +95,18 @@ func (d *Dota2) buildHandlerMap() {
9495
// System events
9596
uint32(gcsm.EGCBaseClientMsg_k_EMsgGCPingRequest): d.handlePingRequest,
9697

98+
// Chat events
9799
uint32(gcm.EDOTAGCMsg_k_EMsgGCChatMessage): d.getEventEmitter(func() devents.Event {
98100
return &devents.ChatMessage{}
99101
}),
102+
uint32(gcm.EDOTAGCMsg_k_EMsgGCJoinChatChannelResponse): d.getEventEmitter(func() devents.Event {
103+
return &devents.JoinedChatChannel{}
104+
}),
105+
106+
// Invites
107+
uint32(bgcm.EGCBaseMsg_k_EMsgGCInvitationCreated): d.getEventEmitter(func() devents.Event {
108+
return &devents.InvitationCreated{}
109+
}),
100110
}
101111

102112
d.registerGeneratedHandlers()

events/chat.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,23 @@ func (e *ChatMessage) GetEventBody() proto.Message {
2525
func (e *ChatMessage) GetEventName() string {
2626
return "ChatMessage"
2727
}
28+
29+
// JoinedChatChannel is emitted when we join a chat channel.
30+
type JoinedChatChannel struct {
31+
gcmcc.CMsgDOTAJoinChatChannelResponse
32+
}
33+
34+
// GetDotaEventMsgID returns the dota message ID of the event.
35+
func (e *JoinedChatChannel) GetDotaEventMsgID() dota_gcmessages_msgid.EDOTAGCMsg {
36+
return dota_gcmessages_msgid.EDOTAGCMsg_k_EMsgGCJoinChatChannelResponse
37+
}
38+
39+
// GetEventBody returns the event body.
40+
func (e *JoinedChatChannel) GetEventBody() proto.Message {
41+
return &e.CMsgDOTAJoinChatChannelResponse
42+
}
43+
44+
// GetEventName returns the chat message event name.
45+
func (e *JoinedChatChannel) GetEventName() string {
46+
return "JoinedChatChannel"
47+
}

events/invite.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,27 @@
11
package events
22

33
import (
4+
"github.com/golang/protobuf/proto"
45
bgcm "github.com/paralin/go-dota2/protocol/base_gcmessages"
6+
"github.com/paralin/go-dota2/protocol/dota_gcmessages_msgid"
57
)
68

7-
// InvitationCreated is fired when the
9+
// InvitationCreated confirms that an invitation has been created.
810
type InvitationCreated struct {
911
bgcm.CMsgInvitationCreated
1012
}
13+
14+
// GetDotaEventMsgID returns the dota message ID of the event.
15+
func (e *InvitationCreated) GetDotaEventMsgID() dota_gcmessages_msgid.EDOTAGCMsg {
16+
return dota_gcmessages_msgid.EDOTAGCMsg(bgcm.EGCBaseMsg_k_EMsgGCInvitationCreated)
17+
}
18+
19+
// GetEventBody returns the event body.
20+
func (e *InvitationCreated) GetEventBody() proto.Message {
21+
return &e.CMsgInvitationCreated
22+
}
23+
24+
// GetEventName returns the event name.
25+
func (e *InvitationCreated) GetEventName() string {
26+
return "InvitationCreated"
27+
}

0 commit comments

Comments
 (0)