refactor: 重构消息类型的初始化逻辑,新增各消息类型的构造函数以提高代码可读性和可维护性

This commit is contained in:
lixiangwuxian
2025-04-09 23:00:37 +08:00
parent 10eba59c63
commit 144034939c
16 changed files with 88 additions and 20 deletions

View File

@@ -21,10 +21,14 @@ type LocationMessageData struct {
func init() {
RegisterMessageType(TypeLocation, func() CQMessage {
return &LocationMessage{Type: TypeLocation}
return NewLocationMessage()
})
}
func NewLocationMessage() *LocationMessage {
return &LocationMessage{Type: TypeLocation}
}
func (msg *LocationMessage) SetData(data json.RawMessage) error {
return json.Unmarshal(data, &msg.Data)
}