fix: unbind
This commit is contained in:
parent
e39db56969
commit
80cae65b98
12
.drone.yml
12
.drone.yml
@ -58,8 +58,10 @@ steps:
|
||||
image: git.vaala.cloud/vaalacat/drone-docker-buildx:24
|
||||
privileged: true
|
||||
environment:
|
||||
HTTP_PROXY: http://10.10.0.17:7890
|
||||
HTTPS_PROXY: http://10.10.0.17:7890
|
||||
HTTP_PROXY:
|
||||
from_secret: HTTP_PROXY
|
||||
HTTPS_PROXY:
|
||||
from_secret: HTTP_PROXY
|
||||
settings:
|
||||
mirror: https://docker.lab.vaala.tech
|
||||
debug: true
|
||||
@ -88,8 +90,10 @@ steps:
|
||||
image: git.vaala.cloud/vaalacat/drone-docker-buildx:24
|
||||
privileged: true
|
||||
environment:
|
||||
HTTP_PROXY: http://10.10.0.17:7890
|
||||
HTTPS_PROXY: http://10.10.0.17:7890
|
||||
HTTP_PROXY:
|
||||
from_secret: HTTP_PROXY
|
||||
HTTPS_PROXY:
|
||||
from_secret: HTTP_PROXY
|
||||
settings:
|
||||
mirror: https://docker.lab.vaala.tech
|
||||
debug: true
|
||||
|
@ -5,24 +5,38 @@ import (
|
||||
"tg-mc/models"
|
||||
|
||||
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
|
||||
"github.com/samber/lo"
|
||||
"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 len(msg.CommandArguments()) == 0 {
|
||||
m := tgbotapi.NewMessage(msg.Chat.ID, "请输入正确的参数")
|
||||
conf.Bot.Send(m)
|
||||
return
|
||||
}
|
||||
|
||||
us, err := models.GetUsersByTGID(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
|
||||
|
||||
lo.Map(us, func(u models.User, _ int) bool {
|
||||
if u.MCName == msg.CommandArguments() {
|
||||
u.Status = 0
|
||||
err = u.Delete(msg.From.ID)
|
||||
if err != nil {
|
||||
m := tgbotapi.NewMessage(msg.Chat.ID, "解绑失败")
|
||||
conf.Bot.Send(m)
|
||||
return false
|
||||
}
|
||||
m := tgbotapi.NewMessage(msg.Chat.ID, "解绑成功")
|
||||
conf.Bot.Send(m)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
})
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user