refactor: 重构消息类型的初始化逻辑,新增各消息类型的构造函数以提高代码可读性和可维护性
This commit is contained in:
@@ -18,10 +18,14 @@ type LightappMessageData struct {
|
||||
|
||||
func init() {
|
||||
RegisterMessageType(TypeLightapp, func() CQMessage {
|
||||
return &LightappMessage{Type: TypeLightapp}
|
||||
return NewLightappMessage()
|
||||
})
|
||||
}
|
||||
|
||||
func NewLightappMessage() *LightappMessage {
|
||||
return &LightappMessage{Type: TypeLightapp}
|
||||
}
|
||||
|
||||
func (msg *LightappMessage) SetData(data json.RawMessage) error {
|
||||
return json.Unmarshal(data, &msg.Data)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user