We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
下面这个实例代码有两个问题: 1、getQrcodeKey这个方法找不到,应该怎么import 2、我这个verifyCode怎么获取?如果我扫码获取到了,我需要关掉再重新启动,那个时候的验证码已经换了啊。
bot.on('scan', (qrcode, status, data) => { console.log(============================================================ qrcode : ${qrcode}, status: ${status}, data: ${data} ============================================================) if (status === ScanStatus.Waiting) { store.qrcodeKey= getQrcodeKey(qrcode) || '' QrcodeTerminal.generate(qrcode, { small: true }) } }).on('verify-code', async (id: string, message: string, scene: types.VerifyCodeScene, status: types.VerifyCodeStatus) => { // 需要注意的是,验证码事件不是完全即时的,可能有最多10秒的延迟。 // 这与底层轮询二维码状态的时间间隔有关。 if (status === types.VerifyCodeStatus.WAITING && scene === types.VerifyCodeScene.LOGIN && id === store.qrcodeKey) { console.log(receive verify-code event, id: ${id}, message: ${message}, scene: ${types.VerifyCodeScene[scene]} status: ${types.VerifyCodeStatus[status]}) const verifyCode = '084356' // 通过一些途径输入验证码 try { await bot.enterVerifyCode(id, verifyCode) // 如果没抛错,则说明输入成功,会推送登录事件 return } catch (e) { console.log((e as Error).message) // 如果抛错,请根据 message 处理,目前发现可以输错3次,超过3次错误需要重新扫码。 // 错误关键词: 验证码错误输入错误,请重新输入 // 错误关键词:验证码错误次数超过阈值,请重新扫码' // 目前不会推送 EXPIRED 事件,需要根据错误内容判断 } } }).on('login', user => { console.log(============================================ user: ${JSON.stringify(user)}, friend: ${user.friend()}, ${user.coworker()} ============================================) }).on('message', message => { console.log(new message received: ${JSON.stringify(message)}) }).on('error', err => { console.log(err) }).on('room-announce', (...args) => { console.log(room announce: ${JSON.stringify(args)}) }).on('contact-alias', (...args) => { console.log(contact alias: ${JSON.stringify(args)}) }).on('tag', (...args) => { console.log(tag: ${JSON.stringify(args)}) })
============================================================ qrcode : ${qrcode}, status: ${status}, data: ${data} ============================================================
receive verify-code event, id: ${id}, message: ${message}, scene: ${types.VerifyCodeScene[scene]} status: ${types.VerifyCodeStatus[status]}
============================================ user: ${JSON.stringify(user)}, friend: ${user.friend()}, ${user.coworker()} ============================================
new message received: ${JSON.stringify(message)}
room announce: ${JSON.stringify(args)}
contact alias: ${JSON.stringify(args)}
tag: ${JSON.stringify(args)}
The text was updated successfully, but these errors were encountered:
@ahujack 参考 #267
Sorry, something went wrong.
就是参考的这个示例,不行
@ahujack 需要自行通过实现将手机端获取到验证码,通过api等形式传递给你的服务,并且通过监听 'verify-code' 事件,将获取到的验证码调用 enterVerifyCode 方法传递。
su-chang
hcfw007
No branches or pull requests
下面这个实例代码有两个问题:
1、getQrcodeKey这个方法找不到,应该怎么import
2、我这个verifyCode怎么获取?如果我扫码获取到了,我需要关掉再重新启动,那个时候的验证码已经换了啊。
bot.on('scan', (qrcode, status, data) => {
console.log(
============================================================ qrcode : ${qrcode}, status: ${status}, data: ${data} ============================================================
)if (status === ScanStatus.Waiting) {
store.qrcodeKey= getQrcodeKey(qrcode) || ''
QrcodeTerminal.generate(qrcode, {
small: true
})
}
}).on('verify-code', async (id: string, message: string, scene: types.VerifyCodeScene, status: types.VerifyCodeStatus) => {
// 需要注意的是,验证码事件不是完全即时的,可能有最多10秒的延迟。
// 这与底层轮询二维码状态的时间间隔有关。
if (status === types.VerifyCodeStatus.WAITING && scene === types.VerifyCodeScene.LOGIN && id === store.qrcodeKey) {
console.log(
receive verify-code event, id: ${id}, message: ${message}, scene: ${types.VerifyCodeScene[scene]} status: ${types.VerifyCodeStatus[status]}
)const verifyCode = '084356' // 通过一些途径输入验证码
try {
await bot.enterVerifyCode(id, verifyCode) // 如果没抛错,则说明输入成功,会推送登录事件
return
} catch (e) {
console.log((e as Error).message)
// 如果抛错,请根据 message 处理,目前发现可以输错3次,超过3次错误需要重新扫码。
// 错误关键词: 验证码错误输入错误,请重新输入
// 错误关键词:验证码错误次数超过阈值,请重新扫码'
// 目前不会推送 EXPIRED 事件,需要根据错误内容判断
}
}
}).on('login', user => {
console.log(
============================================ user: ${JSON.stringify(user)}, friend: ${user.friend()}, ${user.coworker()} ============================================
)}).on('message', message => {
console.log(
new message received: ${JSON.stringify(message)}
)}).on('error', err => {
console.log(err)
}).on('room-announce', (...args) => {
console.log(
room announce: ${JSON.stringify(args)}
)}).on('contact-alias', (...args) => {
console.log(
contact alias: ${JSON.stringify(args)}
)}).on('tag', (...args) => {
console.log(
tag: ${JSON.stringify(args)}
)})
The text was updated successfully, but these errors were encountered: