From a0180c7ae7ea5f08c7f2cc866c5a8a980bdd2cf7 Mon Sep 17 00:00:00 2001 From: Clov614 Date: Mon, 14 Oct 2024 22:36:39 +0800 Subject: [PATCH] =?UTF-8?q?fixed:=20onebot=E5=AE=A2=E6=88=B7=E7=AB=AF?= =?UTF-8?q?=E4=B8=BB=E5=8A=A8=E4=B8=8A=E6=8A=A5=E5=99=A8=E6=B3=A8=E9=87=8A?= =?UTF-8?q?=E5=90=8E=E4=BE=9D=E6=97=A7=E4=B8=8A=E6=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rikkabot/config/config.go | 6 +++++- rikkabot/onebot/httpapi/httpapi.go | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/rikkabot/config/config.go b/rikkabot/config/config.go index 32ee4f5..7f29bd1 100644 --- a/rikkabot/config/config.go +++ b/rikkabot/config/config.go @@ -126,6 +126,10 @@ func (c *CommonConfig) verifiability() { c.AnswerDelayRandMin = defaultAnswerDelayRandMin c.AnswerDelayRandMax = defaultAnswerDelayRandMax } + // 校验 http post 列表是否为空视为不开启主动post + if len(c.HttpPost) == 1 && c.HttpPost[0].Url == "" && c.HttpPost[0].Secret == "" && c.HttpPost[0].MaxRetries == 0 { + c.HttpPost = []HttpPostConfig{} + } } @@ -155,8 +159,8 @@ func init() { } logging.ErrorWithErr(err, "error load config") } - config.verifiability() // 校验设置项是否合规 err = configutil.Save(&config, defaultPath, defaultSaveFileName) + config.verifiability() // 校验设置项是否合规 if err != nil { logging.ErrorWithErr(err, "error saving config") } diff --git a/rikkabot/onebot/httpapi/httpapi.go b/rikkabot/onebot/httpapi/httpapi.go index 928dfc0..6965203 100644 --- a/rikkabot/onebot/httpapi/httpapi.go +++ b/rikkabot/onebot/httpapi/httpapi.go @@ -351,6 +351,7 @@ func (c HttpClient) HandlerPostEvent(event event.IEvent) { req, err = http.NewRequest("POST", c.postUrl, bytes.NewBuffer(eventJSON)) if err != nil { logHttpPostError(event, err, "request create failed") + rikkabot.Bot().ExitWithErr(1102, err.Error()) } req.Header.Set("Content-Type", "application/json") req.Header.Set("Authorization", "Bearer "+encrypt(c.secret))