fix: 更新疯狂星期四文案处理逻辑,添加周四判断和不回复机制

This commit is contained in:
lixiangwuxian 2025-03-17 19:01:55 +08:00
parent 83b0545747
commit c0764036ab
2 changed files with 15 additions and 8 deletions

View File

@ -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

View File

@ -19,3 +19,9 @@ type Reply struct {
ReferOriginMsg bool `json:"referOriginMsg"`
FromMsg Message `json:"fromMsg"`
}
var NotReply = Reply{
ReplyMsg: "",
ReferOriginMsg: false,
FromMsg: Message{},
}