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/approve.go Normal file
View File

@@ -0,0 +1,28 @@
package tgbot
import (
"fmt"
"tg-mc/conf"
"tg-mc/defs"
"tg-mc/models"
"tg-mc/services/mc"
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
"github.com/sirupsen/logrus"
)
func ApproveHandler(update tgbotapi.Update, cmd defs.Command) {
u, err := models.GetUserByTGID(update.CallbackQuery.From.ID)
if err != nil {
return
}
mc.GetAuthcator().Auth(u)
callback := tgbotapi.NewCallback(update.CallbackQuery.ID, "已授权")
if _, err := conf.Bot.Request(callback); err != nil {
logrus.Panic(err)
}
conf.Bot.Send(tgbotapi.NewDeleteMessage(update.CallbackQuery.Message.Chat.ID,
update.CallbackQuery.Message.MessageID))
conf.Bot.Send(tgbotapi.NewMessage(update.CallbackQuery.Message.Chat.ID,
fmt.Sprintf("已授权☑️: %s 登录MC", u.MCName)))
}