未验证 提交 db9dd130 编写于 作者: Y Yuan Gao 提交者: GitHub

add phone method in contact class (#2039)

* add phone method in contact class

* 0.47.13

* 0.47.14

* update wechaty-puppet version

* add jsdoc for contact.phone
上级 489a0da5
{
"name": "wechaty",
"version": "0.47.13",
"version": "0.47.14",
"description": "Wechaty is Conversational SDK Chatbot Makers, Powered by TypeScript, Docker, and 💖",
"main": "dist/src/mod.js",
"typings": "dist/src/mod.d.ts",
"engines": {
"node": ">= 12",
"wechaty-puppet": ">=0.30.3"
"wechaty-puppet": ">=0.31.1"
},
"wechaty": {
"DEFAULT_PORT": 8080,
......@@ -103,7 +103,7 @@
"typed-emitter": "^1.2.0",
"watchdog": "^0.8.17",
"wechaty-puppet-hostie": "^0.9.13",
"wechaty-puppet": "^0.30.3",
"wechaty-puppet": "^0.31.1",
"ws": "^7.2.3"
},
"devDependencies": {
......
......@@ -537,6 +537,51 @@ class Contact extends ContactEventEmitter implements Sayable {
}
}
/**
* GET / SET / DELETE the phone list for a contact
*
* @param {(none | string[])} phoneList
* @returns {(Promise<string[] | void>)}
* @example <caption> GET the phone list for a contact, return {(Promise<string[]>)}</caption>
* const phoneList = await contact.phone()
* if (phone.length === 0) {
* console.log('You have not yet set any phone number for contact ' + contact.name())
* } else {
* console.log('You have already set phone numbers for contact ' + contact.name() + ':' + phoneList.join(','))
* }
*
* @example <caption>SET the phoneList for a contact</caption>
* try {
* const phoneList = ['13999999999', '13888888888']
* await contact.alias(phoneList)
* console.log(`change ${contact.name()}'s phone successfully!`)
* } catch (e) {
* console.log(`failed to change ${contact.name()} phone!`)
* }
*/
public async phone (): Promise<string[]>
public async phone (phoneList: string[]): Promise<void>
public async phone (phoneList?: string[]): Promise<string[] | void> {
log.silly('Contact', 'phone(%s)', phoneList === undefined ? '' : JSON.stringify(phoneList))
if (!this.payload) {
throw new Error('no payload')
}
if (typeof phoneList === 'undefined') {
return this.wechaty.puppet.contactPhone(this.id)
}
try {
await this.wechaty.puppet.contactPhone(this.id, phoneList)
await this.wechaty.puppet.contactPayloadDirty(this.id)
this.payload = await this.wechaty.puppet.contactPayload(this.id)
} catch (e) {
log.error('Contact', 'phone(%s) rejected: %s', JSON.stringify(phoneList), e.message)
Raven.captureException(e)
}
}
/**
*
* @description
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册