package beatleader

import (
	"database/sql"
	"errors"
	"log"

	"git.lxtend.com/lixiangwuxian/qqbot/sqlite3"
)

func getBLID(qqId string) (blId string, err error) {
	db := sqlite3.GetDB()
	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
}
