Skip to content

Commit

Permalink
feat: 🎸 aka and realname
Browse files Browse the repository at this point in the history
  • Loading branch information
hcfw007 committed Nov 20, 2023
1 parent 921b365 commit a53e2a6
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
34 changes: 34 additions & 0 deletions src/user-modules/contact-self.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void>

public override realName (realName?: string): string | Promise<void> {
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<void>

public override aka (aka?: string): string | Promise<void> {
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
*
Expand Down
8 changes: 8 additions & 0 deletions src/user-modules/contact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<undefined | string>
async alias (newAlias: string) : Promise<void>
async alias (empty: null) : Promise<void>
Expand Down

0 comments on commit a53e2a6

Please sign in to comment.