Skip to content

Commit

Permalink
Merge pull request #91 from juzibot/feat/room-dynamic-qrcode
Browse files Browse the repository at this point in the history
Feat/room dynamic qrcode
  • Loading branch information
su-chang authored Nov 15, 2024
2 parents 7bd906a + 5108320 commit b7522d6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 18 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@juzi/wechaty",
"version": "1.0.101",
"version": "1.0.102",
"description": "Wechaty is a RPA SDK for Chatbot Makers.",
"type": "module",
"exports": {
Expand Down
17 changes: 9 additions & 8 deletions src/user-modules/room-invitation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ class RoomInvitationMixin extends wechatifyMixinBase() implements Accepter {
return newRoomInvitation
}

static async acceptByQRCode (qrcode: string): Promise<PUPPET.types.RoomInvitationAcceptByQRCode> {
if (!qrcode) {
throw new Error('acceptByQRCode() qrcode is required')
}
return this.wechaty.puppet.roomInvitationAcceptByQRCode(qrcode)
}

/**
* @hideconstructor
* Instance Properties
Expand Down Expand Up @@ -85,8 +92,6 @@ class RoomInvitationMixin extends wechatifyMixinBase() implements Accepter {
].join('')
}

async accept () : Promise<void>
async accept (qrcode: string) : Promise<PUPPET.types.RoomInvitationAcceptByQRCode>
/**
* Accept Room Invitation
*
Expand All @@ -104,15 +109,11 @@ class RoomInvitationMixin extends wechatifyMixinBase() implements Accepter {
* }
* .start()
*/
async accept (qrcode?: string): Promise<void | PUPPET.types.RoomInvitationAcceptByQRCode> {
async accept (): Promise<void> {
log.verbose('RoomInvitation', 'accept()')

try {
if (qrcode) {
return this.wechaty.puppet.roomInvitationAcceptByQRCode(qrcode)
} else {
await this.wechaty.puppet.roomInvitationAccept(this.id)
}
await this.wechaty.puppet.roomInvitationAccept(this.id)

const inviter = await this.inviter()
const topic = await this.topic()
Expand Down
22 changes: 13 additions & 9 deletions src/user-modules/room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,19 @@ class RoomMixin extends MixinBase implements SayableSayer {
}
}

/**
* Parse the dynamic QR Code of the room
* @param {string} url
* @returns {Promise<PUPPET.types.RoomParseDynamicQRCode>}
*/
static async parseDynamicQRCode (url: string): Promise<PUPPET.types.RoomParseDynamicQRCode> {
log.info('Room', 'parseDynamicQRCode(%s)', url)
if (!url) {
throw new Error('parseDynamicQRCode() url is required')
}
return this.wechaty.puppet.roomParseDynamicQRCode(url)
}

/**
* The filter to find the room: {topic: string | RegExp}
*
Expand Down Expand Up @@ -968,15 +981,6 @@ class RoomMixin extends MixinBase implements SayableSayer {
return guardQrCodeValue(qrcodeValue)
}

/**
* Parse the dynamic QR Code of the room
* @param {string} url
* @returns {Promise<PUPPET.types.RoomParseDynamicQRCode>}
*/
async parseDynamicQRCode (url: string): Promise<PUPPET.types.RoomParseDynamicQRCode> {
return this.wechaty.puppet.roomParseDynamicQRCode(url)
}

/**
* Return contact's roomAlias in the room
* @param {ContactInterface} contact
Expand Down

0 comments on commit b7522d6

Please sign in to comment.