parse channel
This commit is contained in:
parent
ce73e3b561
commit
c0d9ac7420
|
@ -52,6 +52,7 @@ type CustomerMessage struct {
|
|||
Image *CustomerImage
|
||||
Video *CustomerVideo
|
||||
Voice *CustomerVoice
|
||||
Channels *CustomerChannels
|
||||
}
|
||||
|
||||
type CustomerServicer struct {
|
||||
|
@ -69,6 +70,12 @@ type CustomerText struct {
|
|||
MenuId string
|
||||
}
|
||||
|
||||
type CustomerChannels struct {
|
||||
Nickname string
|
||||
Title string
|
||||
SubType int
|
||||
}
|
||||
|
||||
type CustomerImage struct {
|
||||
MediaId string
|
||||
}
|
||||
|
@ -323,8 +330,23 @@ func (m *CustomerMessage) From(data map[string]interface{}) {
|
|||
m.parseText(data)
|
||||
} else if m.Msgtype == message.MsgTypeImage || m.Msgtype == message.MsgTypeVideo || m.Msgtype == message.MsgTypeVoice {
|
||||
m.parseMedia(m.Msgtype, data)
|
||||
} else if m.Msgtype == message.MsgTypeChannels {
|
||||
m.parseChannels(data)
|
||||
}
|
||||
}
|
||||
func (m *CustomerMessage) parseChannels(data map[string]interface{}) error {
|
||||
channels, err := cast.ToStringMapE(data["channels"])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
m.Channels = &CustomerChannels{
|
||||
Title: cast.ToString(channels["title"]),
|
||||
Nickname: cast.ToString(channels["nickname"]),
|
||||
SubType: cast.ToInt(channels["sub_type"]),
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *CustomerMessage) parseEvent(data map[string]interface{}) error {
|
||||
event, err := cast.ToStringMapE(data["event"])
|
||||
|
|
|
@ -35,7 +35,8 @@ const (
|
|||
//MsgTypeTransfer 表示消息消息转发到客服
|
||||
MsgTypeTransfer = "transfer_customer_service"
|
||||
//MsgTypeEvent 表示事件推送消息
|
||||
MsgTypeEvent = "event"
|
||||
MsgTypeEvent = "event"
|
||||
MsgTypeChannels = "channels"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
Loading…
Reference in New Issue