From c0764036ab3868c01e9362122d16da9c829baa02 Mon Sep 17 00:00:00 2001 From: lixiangwuxian Date: Mon, 17 Mar 2025 19:01:55 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=9B=B4=E6=96=B0=E7=96=AF=E7=8B=82?= =?UTF-8?q?=E6=98=9F=E6=9C=9F=E5=9B=9B=E6=96=87=E6=A1=88=E5=A4=84=E7=90=86?= =?UTF-8?q?=E9=80=BB=E8=BE=91=EF=BC=8C=E6=B7=BB=E5=8A=A0=E5=91=A8=E5=9B=9B?= =?UTF-8?q?=E5=88=A4=E6=96=AD=E5=92=8C=E4=B8=8D=E5=9B=9E=E5=A4=8D=E6=9C=BA?= =?UTF-8?q?=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- handler/kfccrazy/kfc.go | 17 +++++++++-------- model/message.go | 6 ++++++ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/handler/kfccrazy/kfc.go b/handler/kfccrazy/kfc.go index 4ad59f8..91a4e2d 100644 --- a/handler/kfccrazy/kfc.go +++ b/handler/kfccrazy/kfc.go @@ -2,6 +2,7 @@ package kfccrazy import ( "strings" + "time" "git.lxtend.com/qqbot/constants" "git.lxtend.com/qqbot/handler" @@ -11,9 +12,9 @@ import ( ) func init() { - handler.RegisterHelpInform("疯狂星期四test", "疯狂星期四", "随机输出疯狂星期四文案") - handler.RegisterHandler("疯狂星期四test", pickKfc, constants.LEVEL_USER) - handler.RegisterHelpInform("疯狂星期四文案添加", "疯狂星期四文案添加", "添加疯狂星期四文案") + // handler.RegisterHelpInform("疯狂星期四", "疯狂星期四", "随机输出疯狂星期四文案") + // handler.RegisterHandler("疯狂星期四", pickKfc, constants.LEVEL_USER) + // handler.RegisterHelpInform("疯狂星期四文案添加", "疯狂星期四文案添加", "添加疯狂星期四文案") handler.RegisterHandler("疯狂星期四文案添加", storeKfc, constants.LEVEL_TRUSTED) // 创建疯狂星期四文案表 @@ -83,6 +84,10 @@ func storeKfc(msg model.Message) (reply model.Reply) { } func pickKfc(msg model.Message) (reply model.Reply) { + // 判断是否是周四 + if time.Now().Weekday() != time.Thursday { + return model.NotReply + } // 从数据库随机获取一条文案 tx, err := sqlite3.GetTran() if err != nil { @@ -105,11 +110,7 @@ func pickKfc(msg model.Message) (reply model.Reply) { } if count == 0 { - return model.Reply{ - ReplyMsg: "", - ReferOriginMsg: false, - FromMsg: msg, - } + return model.NotReply } var content string diff --git a/model/message.go b/model/message.go index 63806e8..b2541d0 100644 --- a/model/message.go +++ b/model/message.go @@ -19,3 +19,9 @@ type Reply struct { ReferOriginMsg bool `json:"referOriginMsg"` FromMsg Message `json:"fromMsg"` } + +var NotReply = Reply{ + ReplyMsg: "", + ReferOriginMsg: false, + FromMsg: Message{}, +}