diff --git a/core/function.go b/core/function.go index 5b51e60..7721fc2 100644 --- a/core/function.go +++ b/core/function.go @@ -1,6 +1,7 @@ package core import ( + "os" "regexp" "strings" @@ -23,7 +24,7 @@ type Function struct { Cron string } -var pname = string(sillyGirl) +var pname = regexp.MustCompile(`/([^/\s]+)`).FindStringSubmatch(os.Args[0])[1] var name = func() string { return sillyGirl.Get("name", "傻妞") diff --git a/core/sys.go b/core/sys.go index 01c0565..ddc71cf 100644 --- a/core/sys.go +++ b/core/sys.go @@ -62,7 +62,7 @@ func GitPull(filename string) (bool, error) { func CompileCode() error { cmd := exec.Command("sh", "-c", "cd "+ExecPath+" && go build -o "+pname) - NotifyMasters("cd " + ExecPath + " && go build -o " + pname) + NotifyMasters(os.Args[0]) _, err := cmd.Output() if err != nil { return errors.New("编译失败:" + err.Error() + "。")