diff --git a/services/mc/helper.go b/services/mc/helper.go index 56a39ec..d1fd718 100644 --- a/services/mc/helper.go +++ b/services/mc/helper.go @@ -4,6 +4,7 @@ import ( "crypto/rand" "encoding/binary" "errors" + "fmt" "tg-mc/conf" "tg-mc/models" su "tg-mc/services/utils" @@ -13,6 +14,7 @@ import ( "github.com/Tnze/go-mc/chat" "github.com/Tnze/go-mc/data/packetid" "github.com/Tnze/go-mc/net/packet" + tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5" "github.com/sirupsen/logrus" ) @@ -49,12 +51,18 @@ func HandleJoinGame(userName string, mention bool) { SendMsgToPlayer("你还没有绑定 Telegram 哦, 5秒后你将会被踢出。请在群组中发送 /bind <你的 MC 用户名> 进行绑定。", userName) time.Sleep(5 * time.Second) kickPlayer(userName) + m := tgbotapi.NewMessage(conf.GetBotSettings().GroupID, fmt.Sprintf("用户:%v 没有绑定,尝试登录已被T出", userName)) + conf.Bot.Send(m) case StatusBanned: SendMsgToPlayer("你已被封禁,如有疑问请联系管理员。", userName) + m := tgbotapi.NewMessage(conf.GetBotSettings().GroupID, fmt.Sprintf("用户:%v 已被封禁,尝试登录已被T出", userName)) + conf.Bot.Send(m) default: SendMsgToPlayer("未知错误,请联系管理员,你将被踢出", userName) time.Sleep(3 * time.Second) kickPlayer(userName) + m := tgbotapi.NewMessage(conf.GetBotSettings().GroupID, fmt.Sprintf("用户:%v 登录失败,错误未知,已被T出", userName)) + conf.Bot.Send(m) } } diff --git a/services/mc/mc.go b/services/mc/mc.go index 15cd1d0..01724c8 100644 --- a/services/mc/mc.go +++ b/services/mc/mc.go @@ -92,6 +92,9 @@ func onSystemMsg(msg chat.Message, overlay bool) error { func onPlayerMsg(msg chat.Message, validated bool) error { go func() { + if msg.Translate != "commands.message.display.incoming" { + return + } log.Printf("Player: %s", msg) s := strings.Split(msg.String(), " ") if len(s) > 1 {