2023-08-28 15:57:58 +08:00

30 lines
622 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package tgbot
import (
"fmt"
"tg-mc/conf"
"tg-mc/models"
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
"github.com/sirupsen/logrus"
)
func BindHandler(m *tgbotapi.Message, i interface{}) {
logrus.Infof("id is %d", m.Chat.ID)
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
}
msg := tgbotapi.NewMessage(m.Chat.ID,
fmt.Sprintf("绑定成功你的MCID是%v", m.CommandArguments()))
conf.Bot.Send(msg)
return
}