refactor: 重构消息发送模型
This commit is contained in:
@@ -20,6 +20,7 @@ func init() {
|
||||
handler.RegisterHandler("/构建bot", build, constants.LEVEL_ADMIN)
|
||||
handler.RegisterHandler("/构建重启", buildAndRestart, constants.LEVEL_ADMIN)
|
||||
handler.RegisterHandler("/gitpull", pullCode, constants.LEVEL_ADMIN)
|
||||
handler.RegisterHandler("/shutdown", shutdown, constants.LEVEL_ADMIN)
|
||||
}
|
||||
|
||||
func restart(msg model.Message) model.Reply {
|
||||
@@ -38,6 +39,15 @@ func restart(msg model.Message) model.Reply {
|
||||
}
|
||||
}
|
||||
|
||||
func shutdown(msg model.Message) model.Reply {
|
||||
go shutdownProgram()
|
||||
return model.Reply{
|
||||
ReplyMsg: "关闭中...",
|
||||
ReferOriginMsg: true,
|
||||
FromMsg: msg,
|
||||
}
|
||||
}
|
||||
|
||||
func build(msg model.Message) model.Reply {
|
||||
err := buildBot()
|
||||
if err != nil {
|
||||
@@ -117,6 +127,14 @@ func restartProgram() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func shutdownProgram() error {
|
||||
log.Println("关闭程序...")
|
||||
docker.DockerContainer.RemoveContainer()
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
os.Exit(0)
|
||||
return nil
|
||||
}
|
||||
|
||||
func buildBot() error {
|
||||
hasVaildBuild = false
|
||||
workDir, err := os.Getwd()
|
||||
|
||||
Reference in New Issue
Block a user