package model import ( "git.lxtend.com/qqbot/constants" ) // 消息接口 // 上报的消息结构体 type SendPkg struct { Action string `json:"action"` Params UpstreamParams `json:"params"` } // 上游包的参数结构体 type UpstreamParams struct { UserID int64 `json:"user_id"` GroupID int64 `json:"group_id"` Message interface{} `json:"message"` AutoEscape bool `json:"auto_escape"` } func GenSendPkg(userID int64, groupID int64, message interface{}, autoEscape bool) SendPkg { if groupID == 0 { return SendPkg{ Action: constants.PRIVATE_MSG_SEND, Params: UpstreamParams{ UserID: userID, Message: message, AutoEscape: autoEscape, }, } } return SendPkg{ Action: constants.GROUP_MSG_SEND, Params: UpstreamParams{ UserID: userID, GroupID: groupID, Message: message, AutoEscape: autoEscape, }, } } // 事件的消息结构体 type EventMessage struct { Time int64 `json:"time"` SelfID int64 `json:"self_id"` PostType string `json:"post_type"` MessageType string `json:"message_type"` SubType string `json:"sub_type"` MessageID int32 `json:"message_id"` UserID int64 `json:"user_id"` // Message string `json:"message"` //just ignore it RawMessage string `json:"raw_message"` Font int32 `json:"font"` Sender Sender `json:"sender"` GroupID int64 `json:"group_id"` } type Sender struct { UserID int64 `json:"user_id"` Nickname string `json:"nickname"` Sex string `json:"sex"` Age int `json:"age"` Card string `json:"card"` Area string `json:"area"` Level string `json:"level"` Role string `json:"role"` Title string `json:"title"` GroupID int64 `json:"group_id"` } // { // "self_id": 12345, // "user_id": 23456, // "time": 23456, // "message_id": 23456, // "message_seq": 23456, // "real_id": 23456, // "message_type": "group", // "sender": { // "user_id": 23456, // "nickname": "23456", // "card": "", // "role": "owner" // }, // "raw_message": "test", // "font": 14, // "sub_type": "normal", // "message": [ // { // "type": "text", // "data": { // "text": "test" // } // } // ], // "message_format": "array", // "post_type": "message", // "group_id": 781332574 // }