From 55944dddb35ee3639022c9d39a8d2cc477e0e3eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Tue, 8 Mar 2022 18:14:41 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20job=E5=A2=9E=E5=8A=A0=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E8=AF=BB=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/job/main.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/plugin/job/main.go b/plugin/job/main.go index 2ac73890..64da9fc3 100644 --- a/plugin/job/main.go +++ b/plugin/job/main.go @@ -232,8 +232,18 @@ func parseArgs(ctx *zero.Ctx) bool { args := make(map[int]string) for strings.Contains(ctx.Event.RawEvent.Raw, "?::") { start := strings.Index(ctx.Event.RawEvent.Raw, "?::") - msgend := strings.Index(ctx.Event.RawEvent.Raw[start+3:], "::") + start + 3 - numend := strings.Index(ctx.Event.RawEvent.Raw[msgend+2:], "!") + msgend + 2 + msgend := strings.Index(ctx.Event.RawEvent.Raw[start+3:], "::") + if msgend < 0 { + ctx.SendChain(message.Text("ERROR:找不到结束的::")) + return false + } + msgend += start + 3 + numend := strings.Index(ctx.Event.RawEvent.Raw[msgend+2:], "!") + if numend <= 0 { + ctx.SendChain(message.Text("ERROR:找不到结束的!")) + return false + } + numend += msgend + 2 logrus.Debugln("[job]", start, msgend, numend) msg := ctx.Event.RawEvent.Raw[start+3 : msgend] arg, err := strconv.Atoi(ctx.Event.RawEvent.Raw[msgend+2 : numend])