fix: 更新疯狂星期四文案处理逻辑,添加周四判断和不回复机制
This commit is contained in:
parent
83b0545747
commit
c0764036ab
@ -2,6 +2,7 @@ package kfccrazy
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"git.lxtend.com/qqbot/constants"
|
"git.lxtend.com/qqbot/constants"
|
||||||
"git.lxtend.com/qqbot/handler"
|
"git.lxtend.com/qqbot/handler"
|
||||||
@ -11,9 +12,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
handler.RegisterHelpInform("疯狂星期四test", "疯狂星期四", "随机输出疯狂星期四文案")
|
// handler.RegisterHelpInform("疯狂星期四", "疯狂星期四", "随机输出疯狂星期四文案")
|
||||||
handler.RegisterHandler("疯狂星期四test", pickKfc, constants.LEVEL_USER)
|
// handler.RegisterHandler("疯狂星期四", pickKfc, constants.LEVEL_USER)
|
||||||
handler.RegisterHelpInform("疯狂星期四文案添加", "疯狂星期四文案添加", "添加疯狂星期四文案")
|
// handler.RegisterHelpInform("疯狂星期四文案添加", "疯狂星期四文案添加", "添加疯狂星期四文案")
|
||||||
handler.RegisterHandler("疯狂星期四文案添加", storeKfc, constants.LEVEL_TRUSTED)
|
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) {
|
func pickKfc(msg model.Message) (reply model.Reply) {
|
||||||
|
// 判断是否是周四
|
||||||
|
if time.Now().Weekday() != time.Thursday {
|
||||||
|
return model.NotReply
|
||||||
|
}
|
||||||
// 从数据库随机获取一条文案
|
// 从数据库随机获取一条文案
|
||||||
tx, err := sqlite3.GetTran()
|
tx, err := sqlite3.GetTran()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -105,11 +110,7 @@ func pickKfc(msg model.Message) (reply model.Reply) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if count == 0 {
|
if count == 0 {
|
||||||
return model.Reply{
|
return model.NotReply
|
||||||
ReplyMsg: "",
|
|
||||||
ReferOriginMsg: false,
|
|
||||||
FromMsg: msg,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var content string
|
var content string
|
||||||
|
@ -19,3 +19,9 @@ type Reply struct {
|
|||||||
ReferOriginMsg bool `json:"referOriginMsg"`
|
ReferOriginMsg bool `json:"referOriginMsg"`
|
||||||
FromMsg Message `json:"fromMsg"`
|
FromMsg Message `json:"fromMsg"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var NotReply = Reply{
|
||||||
|
ReplyMsg: "",
|
||||||
|
ReferOriginMsg: false,
|
||||||
|
FromMsg: Message{},
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user