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{}, +}