feat: approve button

This commit is contained in:
Vaala Cat
2023-08-28 15:57:58 +08:00
parent 46cf57764c
commit 5528766c13
15 changed files with 469 additions and 176 deletions

28
services/tgbot/unbind.go Normal file
View File

@@ -0,0 +1,28 @@
package tgbot
import (
"tg-mc/conf"
"tg-mc/models"
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
"github.com/sirupsen/logrus"
)
func UnbindHandler(msg *tgbotapi.Message, i interface{}) {
logrus.Infof("id is %d", msg.Chat.ID)
u, err := models.GetUserByTGID(msg.From.ID)
if err != nil {
m := tgbotapi.NewMessage(msg.Chat.ID, "你还没有绑定")
conf.Bot.Send(m)
return
}
err = u.Delete(msg.From.ID)
if err != nil {
m := tgbotapi.NewMessage(msg.Chat.ID, "解绑失败")
conf.Bot.Send(m)
return
}
m := tgbotapi.NewMessage(msg.Chat.ID, "解绑成功")
conf.Bot.Send(m)
return
}