qq_bot/service/beatleader/get_blid.go
2024-10-20 01:26:14 +08:00

28 lines
630 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 beatleader
import (
"database/sql"
"errors"
"log"
"git.lxtend.com/qqbot/sqlite3"
)
func getBLID(qqId string) (blId string, err error) {
db := sqlite3.GetDB() // 假设 sqlite3.GetDB() 返回 *sqlx.DB
if err != nil {
log.Print(err)
return "", errors.New("数据库连接失败,请稍后重试")
}
err = db.Get(&blId, "SELECT ssid FROM ssBind WHERE qqid = ?", qqId)
if err != nil {
if err == sql.ErrNoRows {
return "", errors.New("未绑定bl账号输入\"绑定bl [blId]\"绑定")
}
log.Println("查询 blId 出错:", err)
return "", errors.New("查询 blId 失败")
}
return blId, nil
}