feat: support ban and kick
This commit is contained in:
@@ -52,7 +52,7 @@ func HandleJoinGame(userName string, mention bool, expireMode bool) {
|
||||
tgbotapi.NewInlineKeyboardButtonData("拒绝", defs.NewRejectCommand(u.MCName).ToJSON())),
|
||||
)
|
||||
conf.Bot.Send(m)
|
||||
kickPlayer(userName)
|
||||
KickPlayer(userName)
|
||||
return
|
||||
}
|
||||
if mention {
|
||||
@@ -61,7 +61,7 @@ func HandleJoinGame(userName string, mention bool, expireMode bool) {
|
||||
case StatusPending:
|
||||
SendMsgToPlayer("你还没有绑定 Telegram 哦, 5秒后你将会被踢出。请在群组中发送 /bind <你的 MC 用户名> 进行绑定。", userName)
|
||||
time.Sleep(5 * time.Second)
|
||||
kickPlayer(userName)
|
||||
KickPlayer(userName)
|
||||
m := tgbotapi.NewMessage(conf.GetBotSettings().GroupID, fmt.Sprintf("用户:%v 没有绑定,尝试登录已被T出", userName))
|
||||
conf.Bot.Send(m)
|
||||
case StatusBanned:
|
||||
@@ -71,13 +71,13 @@ func HandleJoinGame(userName string, mention bool, expireMode bool) {
|
||||
default:
|
||||
SendMsgToPlayer("未知错误,请联系管理员,你将被踢出", userName)
|
||||
time.Sleep(3 * time.Second)
|
||||
kickPlayer(userName)
|
||||
KickPlayer(userName)
|
||||
m := tgbotapi.NewMessage(conf.GetBotSettings().GroupID, fmt.Sprintf("用户:%v 登录失败,错误未知,已被T出", userName))
|
||||
conf.Bot.Send(m)
|
||||
}
|
||||
}
|
||||
|
||||
func sendCommand(cmd string) error {
|
||||
func SendCommand(cmd string) error {
|
||||
var salt int64
|
||||
if err := binary.Read(rand.Reader, binary.BigEndian, &salt); err != nil {
|
||||
return err
|
||||
@@ -95,8 +95,8 @@ func sendCommand(cmd string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func kickPlayer(userName string) error {
|
||||
err := sendCommand("kick " + userName)
|
||||
func KickPlayer(userName string) error {
|
||||
err := SendCommand("kick " + userName)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user