From 5645fa0168a7e8a2f2db2dc081c27483cf7541d0 Mon Sep 17 00:00:00 2001 From: fumiama Date: Wed, 8 Dec 2021 17:35:22 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20=20sql=20=E9=98=B2?= =?UTF-8?q?=E6=B3=A8=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin_book_review/book_review.go | 3 ++- plugin_book_review/model.go | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/plugin_book_review/book_review.go b/plugin_book_review/book_review.go index 859766cb..11441404 100644 --- a/plugin_book_review/book_review.go +++ b/plugin_book_review/book_review.go @@ -13,7 +13,8 @@ func init() { Help: "哀伤雪刃推书记录\n- 书评[xxx]\n- 随机书评", }) - engine.OnRegex("^书评(.{1,25})$").SetBlock(true). + // 中文、英文、数字但不包括下划线等符号 + engine.OnRegex("^书评([\u4E00-\u9FA5A-Za-z0-9]{1,25})$").SetBlock(true). Handle(func(ctx *zero.Ctx) { b := getBookReviewByKeyword(ctx.State["regex_matched"].([]string)[1]) ctx.SendChain(message.Text(b.BookReview)) diff --git a/plugin_book_review/model.go b/plugin_book_review/model.go index 8fc85ac4..24e5cddf 100644 --- a/plugin_book_review/model.go +++ b/plugin_book_review/model.go @@ -7,7 +7,7 @@ type book struct { // 暂时随机选择一个书评 func getBookReviewByKeyword(keyword string) (b book) { - db.Find("bookreview", &b, "where bookreview LIKE %"+keyword+"%") + db.Find("bookreview", &b, "where bookreview LIKE '%"+keyword+"%'") return }