init: 初始化仓库
This commit is contained in:
145
model/gocq_message.go
Normal file
145
model/gocq_message.go
Normal file
@@ -0,0 +1,145 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"git.lxtend.com/qqbot/constants"
|
||||
)
|
||||
|
||||
// 消息接口
|
||||
|
||||
// @某个QQ用户的结构体
|
||||
type AtMessage struct {
|
||||
Type string `json:"type"`
|
||||
Data AtData `json:"data"`
|
||||
}
|
||||
|
||||
// @消息数据结构体
|
||||
type AtData struct {
|
||||
QQ string `json:"qq"`
|
||||
}
|
||||
|
||||
// 回复消息结构体
|
||||
type ReplyMessage struct {
|
||||
Type string `json:"type"`
|
||||
Data ReplyData `json:"data"`
|
||||
}
|
||||
|
||||
// 回复消息数据结构体
|
||||
type ReplyData struct {
|
||||
ID string `json:"id"`
|
||||
}
|
||||
|
||||
func GenReplyMsg(msgID int64) ReplyMessage {
|
||||
return ReplyMessage{
|
||||
Type: "reply",
|
||||
Data: ReplyData{
|
||||
ID: fmt.Sprint(msgID),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func GenAtMsg(qqId string) AtMessage {
|
||||
return AtMessage{
|
||||
Type: "at",
|
||||
Data: AtData{
|
||||
QQ: qqId,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// 上报的消息结构体
|
||||
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 string `json:"message"`
|
||||
AutoEscape bool `json:"auto_escape"`
|
||||
}
|
||||
|
||||
func GenSendPkg(userID int64, groupID int64, message string, 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
|
||||
// }
|
||||
21
model/message.go
Normal file
21
model/message.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package model
|
||||
|
||||
type Message struct {
|
||||
UserId int64 `json:"userId"`
|
||||
GroupInfo GroupInfo `json:"groupInfo"`
|
||||
OriginMsgId int32 `json:"originMsgId"`
|
||||
Msg string `json:"msg"`
|
||||
UserNickName string `json:"userNickName"`
|
||||
}
|
||||
|
||||
type GroupInfo struct {
|
||||
IsGroupMsg bool `json:"isGroupMsg"`
|
||||
GroupId int64 `json:"groupId"`
|
||||
UserCard string `json:"userCard"`
|
||||
}
|
||||
|
||||
type Reply struct {
|
||||
ReplyMsg string `json:"replyMsg"`
|
||||
ReferOriginMsg bool `json:"referOriginMsg"`
|
||||
FromMsg Message `json:"fromMsg"`
|
||||
}
|
||||
Reference in New Issue
Block a user