优化对象的字段的排列

This commit is contained in:
eatMoreApple 2021-04-27 11:12:46 +08:00
parent 7ddcde9ab6
commit d84fbe1681
3 changed files with 302 additions and 303 deletions

6
bot.go
View File

@ -6,15 +6,15 @@ import (
) )
type Bot struct { type Bot struct {
Caller *Caller
self *Self
storage *Storage
ScanCallBack func(body []byte) ScanCallBack func(body []byte)
LoginCallBack func(body []byte) LoginCallBack func(body []byte)
UUIDCallback func(uuid string) UUIDCallback func(uuid string)
MessageHandler func(msg *Message) MessageHandler func(msg *Message)
err error err error
exit chan bool exit chan bool
Caller *Caller
self *Self
storage *Storage
} }
// 判断当前用户是否正常在线 // 判断当前用户是否正常在线

View File

@ -9,12 +9,12 @@ import "fmt"
// 登录信息 // 登录信息
type LoginInfo struct { type LoginInfo struct {
Ret int `xml:"ret"` Ret int `xml:"ret"`
WxUin int `xml:"wxuin"`
IsGrayScale int `xml:"isgrayscale"`
Message string `xml:"message"` Message string `xml:"message"`
SKey string `xml:"skey"` SKey string `xml:"skey"`
WxSid string `xml:"wxsid"` WxSid string `xml:"wxsid"`
WxUin int `xml:"wxuin"`
PassTicket string `xml:"pass_ticket"` PassTicket string `xml:"pass_ticket"`
IsGrayScale int `xml:"isgrayscale"`
} }
// 初始的请求信息 // 初始的请求信息
@ -26,8 +26,8 @@ type BaseRequest struct {
// 大部分返回对象都携带该信息 // 大部分返回对象都携带该信息
type BaseResponse struct { type BaseResponse struct {
ErrMsg string
Ret int Ret int
ErrMsg string
} }
func (b BaseResponse) Ok() bool { func (b BaseResponse) Ok() bool {
@ -64,28 +64,28 @@ type SyncKey struct {
// 初始化的相应信息 // 初始化的相应信息
type WebInitResponse struct { type WebInitResponse struct {
BaseResponse BaseResponse
Count int Count int
ChatSet string
SKey string
SyncKey SyncKey
User User
ClientVersion int ClientVersion int
SystemTime int64
GrayScale int GrayScale int
InviteStartCount int InviteStartCount int
MPSubscribeMsgCount int MPSubscribeMsgCount int
MPSubscribeMsgList []MPSubscribeMsg
ClickReportInterval int ClickReportInterval int
SystemTime int64
ChatSet string
SKey string
BaseResponse BaseResponse
SyncKey SyncKey
User User
MPSubscribeMsgList []MPSubscribeMsg
ContactList []User ContactList []User
} }
// 公众号的订阅信息 // 公众号的订阅信息
type MPSubscribeMsg struct { type MPSubscribeMsg struct {
UserName string
Time int64
NickName string
MPArticleCount int MPArticleCount int
Time int64
UserName string
NickName string
MPArticleList []struct { MPArticleList []struct {
Title string Title string
Cover string Cover string
@ -149,29 +149,29 @@ func (s *SyncCheckResponse) Error() string {
type WebWxSyncResponse struct { type WebWxSyncResponse struct {
AddMsgCount int AddMsgCount int
AddMsgList []*Message
BaseResponse BaseResponse
ContinueFlag int ContinueFlag int
DelContactCount int DelContactCount int
ModChatRoomMemberCount int ModChatRoomMemberCount int
ModChatRoomMemberList Members
ModContactCount int ModContactCount int
Skey string Skey string
SyncCheckKey SyncKey SyncCheckKey SyncKey
SyncKey SyncKey SyncKey SyncKey
BaseResponse BaseResponse
ModChatRoomMemberList Members
AddMsgList []*Message
} }
type WebWxContactResponse struct { type WebWxContactResponse struct {
BaseResponse BaseResponse
MemberCount int MemberCount int
MemberList []*User
Seq int Seq int
BaseResponse BaseResponse
MemberList []*User
} }
type WebWxBatchContactResponse struct { type WebWxBatchContactResponse struct {
Count int
BaseResponse BaseResponse BaseResponse BaseResponse
ContactList []*User ContactList []*User
Count int
} }
type CheckLoginResponse struct { type CheckLoginResponse struct {

View File

@ -13,44 +13,43 @@ import (
) )
type Message struct { type Message struct {
IsAt bool
AppInfo struct { AppInfo struct {
AppID string
Type int Type int
AppID string
} }
AppMsgType int AppMsgType int
Content string
CreateTime int64
EncryFileName string
FileName string
FileSize string
ForwardFlag int
FromUserName string
HasProductId int HasProductId int
ImgHeight int ImgHeight int
ImgStatus int ImgStatus int
ImgWidth int ImgWidth int
MediaId string ForwardFlag int
MsgId string
MsgType int MsgType int
NewMsgId int64
OriContent string
PlayLength int64
RecommendInfo RecommendInfo
Status int Status int
StatusNotifyCode int StatusNotifyCode int
StatusNotifyUserName string
SubMsgType int SubMsgType int
VoiceLength int
CreateTime int64
NewMsgId int64
PlayLength int64
MediaId string
MsgId string
EncryFileName string
FileName string
FileSize string
Content string
FromUserName string
OriContent string
StatusNotifyUserName string
Ticket string Ticket string
ToUserName string ToUserName string
Url string Url string
VoiceLength int
IsAt bool
Bot *Bot
senderInGroupUserName string senderInGroupUserName string
RecommendInfo RecommendInfo
Bot *Bot
mu sync.RWMutex mu sync.RWMutex
item map[string]interface{}
Context context.Context Context context.Context
item map[string]interface{}
} }
// 获取消息的发送者 // 获取消息的发送者