@juzi/wechaty 1.0.129 → 1.0.131

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 (43) hide show
  1. package/dist/cjs/src/package-json.js +3 -3
  2. package/dist/cjs/src/schemas/contact-events.d.ts +8 -1
  3. package/dist/cjs/src/schemas/contact-events.d.ts.map +1 -1
  4. package/dist/cjs/src/schemas/contact-events.js.map +1 -1
  5. package/dist/cjs/src/schemas/wechaty-events.d.ts +10 -25
  6. package/dist/cjs/src/schemas/wechaty-events.d.ts.map +1 -1
  7. package/dist/cjs/src/schemas/wechaty-events.js +0 -8
  8. package/dist/cjs/src/schemas/wechaty-events.js.map +1 -1
  9. package/dist/cjs/src/wechaty/wechaty-base.d.ts +7 -7
  10. package/dist/cjs/src/wechaty-mixins/gerror-mixin.d.ts +1 -1
  11. package/dist/cjs/src/wechaty-mixins/io-mixin.d.ts +2 -2
  12. package/dist/cjs/src/wechaty-mixins/login-mixin.d.ts +5 -5
  13. package/dist/cjs/src/wechaty-mixins/misc-mixin.d.ts +5 -5
  14. package/dist/cjs/src/wechaty-mixins/plugin-mixin.d.ts +6 -6
  15. package/dist/cjs/src/wechaty-mixins/puppet-mixin.d.ts +4 -4
  16. package/dist/cjs/src/wechaty-mixins/puppet-mixin.d.ts.map +1 -1
  17. package/dist/cjs/src/wechaty-mixins/puppet-mixin.js +27 -0
  18. package/dist/cjs/src/wechaty-mixins/puppet-mixin.js.map +1 -1
  19. package/dist/cjs/src/wechaty-mixins/wechatify-user-module-mixin.d.ts +1 -1
  20. package/dist/esm/src/package-json.js +3 -3
  21. package/dist/esm/src/schemas/contact-events.d.ts +8 -1
  22. package/dist/esm/src/schemas/contact-events.d.ts.map +1 -1
  23. package/dist/esm/src/schemas/contact-events.js.map +1 -1
  24. package/dist/esm/src/schemas/wechaty-events.d.ts +10 -25
  25. package/dist/esm/src/schemas/wechaty-events.d.ts.map +1 -1
  26. package/dist/esm/src/schemas/wechaty-events.js +0 -8
  27. package/dist/esm/src/schemas/wechaty-events.js.map +1 -1
  28. package/dist/esm/src/wechaty/wechaty-base.d.ts +7 -7
  29. package/dist/esm/src/wechaty-mixins/gerror-mixin.d.ts +1 -1
  30. package/dist/esm/src/wechaty-mixins/io-mixin.d.ts +2 -2
  31. package/dist/esm/src/wechaty-mixins/login-mixin.d.ts +5 -5
  32. package/dist/esm/src/wechaty-mixins/misc-mixin.d.ts +5 -5
  33. package/dist/esm/src/wechaty-mixins/plugin-mixin.d.ts +6 -6
  34. package/dist/esm/src/wechaty-mixins/puppet-mixin.d.ts +4 -4
  35. package/dist/esm/src/wechaty-mixins/puppet-mixin.d.ts.map +1 -1
  36. package/dist/esm/src/wechaty-mixins/puppet-mixin.js +27 -0
  37. package/dist/esm/src/wechaty-mixins/puppet-mixin.js.map +1 -1
  38. package/dist/esm/src/wechaty-mixins/wechatify-user-module-mixin.d.ts +1 -1
  39. package/package.json +2 -2
  40. package/src/package-json.ts +3 -3
  41. package/src/schemas/contact-events.ts +5 -0
  42. package/src/schemas/wechaty-events.ts +6 -32
  43. package/src/wechaty-mixins/puppet-mixin.ts +33 -0
@@ -25,14 +25,6 @@ const WECHATY_EVENT_DICT = {
25
25
  ready : 'All underlined data source are ready for use.',
26
26
  start : 'Will be emitted after the Wechaty had been started.',
27
27
  stop : 'Will be emitted after the Wechaty had been stopped.',
28
- 'contact-tag-add' : 'Will be emitted when contact has new tags.',
29
- 'contact-tag-remove' : 'Will be emitted when contact has some tags removed.',
30
- 'contact-name' : 'Will be emitted when contact name has been changed.',
31
- 'contact-alias' : 'Will be emitted when contact alias has been changed.',
32
- 'contact-phone' : 'Will be emitted when contact phone has been changed.',
33
- 'contact-description': 'Will be emitted when contact description has been changed.',
34
- 'contact-corporation': 'Will be emitted when contact corporation has been changed.',
35
- 'room-owner' : 'Will be emitted when room owner has been changed.',
36
28
  } as const
37
29
 
38
30
  type WechatyEventName = keyof typeof WECHATY_EVENT_DICT
@@ -55,16 +47,8 @@ type WechatyEventListenerRoomJoin = (room: RoomInterface, inviteeList:
55
47
  type WechatyEventListenerRoomLeave = (room: RoomInterface, leaverList: ContactInterface[], remover?: ContactInterface, date?: Date) => void | Promise<void>
56
48
  type WechatyEventListenerRoomTopic = (room: RoomInterface, newTopic: string, oldTopic: string, changer: ContactInterface, date?: Date) => void | Promise<void>
57
49
  type WechatyEventListenerRoomAnnounce = (room: RoomInterface, newAnnounce: string, changer?: ContactInterface, oldAnnounce?: string, date?: Date) => void | Promise<void>
58
- type WechatyEventListenerRoomOwner = (room: RoomInterface, newOwner: ContactInterface, oldOwner: ContactInterface) => void | Promise<void>
59
50
  type WechatyEventListenerScan = (qrcode: string, status: PUPPET.types.ScanStatus, data: string, type: PUPPET.types.ScanType, createDate: Date, expireDate?: Date) => void | Promise<void>
60
51
  type WechatyEventListenerStartStop = () => void | Promise<void>
61
- type WechatyEventListenerContactTagAdd = (contact: ContactInterface, tagList: TagInterface[]) => void | Promise<void>
62
- type WechatyEventListenerContactTagRemove = (contact: ContactInterface, tagList: TagInterface[]) => void | Promise<void>
63
- type WechatyEventListenerContactName = (contact: ContactInterface, newName: string, oldName: string) => void | Promise<void>
64
- type WechatyEventListenerContactPhone = (contact: ContactInterface, newPhoneList: string[], oldPhoneList: []) => void | Promise<void>
65
- type WechatyEventListenerContactAlias = (contact: ContactInterface, newAlias: string, oldAlias: string) => void | Promise<void>
66
- type WechatyEventListenerContactDescription = (contact: ContactInterface, newDescription: string, oldDescription: string) => void | Promise<void>
67
- type WechatyEventListenerContactCorporation = (contact: ContactInterface, newCorporation: string, oldCorporation: string) => void | Promise<void>
68
52
  type WechatyEventListenerTag = (type: PUPPET.types.TagEvent, list: TagInterface[], date?: Date) => void | Promise<void>
69
53
  type WechatyEventListenerTagGroup = (type: PUPPET.types.TagGroupEvent, list: TagGroupInterface[], date?: Date) => void | Promise<void>
70
54
  type WechatyEventListenerPostComment = (comment: PostInterface, post: PostInterface) => void | Promise<void>
@@ -74,6 +58,8 @@ type WechatyEventListenerVerifySlide = (scene: PUPPET.types.VerifySlideSc
74
58
  type WechatyEventListenerDirty = (id: string, type: PUPPET.types.Dirty) => void | Promise<void>
75
59
  type WechatyEventListenerLoginUrl = (url: string) => void | Promise<void>
76
60
  type WechatyEventListenerIntentComment = (payload: PUPPET.payloads.IntentComment) => void | Promise<void>
61
+ type WechatyEventListenerContactEnterConversation = (contact: ContactInterface, date?: Date) => void | Promise<void>
62
+ type WechatyEventListenerContactLeadFilled = (contact: ContactInterface, leads: { name: string, value: string }[], date?: Date) => void | Promise<void>
77
63
 
78
64
  /**
79
65
  * @desc Wechaty Class Event Type
@@ -248,14 +234,6 @@ interface WechatyEventListeners {
248
234
  scan : WechatyEventListenerScan
249
235
  start : WechatyEventListenerStartStop
250
236
  stop : WechatyEventListenerStartStop
251
- 'contact-tag-add' : WechatyEventListenerContactTagAdd
252
- 'contact-tag-remove' : WechatyEventListenerContactTagRemove
253
- 'contact-name' : WechatyEventListenerContactName
254
- 'contact-alias' : WechatyEventListenerContactAlias
255
- 'contact-phone' : WechatyEventListenerContactPhone
256
- 'contact-description': WechatyEventListenerContactDescription
257
- 'contact-corporation': WechatyEventListenerContactCorporation
258
- 'room-owner' : WechatyEventListenerRoomOwner
259
237
  'tag' : WechatyEventListenerTag
260
238
  'tag-group' : WechatyEventListenerTagGroup
261
239
  'post-comment' : WechatyEventListenerPostComment
@@ -265,6 +243,8 @@ interface WechatyEventListeners {
265
243
  'login-url' : WechatyEventListenerLoginUrl
266
244
  'intent-comment' : WechatyEventListenerIntentComment
267
245
  'verify-slide' : WechatyEventListenerVerifySlide
246
+ 'contact-enter-conversation' : WechatyEventListenerContactEnterConversation
247
+ 'contact-lead-filled' : WechatyEventListenerContactLeadFilled
268
248
  }
269
249
 
270
250
  const WechatyEventEmitter = EventEmitter as any as new () => TypedEventEmitter<
@@ -289,17 +269,9 @@ export type {
289
269
  WechatyEventListenerRoomJoin,
290
270
  WechatyEventListenerRoomLeave,
291
271
  WechatyEventListenerRoomTopic,
292
- WechatyEventListenerRoomOwner,
293
272
  WechatyEventListenerRoomAnnounce,
294
273
  WechatyEventListenerScan,
295
274
  WechatyEventListenerStartStop,
296
- WechatyEventListenerContactTagAdd,
297
- WechatyEventListenerContactTagRemove,
298
- WechatyEventListenerContactName,
299
- WechatyEventListenerContactAlias,
300
- WechatyEventListenerContactPhone,
301
- WechatyEventListenerContactDescription,
302
- WechatyEventListenerContactCorporation,
303
275
  WechatyEventListenerTag,
304
276
  WechatyEventListenerTagGroup,
305
277
  WechatyEventListenerPostComment,
@@ -309,6 +281,8 @@ export type {
309
281
  WechatyEventListenerDirty,
310
282
  WechatyEventListenerLoginUrl,
311
283
  WechatyEventListenerIntentComment,
284
+ WechatyEventListenerContactEnterConversation,
285
+ WechatyEventListenerContactLeadFilled,
312
286
  }
313
287
  export {
314
288
  WechatyEventEmitter,
@@ -652,6 +652,39 @@ const puppetMixin = <MixinBase extends WechatifyUserModuleMixin & GErrorMixin &
652
652
  })
653
653
  break
654
654
 
655
+ case 'contact-enter-conversation':
656
+ puppet.on('contact-enter-conversation', async (payload) => {
657
+ const contact = await this.Contact.find({ id: payload.contactId })
658
+ if (contact) {
659
+ const date = payload.timestamp ? timestampToDate(payload.timestamp) : undefined
660
+ this.emit('contact-enter-conversation', contact, date)
661
+ contact.emit('enter-conversation', date)
662
+ } else {
663
+ log.verbose('PuppetMixin',
664
+ '__setupPuppetEvents() contact-enter-conversation event contact not found for id: %s',
665
+ payload.contactId,
666
+ )
667
+ }
668
+ })
669
+ break
670
+
671
+ case 'contact-lead-filled':
672
+ puppet.on('contact-lead-filled', async (payload) => {
673
+ const contact = await this.Contact.find({ id: payload.contactId })
674
+ if (contact) {
675
+ const leads = payload.leads
676
+ const date = payload.timestamp ? timestampToDate(payload.timestamp) : undefined
677
+ this.emit('contact-lead-filled', contact, leads, date)
678
+ contact.emit('lead-filled', leads, date)
679
+ } else {
680
+ log.verbose('PuppetMixin',
681
+ '__setupPuppetEvents() contact-lead-filled event contact not found for id: %s',
682
+ payload.contactId,
683
+ )
684
+ }
685
+ })
686
+ break
687
+
655
688
  case 'reset':
656
689
  // Do not propagation `reset` event from puppet
657
690
  break