diff --git a/package.json b/package.json index b2b0d08b1..fc2b7760b 100644 --- a/package.json +++ b/package.json @@ -109,7 +109,7 @@ }, "homepage": "https://github.com/wechaty/", "dependencies": { - "@juzi/wechaty-puppet-service": "^1.0.81", + "@juzi/wechaty-puppet-service": "^1.0.82", "clone-class": "^1.1.1", "cmd-ts": "^0.10.0", "cockatiel": "^2.0.2", @@ -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.69", + "@juzi/wechaty-puppet": "^1.0.71", "@juzi/wechaty-puppet-mock": "^1.0.1", "@swc/core": "1.3.44", "@swc/helpers": "^0.3.6", diff --git a/src/user-modules/contact-self.ts b/src/user-modules/contact-self.ts index a9a3f7974..62cb136f9 100644 --- a/src/user-modules/contact-self.ts +++ b/src/user-modules/contact-self.ts @@ -175,6 +175,40 @@ class ContactSelfMixin extends MixinBase { return this.wechaty.puppet.contactSelfName(name).then(this.sync.bind(this)) } + public override realName (): string + public override realName (realName: string): Promise + + public override realName (realName?: string): string | Promise { + log.verbose('ContactSelf', 'realName(%s)', realName || '') + + if (typeof realName === 'undefined') { + return super.realName() + } + + if (this.id !== this.wechaty.puppet.currentUserId) { + throw new Error('only can set realName for user self') + } + + return this.wechaty.puppet.contactSelfRealName(realName).then(this.sync.bind(this)) + } + + public override aka (): string + public override aka (aka: string): Promise + + public override aka (aka?: string): string | Promise { + log.verbose('ContactSelf', 'aka(%s)', aka || '') + + if (typeof aka === 'undefined') { + return super.aka() + } + + if (this.id !== this.wechaty.puppet.currentUserId) { + throw new Error('only can set aka for user self') + } + + return this.wechaty.puppet.contactSelfAka(aka).then(this.sync.bind(this)) + } + /** * Change bot signature * diff --git a/src/user-modules/contact.ts b/src/user-modules/contact.ts index 2e5a85e01..f456f8c4b 100644 --- a/src/user-modules/contact.ts +++ b/src/user-modules/contact.ts @@ -396,6 +396,14 @@ class ContactMixin extends MixinBase implements SayableSayer { return (this.payload && this.payload.name) || '' } + aka (): string { + return (this.payload && this.payload.aka) || '' + } + + realName (): string { + return (this.payload && this.payload.realName) || '' + } + async alias () : Promise async alias (newAlias: string) : Promise async alias (empty: null) : Promise