feat: add binding checks in BindBL and BindSS functions to prevent account conflicts

This commit is contained in:
lixiangwuxian 2025-01-16 21:34:07 +08:00
parent 70d7e270d7
commit df2ad0de94
2 changed files with 13 additions and 0 deletions

View File

@ -91,6 +91,12 @@ func (bl *blQuery) BindBL(qqId string, blId string) (reply string) {
}
rows.Close()
}
if rows, err := tx.Query("SELECT * FROM ssBind WHERE ssid = ?", blId); err == nil {
if rows.Next() {
return "该bl账号已绑定至其他用户"
}
rows.Close()
}
_, err = tx.Exec("INSERT INTO ssBind(qqid, ssid) VALUES(?, ?)", qqId, blId)
if err != nil {
return "绑定失败,请稍后重试:" + err.Error()

View File

@ -98,6 +98,13 @@ func (ss *ssQuery) BindSS(qqId string, ssId string) (reply string) {
}
rows.Close()
}
// 检查是否已绑定
if rows, err := tx.Query("SELECT * FROM ssBind WHERE ssid = ?", ssId); err == nil {
if rows.Next() {
return "该ss账号已绑定至其他用户"
}
rows.Close()
}
_, err = tx.Exec("INSERT INTO ssBind(qqid, ssid) VALUES(?, ?)", qqId, ssId)
if err != nil {
return "绑定失败"