function isQQ(str) {
    return /^[1-9][0-9]{4,10}$/.test(str)
}

function resolveQQAvatarFromEmail(email) {
    if (!email) return null
    const parts = String(email).split('@')
    if (parts.length !== 2) return null
    const qq = parts[0]
    const domain = parts[1].toLowerCase()
    if (domain !== 'qq.com' || !isQQ(qq)) return null
    return `https://q2.qlogo.cn/headimg_dl?dst_uin=${qq}&spec=640`
}

module.exports = {
    isQQ,
    resolveQQAvatarFromEmail
}
