fix: support kick cron

This commit is contained in:
Vaala Cat
2023-06-19 19:54:47 +08:00
parent f0c2083bd7
commit 60d6572331
5 changed files with 30 additions and 13 deletions

View File

@@ -59,11 +59,16 @@ func Run(sendFunc func(string)) {
}
if m.Command() == "bind" {
logrus.Infof("id is %d", m.Chat.ID)
models.CreateUserIfNotExist(m.From.ID, &models.User{
err := models.CreateUser(&models.User{
TGID: m.From.ID,
MCName: m.CommandArguments(),
Status: 1,
})
if err != nil {
m := tgbotapi.NewMessage(m.Chat.ID, "绑定失败, err: "+err.Error())
conf.Bot.Send(m)
return
}
m := tgbotapi.NewMessage(m.Chat.ID,
fmt.Sprintf("绑定成功你的MCID是%v", m.CommandArguments()))
conf.Bot.Send(m)
@@ -87,6 +92,18 @@ func Run(sendFunc func(string)) {
conf.Bot.Send(m)
return
}
if m.Command() == "get" {
logrus.Infof("id is %d", m.Chat.ID)
u, err := models.GetUserByTGID(m.From.ID)
if err != nil {
m := tgbotapi.NewMessage(m.Chat.ID, "你还没有绑定")
conf.Bot.Send(m)
return
}
m := tgbotapi.NewMessage(m.Chat.ID, fmt.Sprintf("你的MCID是%v", u.MCName))
conf.Bot.Send(m)
return
}
}(update.Message)
}
}