forked from magicshui/wechat-1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
event.go
66 lines (54 loc) · 1.85 KB
/
event.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// @description wechat 是腾讯微信公众平台 api 的 golang 语言封装
// @link https://github.com/chanxuehong/wechat for the canonical source repository
// @license https://github.com/chanxuehong/wechat/blob/master/LICENSE
// @authors chanxuehong(chanxuehong@gmail.com)
package session
import (
"github.com/chanxuehong/wechat/mp"
)
const (
EventTypeKfCreateSession = "kf_create_session" // 接入会话
EventTypeKfCloseSession = "kf_close_session" // 关闭会话
EventTypeKfSwitchSession = "kf_switch_session" // 转接会话
)
type KfCreateSessionEvent struct {
XMLName struct{} `xml:"xml" json:"-"`
mp.MessageHeader
Event string `xml:"Event" json:"Event"`
KfAccount string `xml:"KfAccount" json:"KfAccount"`
}
func GetKfCreateSessionEvent(msg *mp.MixedMessage) *KfCreateSessionEvent {
return &KfCreateSessionEvent{
MessageHeader: msg.MessageHeader,
Event: msg.Event,
KfAccount: msg.KfAccount,
}
}
type KfCloseSessionEvent struct {
XMLName struct{} `xml:"xml" json:"-"`
mp.MessageHeader
Event string `xml:"Event" json:"Event"`
KfAccount string `xml:"KfAccount" json:"KfAccount"`
}
func GetKfCloseSessionEvent(msg *mp.MixedMessage) *KfCloseSessionEvent {
return &KfCloseSessionEvent{
MessageHeader: msg.MessageHeader,
Event: msg.Event,
KfAccount: msg.KfAccount,
}
}
type KfSwitchSessionEvent struct {
XMLName struct{} `xml:"xml" json:"-"`
mp.MessageHeader
Event string `xml:"Event" json:"Event"`
FromKfAccount string `xml:"FromKfAccount" json:"FromKfAccount"`
ToKfAccount string `xml:"ToKfAccount" json:"ToKfAccount"`
}
func GetKfSwitchSessionEvent(msg *mp.MixedMessage) *KfSwitchSessionEvent {
return &KfSwitchSessionEvent{
MessageHeader: msg.MessageHeader,
Event: msg.Event,
FromKfAccount: msg.FromKfAccount,
ToKfAccount: msg.ToKfAccount,
}
}