fix: 修改多个处理函数的返回类型为指针类型,以提高内存使用效率并避免不必要的拷贝
This commit is contained in:
@@ -32,81 +32,81 @@ func init() {
|
||||
handler.RegisterHelpInform("/shutdown", "热更新", "结束程序")
|
||||
}
|
||||
|
||||
func restart(msg model.Message) model.Reply {
|
||||
func restart(msg model.Message) *model.Reply {
|
||||
if !hasVaildBuild {
|
||||
return model.Reply{
|
||||
return &model.Reply{
|
||||
ReplyMsg: "上次构建失败,请先成功构建再部署",
|
||||
ReferOriginMsg: true,
|
||||
FromMsg: msg,
|
||||
}
|
||||
}
|
||||
go restartProgram()
|
||||
return model.Reply{
|
||||
return &model.Reply{
|
||||
ReplyMsg: "重启中...",
|
||||
ReferOriginMsg: true,
|
||||
FromMsg: msg,
|
||||
}
|
||||
}
|
||||
|
||||
func shutdown(msg model.Message) model.Reply {
|
||||
func shutdown(msg model.Message) *model.Reply {
|
||||
go shutdownProgram()
|
||||
return model.Reply{
|
||||
return &model.Reply{
|
||||
ReplyMsg: "关闭中...",
|
||||
ReferOriginMsg: true,
|
||||
FromMsg: msg,
|
||||
}
|
||||
}
|
||||
|
||||
func build(msg model.Message) model.Reply {
|
||||
func build(msg model.Message) *model.Reply {
|
||||
err := buildBot()
|
||||
if err != nil {
|
||||
return model.Reply{
|
||||
return &model.Reply{
|
||||
ReplyMsg: "构建失败,报错如下\n" + err.Error(),
|
||||
ReferOriginMsg: true,
|
||||
FromMsg: msg,
|
||||
}
|
||||
}
|
||||
return model.Reply{
|
||||
return &model.Reply{
|
||||
ReplyMsg: "构建成功",
|
||||
ReferOriginMsg: true,
|
||||
FromMsg: msg,
|
||||
}
|
||||
}
|
||||
|
||||
func buildAndRestart(msg model.Message) model.Reply {
|
||||
func buildAndRestart(msg model.Message) *model.Reply {
|
||||
err := buildBot()
|
||||
if err != nil {
|
||||
return model.Reply{
|
||||
return &model.Reply{
|
||||
ReplyMsg: "构建失败,报错如下\n" + err.Error(),
|
||||
ReferOriginMsg: true,
|
||||
FromMsg: msg,
|
||||
}
|
||||
}
|
||||
if !hasVaildBuild {
|
||||
return model.Reply{
|
||||
return &model.Reply{
|
||||
ReplyMsg: "构建失败,请先成功构建再部署",
|
||||
ReferOriginMsg: true,
|
||||
FromMsg: msg,
|
||||
}
|
||||
}
|
||||
go restartProgram()
|
||||
return model.Reply{
|
||||
return &model.Reply{
|
||||
ReplyMsg: "构建成功,重启中...",
|
||||
ReferOriginMsg: true,
|
||||
FromMsg: msg,
|
||||
}
|
||||
}
|
||||
|
||||
func pullCode(msg model.Message) model.Reply {
|
||||
func pullCode(msg model.Message) *model.Reply {
|
||||
err := util.GitPull()
|
||||
if err != nil {
|
||||
return model.Reply{
|
||||
return &model.Reply{
|
||||
ReplyMsg: "拉取代码失败,报错如下\n" + err.Error(),
|
||||
ReferOriginMsg: true,
|
||||
FromMsg: msg,
|
||||
}
|
||||
}
|
||||
return model.Reply{
|
||||
return &model.Reply{
|
||||
ReplyMsg: "拉取代码成功",
|
||||
ReferOriginMsg: true,
|
||||
FromMsg: msg,
|
||||
|
||||
Reference in New Issue
Block a user