提交 e64f0e70 编写于 作者: Huan (李卓桓)'s avatar Huan (李卓桓)

rename qrCode to qrcode

上级 f9bf6d8a
......@@ -73,8 +73,8 @@ bot
log.info('Bot', `${user.name()} login`)
bot.say('Wechaty login').catch(console.error)
})
.on('scan', (qrData, status, data) => {
QrcodeTerminal.generate(qrData, { small: true }, (asciiArt: string) => {
.on('scan', (qrcode, status, data) => {
QrcodeTerminal.generate(qrcode, { small: true }, (asciiArt: string) => {
console.log(asciiArt)
console.log(`[${status}] Scan QR Code above url to log in: `)
if (data) {
......
......@@ -75,9 +75,9 @@ bot
log.info('Bot', `${user.name()} login`)
bot.say('Wechaty login').catch(console.error)
})
.on('scan', (qrData, status, data) => {
QrcodeTerminal.generate(qrData, { small: true }, (asciiArt: string) => {
console.log(asciiArt)
.on('scan', (qrcode, status, data) => {
QrcodeTerminal.generate(qrcode, { small: true }, (asciiart: string) => {
console.log(asciiart)
console.log(`[${status}] Scan QR Code above url to log in: `)
if (data) {
console.log(data)
......
......@@ -637,7 +637,7 @@ export class ContactSelf extends Contact {
throw new Error('only can get qrcode for the login userself')
}
return await this.puppet.contactQrCode(this.id)
return await this.puppet.contactQrcode(this.id)
}
}
......
......@@ -153,7 +153,7 @@ export class PuppetMock extends Puppet {
return []
}
public async contactQrCode(contactId: string): Promise<string> {
public async contactQrcode(contactId: string): Promise<string> {
if (contactId !== this.selfId()) {
throw new Error('can not set avatar for others')
}
......@@ -352,7 +352,7 @@ export class PuppetMock extends Puppet {
log.verbose('PuppetMock', 'roomQuit(%s)', roomId)
}
public async roomQrCode(roomId: string): Promise<string> {
public async roomQrcode(roomId: string): Promise<string> {
return roomId + ' mock qrcode'
}
......
......@@ -45,7 +45,7 @@ export class Bridge extends PadchatRpc {
// private readonly padchatRpc : PadchatRpc
private autoData : AutoDataType
private loginScanQrCode? : string
private loginScanQrcode? : string
private loginScanStatus? : number
private loginTimer?: NodeJS.Timer
......@@ -189,7 +189,7 @@ export class Bridge extends PadchatRpc {
this.releaseCache()
this.selfId = undefined
this.loginScanQrCode = undefined
this.loginScanQrcode = undefined
this.state.off(true)
}
......@@ -231,7 +231,7 @@ export class Bridge extends PadchatRpc {
clearTimeout(this.loginTimer)
this.loginTimer = undefined
}
this.loginScanQrCode = undefined
this.loginScanQrcode = undefined
this.loginScanStatus = undefined
}
......@@ -257,11 +257,11 @@ export class Bridge extends PadchatRpc {
// const result = await this.padchatRpc.WXCheckQRCode()
const result = await this.WXCheckQRCode()
if (this.loginScanStatus !== result.status && this.loginScanQrCode) {
if (this.loginScanStatus !== result.status && this.loginScanQrcode) {
this.loginScanStatus = result.status
this.emit(
'scan',
this.loginScanQrCode,
this.loginScanQrcode,
this.loginScanStatus,
)
}
......@@ -269,7 +269,7 @@ export class Bridge extends PadchatRpc {
if (result.expired_time && result.expired_time < 10) {
// result.expire_time is second
// emit new qrcode before the old one expired
this.loginScanQrCode = undefined
this.loginScanQrcode = undefined
this.loginScanStatus = undefined
waitUserResponse = false
continue
......@@ -311,21 +311,21 @@ export class Bridge extends PadchatRpc {
case WXCheckQRCodeStatus.Timeout:
log.silly('PuppetPadchatBridge', 'checkQrcode: Timeout')
this.loginScanQrCode = undefined
this.loginScanQrcode = undefined
this.loginScanStatus = undefined
waitUserResponse = false
break
case WXCheckQRCodeStatus.Cancel:
log.silly('PuppetPadchatBridge', 'user cancel')
this.loginScanQrCode = undefined
this.loginScanQrcode = undefined
this.loginScanStatus = undefined
waitUserResponse = false
break
default:
log.warn('PadchatBridge', 'startLogin() unknown WXCheckQRCodeStatus: ' + result.status)
this.loginScanQrCode = undefined
this.loginScanQrcode = undefined
this.loginScanStatus = undefined
waitUserResponse = false
break
......@@ -334,7 +334,7 @@ export class Bridge extends PadchatRpc {
await new Promise(r => setTimeout(r, 1000))
}
await this.emitLoginQrCode()
await this.emitLoginQrcode()
this.loginTimer = setTimeout(() => {
this.loginTimer = undefined
this.startLogin()
......@@ -401,7 +401,7 @@ export class Bridge extends PadchatRpc {
/**
* 1. No Auto Login, emit QrCode for scan
*/
await this.emitLoginQrCode()
await this.emitLoginQrcode()
return false
}
......@@ -423,7 +423,7 @@ export class Bridge extends PadchatRpc {
/**
* 3.1 Login Request Not Valid, emit QrCode for scan.
*/
await this.emitLoginQrCode()
await this.emitLoginQrcode()
return false
} else {
......@@ -435,10 +435,10 @@ export class Bridge extends PadchatRpc {
}
}
protected async emitLoginQrCode(): Promise<void> {
protected async emitLoginQrcode(): Promise<void> {
log.verbose('PuppetPadchatBridge', `emitLoginQrCode()`)
if (this.loginScanQrCode) {
if (this.loginScanQrcode) {
throw new Error('qrcode exist')
}
......@@ -450,17 +450,17 @@ export class Bridge extends PadchatRpc {
await this.WXInitialize()
// wait 1 second and try again
await new Promise(r => setTimeout(r, 1000))
return await this.emitLoginQrCode()
return await this.emitLoginQrcode()
}
const qrCodeText = await pfHelper.imageBase64ToQrCode(result.qr_code)
this.loginScanQrCode = qrCodeText
this.loginScanQrcode = qrCodeText
this.loginScanStatus = WXCheckQRCodeStatus.WaitScan
this.emit(
'scan',
this.loginScanQrCode,
this.loginScanQrcode,
this.loginScanStatus,
)
......
......@@ -348,7 +348,7 @@ export class PuppetPadchat extends Puppet {
return fileBox
}
public async contactQrCode(contactId: string): Promise<string> {
public async contactQrcode(contactId: string): Promise<string> {
if (contactId !== this.selfId()) {
throw new Error('can not set avatar for others')
}
......@@ -570,7 +570,7 @@ export class PuppetPadchat extends Puppet {
await this.bridge.WXDeleteChatRoomMember(roomId, contactId)
}
public async roomQrCode(roomId: string): Promise<string> {
public async roomQrcode(roomId: string): Promise<string> {
log.verbose('PuppetPadchat', 'roomQrCode(%s)', roomId)
// TODO
......
......@@ -775,7 +775,7 @@ export class PuppetPuppeteer extends Puppet {
}
}
public async contactQrCode(contactId: string): Promise<string> {
public async contactQrcode(contactId: string): Promise<string> {
if (contactId !== this.selfId()) {
throw new Error('can not set avatar for others')
}
......@@ -1088,7 +1088,7 @@ export class PuppetPuppeteer extends Puppet {
log.warn('PuppetPuppeteer', 'roomQuit(%s) not supported by Web API', roomId)
}
public async roomQrCode(roomId: string): Promise<string> {
public async roomQrcode(roomId: string): Promise<string> {
throw new Error('not support ' + roomId)
}
......
......@@ -316,7 +316,7 @@ export class PuppetWechat4u extends Puppet {
return idList
}
public async contactQrCode(contactId: string): Promise<string> {
public async contactQrcode(contactId: string): Promise<string> {
if (contactId !== this.selfId()) {
throw new Error('can not set avatar for others')
}
......@@ -830,7 +830,7 @@ export class PuppetWechat4u extends Puppet {
log.verbose('PuppetWechat4u', 'roomQuit(%s)', roomId)
}
public async roomQrCode(roomId: string): Promise<string> {
public async roomQrcode(roomId: string): Promise<string> {
throw new Error('not support ' + roomId)
}
......
......@@ -58,7 +58,7 @@ class PuppetTest extends Puppet {
public async contactAvatar(contactId: string, file?: FileBox) : Promise<void | FileBox> { return {contactId, file} as any }
public async contactList() : Promise<string[]> { return {} as any }
public async contactQrCode(contactId: string) : Promise<string> { return {contactId} as any }
public async contactQrcode(contactId: string) : Promise<string> { return {contactId} as any }
public async contactRawPayload(id: string) : Promise<any> { return {id} as any }
public async contactRawPayloadParser(rawPayload: any) : Promise<ContactPayload> { return {rawPayload} as any }
......@@ -101,7 +101,7 @@ class PuppetTest extends Puppet {
public async roomCreate(contactIdList: string[], topic?: string) : Promise<string> { return {contactIdList, topic} as any }
public async roomDel(roomId: string, contactId: string) : Promise<void> { return {roomId, contactId} as any }
public async roomQuit(roomId: string) : Promise<void> { return {roomId} as any }
public async roomQrCode(roomId: string) : Promise<string> { return {roomId} as any }
public async roomQrcode(roomId: string) : Promise<string> { return {roomId} as any }
public async roomTopic(roomId: string) : Promise<string>
public async roomTopic(roomId: string, topic: string) : Promise<void>
......
......@@ -181,7 +181,7 @@ export abstract class Puppet extends EventEmitter implements Sayable {
public emit(event: 'room-join', roomId: string, inviteeIdList: string[], inviterId: string) : boolean
public emit(event: 'room-leave', roomId: string, leaverIdList: string[], remover?: string) : boolean
public emit(event: 'room-topic', roomId: string, topic: string, oldTopic: string, changerId: string) : boolean
public emit(event: 'scan', qrCode: string, status: number, data?: string) : boolean
public emit(event: 'scan', qrcode: string, status: number, data?: string) : boolean
public emit(event: 'start') : boolean
public emit(event: 'stop') : boolean
// Internal Usage: watchdog
......@@ -211,7 +211,7 @@ export abstract class Puppet extends EventEmitter implements Sayable {
public on(event: 'room-join', listener: (roomId: string, inviteeIdList: string[], inviterId: string) => void) : this
public on(event: 'room-leave', listener: (roomId: string, leaverIdList : string[], removerId?: string) => void) : this
public on(event: 'room-topic', listener: (roomId: string, topic: string, oldTopic: string, changerId: string) => void) : this
public on(event: 'scan', listener: (qrCode: string, status: number, data?: string) => void) : this
public on(event: 'scan', listener: (qrcode: string, status: number, data?: string) => void) : this
public on(event: 'start', listener: () => void) : this
public on(event: 'stop', listener: () => void) : this
// Internal Usage: watchdog
......@@ -361,7 +361,7 @@ export abstract class Puppet extends EventEmitter implements Sayable {
public abstract async contactList() : Promise<string[]>
public abstract async contactQrCode(contactId: string) : Promise<string>
public abstract async contactQrcode(contactId: string) : Promise<string>
public abstract async contactRawPayload(contactId: string) : Promise<any>
public abstract async contactRawPayloadParser(rawPayload: any) : Promise<ContactPayload>
......@@ -634,7 +634,7 @@ export abstract class Puppet extends EventEmitter implements Sayable {
public abstract async roomTopic(roomId: string, topic: string) : Promise<void>
public abstract async roomTopic(roomId: string, topic?: string) : Promise<string | void>
public abstract async roomQrCode(roomId: string) : Promise<string>
public abstract async roomQrcode(roomId: string) : Promise<string>
public abstract async roomList() : Promise<string[]>
public abstract async roomMemberList(roomId: string) : Promise<string[]>
......
......@@ -254,7 +254,7 @@ export class Wechaty extends Accessory implements Sayable {
public emit(event: 'room-join' , room: Room, inviteeList : Contact[], inviter : Contact) : boolean
public emit(event: 'room-leave' , room: Room, leaverList : Contact[], remover? : Contact) : boolean
public emit(event: 'room-topic' , room: Room, topic: string, oldTopic: string, changer: Contact) : boolean
public emit(event: 'scan' , qrData: string, status: number, data?: string) : boolean
public emit(event: 'scan' , qrcode: string, status: number, data?: string) : boolean
public emit(event: 'start') : boolean
public emit(event: 'stop') : boolean
......@@ -277,7 +277,7 @@ export class Wechaty extends Accessory implements Sayable {
public on(event: 'room-join' , listener: string | ((this: Wechaty, room: Room, inviteeList: Contact[], inviter: Contact) => void)) : this
public on(event: 'room-leave' , listener: string | ((this: Wechaty, room: Room, leaverList: Contact[], remover?: Contact) => void)) : this
public on(event: 'room-topic' , listener: string | ((this: Wechaty, room: Room, topic: string, oldTopic: string, changer: Contact) => void)) : this
public on(event: 'scan' , listener: string | ((this: Wechaty, qrData: string, status: number, data?: string) => void)) : this
public on(event: 'scan' , listener: string | ((this: Wechaty, qrcode: string, status: number, data?: string) => void)) : this
public on(event: 'start' , listener: string | ((this: Wechaty) => void)) : this
public on(event: 'stop' , listener: string | ((this: Wechaty) => void)) : this
......@@ -643,8 +643,8 @@ export class Wechaty extends Accessory implements Sayable {
case 'scan':
puppet.removeAllListeners('scan')
puppet.on('scan', async (qrCode, statusCode, data) => {
this.emit('scan', qrCode, statusCode, data)
puppet.on('scan', async (qrcode, status, data) => {
this.emit('scan', qrcode, status, data)
})
break
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册