Skip to content

Commit

Permalink
Merge pull request #32 from juzibot/feat-contact-corp-event
Browse files Browse the repository at this point in the history
Feat contact corp event
  • Loading branch information
hcfw007 authored Oct 10, 2022
2 parents 1da8a04 + fd27fe0 commit 5b8aabb
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 2 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.30",
"version": "1.0.31",
"description": "Wechaty is a RPA SDK for Chatbot Makers.",
"type": "module",
"exports": {
Expand Down
3 changes: 3 additions & 0 deletions src/schemas/contact-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type ContactEventListenerTagAdd = (tagList: TagInterface[]) => void | Promise<vo
type ContactEventListenerTagRemove = (tagList: TagInterface[]) => void | Promise<void>
type ContactEventListenerName = (newName: string, oldName: string) => void | Promise<void>
type ContactEventListenerDescription = (newDescription: string, oldDescription: string) => void | Promise<void>
type ContactEventListenerCorporation = (newCorporation: string, oldCorporation: string) => void | Promise<void>
type ContactEventListenerPhone = (newPhoneList: string[], oldPhoneList: string[]) => void | Promise<void>
type ContactEventListenerAlias = (newAlias: string, oldAlias: string) => void | Promise<void>

Expand All @@ -27,6 +28,7 @@ interface ContactEventListeners {
'tag-remove': ContactEventListenerTagRemove,
name : ContactEventListenerName,
description : ContactEventListenerDescription,
corporation : ContactEventListenerCorporation,
phone : ContactEventListenerPhone,
alias : ContactEventListenerAlias,
}
Expand All @@ -44,6 +46,7 @@ export type {
ContactEventListenerTagRemove,
ContactEventListenerName,
ContactEventListenerDescription,
ContactEventListenerCorporation,
ContactEventListenerPhone,
ContactEventListenerAlias,
}
Expand Down
2 changes: 1 addition & 1 deletion src/schemas/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import * as PUPPET from '@juzi/wechaty-puppet'

export const ContactImportantFields = [
'name', 'tags', 'alias', 'phone', 'description',
'name', 'tags', 'alias', 'phone', 'description', 'corporation',
] as const

export const RoomImportantFields = [
Expand Down
4 changes: 4 additions & 0 deletions src/schemas/wechaty-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const WECHATY_EVENT_DICT = {
'contact-alias' : 'Will be emitted when contact alias has been changed.',
'contact-phone' : 'Will be emitted when contact phone has been changed.',
'contact-description': 'Will be emitted when contact description has been changed.',
'contact-corporation': 'Will be emitted when contact corporation has been changed.',
'room-owner' : 'Will be emitted when room owner has been changed.',
} as const

Expand Down Expand Up @@ -65,6 +66,7 @@ type WechatyEventListenerContactName = (contact: ContactInterface, newNam
type WechatyEventListenerContactPhone = (contact: ContactInterface, newPhoneList: string[], oldPhoneList: []) => void | Promise<void>
type WechatyEventListenerContactAlias = (contact: ContactInterface, newAlias: string, oldAlias: string) => void | Promise<void>
type WechatyEventListenerContactDescription = (contact: ContactInterface, newDescription: string, oldDescription: string) => void | Promise<void>
type WechatyEventListenerContactCorporation = (contact: ContactInterface, newCorporation: string, oldCorporation: string) => void | Promise<void>
type WechatyEventListenerTag = (type: PUPPET.types.TagEvent, list: TagInterface[], date?: Date) => void | Promise<void>
type WechatyEventListenerTagGroup = (type: PUPPET.types.TagGroupEvent, list: TagGroupInterface[], date?: Date) => void | Promise<void>

Expand Down Expand Up @@ -247,6 +249,7 @@ interface WechatyEventListeners {
'contact-alias' : WechatyEventListenerContactAlias
'contact-phone' : WechatyEventListenerContactPhone
'contact-description': WechatyEventListenerContactDescription
'contact-corporation': WechatyEventListenerContactCorporation
'room-owner' : WechatyEventListenerRoomOwner
'tag' : WechatyEventListenerTag
'tag-group' : WechatyEventListenerTagGroup
Expand Down Expand Up @@ -284,6 +287,7 @@ export type {
WechatyEventListenerContactAlias,
WechatyEventListenerContactPhone,
WechatyEventListenerContactDescription,
WechatyEventListenerContactCorporation,
WechatyEventListenerTag,
WechatyEventListenerTagGroup,
}
Expand Down
5 changes: 5 additions & 0 deletions src/wechaty-mixins/puppet-mixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,11 @@ const puppetMixin = <MixinBase extends WechatifyUserModuleMixin & GErrorMixin &
contact?.emit('description', difference.newValue || '', difference.oldValue || '')
break
}
case 'corporation': {
this.emit('contact-corporation', contact, difference.newValue || '', difference.oldValue || '')
contact?.emit('corporation', difference.newValue || '', difference.oldValue || '')
break
}
default:
log.warn('WechatyPuppetMixin', 'puppet dirty unsupported difference type: %s', JSON.stringify(difference))
}
Expand Down

0 comments on commit 5b8aabb

Please sign in to comment.