package scoresaber

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

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

func GetSSID(qqId string) (ssId string, err error) {
	db := sqlite3.GetDB()
	err = db.Get(&ssId, "SELECT ssid FROM ssBind WHERE qqid = ?", qqId)
	if err != nil {
		if err == sql.ErrNoRows {
			return "", errors.New("未绑定ss账号，输入\"绑定ss [ssId]\"绑定")
		}
		log.Println("查询 ssId 出错:", err)
		return "", errors.New("查询 ssId 失败")
	}
	return ssId, nil
}
