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 }