From d36d7aa2ed664783a3ff89cbb4afc8bb4a90c7a0 Mon Sep 17 00:00:00 2001 From: wdvxdr Date: Tue, 20 Apr 2021 18:44:00 +0800 Subject: [PATCH] feat(server): allow post without http server --- server/http.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server/http.go b/server/http.go index c6f0283..9604208 100644 --- a/server/http.go +++ b/server/http.go @@ -51,8 +51,12 @@ func RunHTTPServerAndClients(bot *coolq.CQBot, conf *config.HTTPServer) { var ( s = new(httpServer) authToken = conf.AccessToken - addr = fmt.Sprintf("%s:%d", conf.Host, conf.Port) + addr string ) + if conf.Host == "" || conf.Port == 0 { + goto client + } + addr = fmt.Sprintf("%s:%d", conf.Host, conf.Port) gin.SetMode(gin.ReleaseMode) s.engine = gin.New() s.bot = bot @@ -126,7 +130,7 @@ func RunHTTPServerAndClients(bot *coolq.CQBot, conf *config.HTTPServer) { os.Exit(1) } }() - +client: for _, c := range conf.Post { if c.URL != "" { go newHTTPClient().Run(c.URL, c.Secret, conf.Filter, conf.Timeout, bot)