Skip to content

Commit 257fe76

Browse files
authored
feat(message): support refer msg (#171)
* feat(message): support refer msg * fix&comment
1 parent 0d6c5b3 commit 257fe76

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

wechaty-puppet/puppet.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ package wechatypuppet
33
import (
44
"errors"
55
"fmt"
6+
67
lru "github.com/hashicorp/golang-lru"
8+
79
"github.com/wechaty/go-wechaty/wechaty-puppet/events"
810
"github.com/wechaty/go-wechaty/wechaty-puppet/filebox"
911
"github.com/wechaty/go-wechaty/wechaty-puppet/helper"

wechaty-puppet/schemas/message.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,19 @@ type MessagePayloadBase struct {
9393

9494
// 小程序有些消息类型,wechaty服务端解析不处理,框架端解析。 xml type 36 是小程序
9595
FixMiniApp bool
96+
97+
ReferMessage *ReferMessagePayload
98+
}
99+
100+
// ReferMessagePayload refer message payload
101+
type ReferMessagePayload struct {
102+
Type MessageType // TODO: 确认是否和 MessageType 一致
103+
SourceMsgID string
104+
TalkerId string
105+
RoomId string
106+
DisplayName string
107+
Content string
108+
Timestamp time.Time
96109
}
97110

98111
type MessagePayloadRoom struct {

wechaty/user/message.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,16 @@ func (m *Message) Date() time.Time {
147147
return m.payload.Timestamp
148148
}
149149

150+
// ReferMessage get the refer message
151+
func (m *Message) ReferMessage() *schemas.ReferMessagePayload {
152+
if m.payload.ReferMessage == nil {
153+
return nil
154+
}
155+
156+
copy := *m.payload.ReferMessage
157+
return &copy
158+
}
159+
150160
// Say reply a Text or Media File message to the sender.
151161
// Support msg:
152162
// string

0 commit comments

Comments
 (0)