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