refactor: 重构数据库逻辑

This commit is contained in:
lixiangwuxian
2024-10-11 00:14:11 +08:00
parent 7aebdeae56
commit 769308389a
16 changed files with 289 additions and 164 deletions

View File

@@ -0,0 +1,26 @@
package beatleader
import (
"git.lxtend.com/qqbot/handler"
"git.lxtend.com/qqbot/model"
)
func init() {
handler.RegisterHandler("查bl", getMyBL)
// handler.RegisterHandler("绑定bl", bindBL)
// handler.RegisterHandler("解绑bl", unbindSS)
// handler.RegisterHandler("最新bl", getMyRecentScore)
// handler.RegisterHandler("最热bl", getRecentScore)
}
func getMyBL(msg model.Message) (reply model.Reply) {
if len(msg.Msg) <= len("查bl ") {
return model.Reply{}
}
bindResult := ""
return model.Reply{
ReplyMsg: bindResult,
ReferOriginMsg: true,
FromMsg: msg,
}
}

19
handler/health/health.go Normal file
View File

@@ -0,0 +1,19 @@
package health
import (
"git.lxtend.com/qqbot/handler"
"git.lxtend.com/qqbot/model"
)
func init() {
handler.RegisterHandler("health", health)
}
func health(msg model.Message) (reply model.Reply) {
heathResult := ""
return model.Reply{
ReplyMsg: heathResult,
ReferOriginMsg: true,
FromMsg: msg,
}
}

View File

@@ -6,15 +6,15 @@ import (
)
func init() {
handler.RegisterHandler("记下", say)
handler.RegisterHandler("kw", say)
}
func say(msg model.Message) (reply model.Reply) {
if len(msg.Msg) <= 5 {
if len(msg.Msg) <= len("kw ") {
return model.Reply{}
}
return model.Reply{
ReplyMsg: msg.Msg[5:],
ReplyMsg: "记下了",
ReferOriginMsg: true,
FromMsg: msg,
}

View File

@@ -9,16 +9,21 @@ import (
)
func init() {
handler.RegisterHandler("查ss", getScore)
handler.RegisterHandler("查ss", getMySS)
handler.RegisterHandler("绑定ss", bindSS)
handler.RegisterHandler("解绑ss", unbindSS)
handler.RegisterHandler("最新ss", getMyRecentScore)
handler.RegisterHandler("最热ss", getRecentScore)
}
func getScore(msg model.Message) (reply model.Reply) {
func getMySS(msg model.Message) (reply model.Reply) {
resultStr := ""
var err error
for ; err != nil; resultStr, err = scoresaber.SSQuery.GetScore(strconv.Itoa(int(msg.UserId))) {
}
return model.Reply{
ReplyMsg: scoresaber.SSQuery.GetScore(strconv.Itoa(int(msg.UserId))),
ReplyMsg: resultStr,
ReferOriginMsg: true,
FromMsg: msg,
}
@@ -54,7 +59,7 @@ func getRecentScore(msg model.Message) (reply model.Reply) {
}
}
scoreMsg := ""
for _, v := range scoresaber.ScoresManager.GetRecentScores(count) {
for _, v := range scoresaber.ScoresManager.GetRecentScores(count, " WHERE country = 'CN' ") {
scoreMsg += v.ToString() + "\n\n"
}
if len(scoreMsg) > 0 {