Skip to content

Commit

Permalink
Merge pull request #92 from juzibot/feat/event-login-url
Browse files Browse the repository at this point in the history
Feat/event login url
  • Loading branch information
hcfw007 authored Dec 5, 2024
2 parents 6f46265 + 3fb2291 commit bac4e46
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@juzi/wechaty",
"version": "1.0.103",
"version": "1.0.104",
"description": "Wechaty is a RPA SDK for Chatbot Makers.",
"type": "module",
"exports": {
Expand Down Expand Up @@ -132,7 +132,7 @@
"@chatie/eslint-config": "^1.0.4",
"@chatie/semver": "^0.4.7",
"@chatie/tsconfig": "^4.6.3",
"@juzi/wechaty-puppet": "1.0.94",
"@juzi/wechaty-puppet": "^1.0.98",
"@juzi/wechaty-puppet-mock": "^1.0.1",
"@swc/core": "1.3.44",
"@swc/helpers": "^0.3.6",
Expand Down
3 changes: 3 additions & 0 deletions src/schemas/wechaty-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ type WechatyEventListenerPostComment = (comment: PostInterface, post: Pos
type WechatyEventListenerPostTap = (post: PostInterface, contact: ContactInterface, type: PUPPET.types.Tap, tap: boolean, date?: Date) => void | Promise<void>
type WechatyEventListenerVerifyCode = (id: string, message: string, scene: PUPPET.types.VerifyCodeScene, status: PUPPET.types.VerifyCodeStatus) => void | Promise<void>
type WechatyEventListenerDirty = (id: string, type: PUPPET.types.Dirty) => void | Promise<void>
type WechatyEventListenerLoginUrl = (url: string) => void | Promise<void>

/**
* @desc Wechaty Class Event Type
Expand Down Expand Up @@ -259,6 +260,7 @@ interface WechatyEventListeners {
'post-tap' : WechatyEventListenerPostTap
'verify-code' : WechatyEventListenerVerifyCode
'dirty' : WechatyEventListenerDirty
'login-url' : WechatyEventListenerLoginUrl
}

const WechatyEventEmitter = EventEmitter as any as new () => TypedEventEmitter<
Expand Down Expand Up @@ -300,6 +302,7 @@ export type {
WechatyEventListenerPostTap,
WechatyEventListenerVerifyCode,
WechatyEventListenerDirty,
WechatyEventListenerLoginUrl,
}
export {
WechatyEventEmitter,
Expand Down
6 changes: 6 additions & 0 deletions src/wechaty-mixins/puppet-mixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,12 @@ const puppetMixin = <MixinBase extends WechatifyUserModuleMixin & GErrorMixin &
})
break

case 'login-url':
puppet.on('login-url', (payload) => {
this.emit('login-url', payload.url)
})
break

default:
/**
* Check: The eventName here should have the type `never`
Expand Down

0 comments on commit bac4e46

Please sign in to comment.