refactor: 重构消息类型的初始化逻辑,新增各消息类型的构造函数以提高代码可读性和可维护性
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user