@juzi/wechaty 1.0.74 → 1.0.76

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/cjs/src/package-json.js +3 -3
  2. package/dist/cjs/src/schemas/wechaty-events.d.ts +4 -1
  3. package/dist/cjs/src/schemas/wechaty-events.d.ts.map +1 -1
  4. package/dist/cjs/src/schemas/wechaty-events.js.map +1 -1
  5. package/dist/cjs/src/user-modules/message.d.ts.map +1 -1
  6. package/dist/cjs/src/user-modules/message.js +11 -0
  7. package/dist/cjs/src/user-modules/message.js.map +1 -1
  8. package/dist/cjs/src/wechaty/wechaty-base.d.ts +7 -7
  9. package/dist/cjs/src/wechaty-mixins/gerror-mixin.d.ts +1 -1
  10. package/dist/cjs/src/wechaty-mixins/io-mixin.d.ts +2 -2
  11. package/dist/cjs/src/wechaty-mixins/login-mixin.d.ts +5 -5
  12. package/dist/cjs/src/wechaty-mixins/misc-mixin.d.ts +5 -5
  13. package/dist/cjs/src/wechaty-mixins/plugin-mixin.d.ts +6 -6
  14. package/dist/cjs/src/wechaty-mixins/puppet-mixin.d.ts +4 -4
  15. package/dist/cjs/src/wechaty-mixins/puppet-mixin.d.ts.map +1 -1
  16. package/dist/cjs/src/wechaty-mixins/puppet-mixin.js +3 -2
  17. package/dist/cjs/src/wechaty-mixins/puppet-mixin.js.map +1 -1
  18. package/dist/cjs/src/wechaty-mixins/wechatify-user-module-mixin.d.ts +1 -1
  19. package/dist/esm/src/package-json.js +3 -3
  20. package/dist/esm/src/schemas/wechaty-events.d.ts +4 -1
  21. package/dist/esm/src/schemas/wechaty-events.d.ts.map +1 -1
  22. package/dist/esm/src/schemas/wechaty-events.js.map +1 -1
  23. package/dist/esm/src/user-modules/message.d.ts.map +1 -1
  24. package/dist/esm/src/user-modules/message.js +11 -0
  25. package/dist/esm/src/user-modules/message.js.map +1 -1
  26. package/dist/esm/src/wechaty/wechaty-base.d.ts +7 -7
  27. package/dist/esm/src/wechaty-mixins/gerror-mixin.d.ts +1 -1
  28. package/dist/esm/src/wechaty-mixins/io-mixin.d.ts +2 -2
  29. package/dist/esm/src/wechaty-mixins/login-mixin.d.ts +5 -5
  30. package/dist/esm/src/wechaty-mixins/misc-mixin.d.ts +5 -5
  31. package/dist/esm/src/wechaty-mixins/plugin-mixin.d.ts +6 -6
  32. package/dist/esm/src/wechaty-mixins/puppet-mixin.d.ts +4 -4
  33. package/dist/esm/src/wechaty-mixins/puppet-mixin.d.ts.map +1 -1
  34. package/dist/esm/src/wechaty-mixins/puppet-mixin.js +3 -2
  35. package/dist/esm/src/wechaty-mixins/puppet-mixin.js.map +1 -1
  36. package/dist/esm/src/wechaty-mixins/wechatify-user-module-mixin.d.ts +1 -1
  37. package/package.json +2 -2
  38. package/src/package-json.ts +3 -3
  39. package/src/schemas/wechaty-events.ts +3 -0
  40. package/src/user-modules/message.ts +12 -0
  41. package/src/wechaty-mixins/puppet-mixin.ts +3 -2
@@ -4,10 +4,10 @@
4
4
  */
5
5
  import type { PackageJsonWechaty } from './config'
6
6
 
7
- export const GIT_COMMIT_HASH: string = '3850af2e7b8bad84a369ff57a1107186e89c215b'
7
+ export const GIT_COMMIT_HASH: string = 'a79ec2aabc32f13210589c11831a41e5368cfef6'
8
8
  export const packageJson: PackageJsonWechaty = {
9
9
  "name": "@juzi/wechaty",
10
- "version": "1.0.74",
10
+ "version": "1.0.76",
11
11
  "description": "Wechaty is a RPA SDK for Chatbot Makers.",
12
12
  "type": "module",
13
13
  "exports": {
@@ -139,7 +139,7 @@ export const packageJson: PackageJsonWechaty = {
139
139
  "@chatie/eslint-config": "^1.0.4",
140
140
  "@chatie/semver": "^0.4.7",
141
141
  "@chatie/tsconfig": "^4.6.3",
142
- "@juzi/wechaty-puppet": "^1.0.66",
142
+ "@juzi/wechaty-puppet": "^1.0.68",
143
143
  "@juzi/wechaty-puppet-mock": "^1.0.1",
144
144
  "@swc/core": "1.3.44",
145
145
  "@swc/helpers": "^0.3.6",
@@ -73,6 +73,7 @@ type WechatyEventListenerTagGroup = (type: PUPPET.types.TagGroupEvent,
73
73
  type WechatyEventListenerPostComment = (comment: PostInterface, post: PostInterface) => void | Promise<void>
74
74
  type WechatyEventListenerPostTap = (post: PostInterface, contact: ContactInterface, type: PUPPET.types.Tap, tap: boolean, date?: Date) => void | Promise<void>
75
75
  type WechatyEventListenerVerifyCode = (id: string, message: string, scene: PUPPET.types.VerifyCodeScene, status: PUPPET.types.VerifyCodeStatus) => void | Promise<void>
76
+ type WechatyEventListenerDirty = (id: string, type: PUPPET.types.Dirty) => void | Promise<void>
76
77
 
77
78
  /**
78
79
  * @desc Wechaty Class Event Type
@@ -261,6 +262,7 @@ interface WechatyEventListeners {
261
262
  'post-comment' : WechatyEventListenerPostComment
262
263
  'post-tap' : WechatyEventListenerPostTap
263
264
  'verify-code' : WechatyEventListenerVerifyCode
265
+ 'dirty' : WechatyEventListenerDirty
264
266
  }
265
267
 
266
268
  const WechatyEventEmitter = EventEmitter as any as new () => TypedEventEmitter<
@@ -302,6 +304,7 @@ export type {
302
304
  WechatyEventListenerPostComment,
303
305
  WechatyEventListenerPostTap,
304
306
  WechatyEventListenerVerifyCode,
307
+ WechatyEventListenerDirty,
305
308
  }
306
309
  export {
307
310
  WechatyEventEmitter,
@@ -117,6 +117,18 @@ class MessageMixin extends MixinBase implements SayableSayer {
117
117
  ): Promise<undefined | MessageInterface> {
118
118
  log.verbose('Message', 'find(%s)', JSON.stringify(query))
119
119
 
120
+ if (typeof query === 'object' && query.id) {
121
+ const message = this.load(query.id)
122
+ try {
123
+ await message.ready()
124
+ } catch (e) {
125
+ this.wechaty.emitError(e)
126
+ return undefined
127
+ }
128
+
129
+ return message
130
+ }
131
+
120
132
  if (typeof query === 'string') {
121
133
  query = { text: query }
122
134
  }
@@ -649,7 +649,7 @@ const puppetMixin = <MixinBase extends WechatifyUserModuleMixin & GErrorMixin &
649
649
  const differences = diffPayload<PUPPET.payloads.Contact>(oldPayload, newPayload)
650
650
  if (differences.length === 0) {
651
651
  log.info('WechatyPuppetMixin', `got dirty for contact ${payloadId} but cannot find any difference. old payload: ${JSON.stringify(oldPayload)}, new payload: ${JSON.stringify(newPayload)}`)
652
- return
652
+ break
653
653
  }
654
654
 
655
655
  const importantDifferences = differences.filter(ele => ele && ContactImportantFields.some(key => key === ele.key))
@@ -721,7 +721,7 @@ const puppetMixin = <MixinBase extends WechatifyUserModuleMixin & GErrorMixin &
721
721
 
722
722
  if (differences.length === 0) {
723
723
  log.info('WechatyPuppetMixin', `got dirty for room ${payloadId} but cannot find any difference. old payload: ${JSON.stringify(oldPayload)}, new payload: ${JSON.stringify(newPayload)}`)
724
- return
724
+ break
725
725
  }
726
726
 
727
727
  const importantDifferences = differences.filter(ele => ele && RoomImportantFields.some(key => key === ele.key))
@@ -778,6 +778,7 @@ const puppetMixin = <MixinBase extends WechatifyUserModuleMixin & GErrorMixin &
778
778
  default:
779
779
  throw new Error('unknown payload type: ' + payloadType)
780
780
  }
781
+ this.emit('dirty', payloadId, payloadType)
781
782
  } catch (e) {
782
783
  this.emit('error', GError.from(e))
783
784
  }