fix: 修改多个处理函数的返回类型为指针类型,以提高内存使用效率并避免不必要的拷贝
This commit is contained in:
@@ -24,7 +24,7 @@ func init() {
|
||||
handler.RegisterPrivateHandler(headmasterHandler)
|
||||
}
|
||||
|
||||
func headmasterHandler(msg model.Message) (reply model.Reply) {
|
||||
func headmasterHandler(msg model.Message) (reply *model.Reply) {
|
||||
var from string
|
||||
if msg.GroupInfo.IsGroupMsg {
|
||||
from = util.From(msg.GroupInfo.GroupId, 0)
|
||||
@@ -32,13 +32,13 @@ func headmasterHandler(msg model.Message) (reply model.Reply) {
|
||||
from = util.From(0, msg.UserId)
|
||||
}
|
||||
if len(msg.RawMsg) > 7 && msg.RawMsg[0:7] == "校长 " {
|
||||
return model.Reply{
|
||||
return &model.Reply{
|
||||
ReplyMsg: ask(from, fmt.Sprintf("{\"qqid\":%d,\"group_nickname\":\"%s\",\"nickname\":\"%s\",\"referid\":%d,\"received_time\":%s,\"msg\":\"%s\"}", msg.UserId, msg.GroupInfo.UserCard, msg.UserNickName, msg.OriginMsgId, time.Now().Format("2006-01-02 15:04:05"), msg.RawMsg[7:])),
|
||||
ReferOriginMsg: false,
|
||||
FromMsg: msg,
|
||||
}
|
||||
}
|
||||
return model.Reply{
|
||||
return &model.Reply{
|
||||
ReplyMsg: ask(from, fmt.Sprintf("{\"qqid\":%d,\"group_nickname\":\"%s\",\"nickname\":\"%s\",\"referid\":%d,\"received_time\":%s,\"msg\":\"%s\"}", msg.UserId, msg.GroupInfo.UserCard, msg.UserNickName, msg.OriginMsgId, time.Now().Format("2006-01-02 15:04:05"), msg.RawMsg)),
|
||||
ReferOriginMsg: false,
|
||||
FromMsg: msg,
|
||||
|
||||
Reference in New Issue
Block a user