提交 1b180cc3 编写于 作者: Huan (李卓桓)'s avatar Huan (李卓桓)

use toFile() to extract attachments in message

上级 3866a0b7
......@@ -361,7 +361,15 @@ export class Message extends Accessory implements Sayable {
}
}
/**
* @deprecated use toFile() instead
*/
public async file(): Promise<FileBox> {
log.warn('Message', 'file() DEPRECATED. use toFile() instead.')
return this.toFile()
}
public async toFile(): Promise<FileBox> {
if (this.type() === Message.Type.Text) {
throw new Error('text message no file')
}
......@@ -369,6 +377,18 @@ export class Message extends Accessory implements Sayable {
return fileBox
}
public async toContact(): Promise<Contact> {
log.warn('Message', 'toContact() to be implemented')
if (this.type() === Message.Type.Contact) {
throw new Error('message not a ShareCard')
}
// TODO: return the ShareCard Contact
const contact = this.wechaty.userSelf()
return contact
}
/**
* Get the type from the message.
*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册