feat: Add MessageMedia.fromUrl method (#769)

This commit is contained in:
Wictor Nogueira 2021-07-31 10:36:11 -03:00 • committed by GitHub
commit cd774bef17
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 63 additions and 0 deletions

10
index.d.ts vendored
View file

@ -1,5 +1,6 @@
import { EventEmitter } from 'events'
import { RequestInit } from 'node-fetch'
import puppeteer = require('puppeteer')
declare namespace WAWebJS {
@ -664,6 +665,12 @@ declare namespace WAWebJS {
stickerCategories?: string[]
}
export interface MediaFromURLOptions {
client?: Client
unsafeMime?: boolean
reqOptions?: RequestInit
}
/** Media attached to a message */
export class MessageMedia {
/** MIME type of the attachment */
@ -682,6 +689,9 @@ declare namespace WAWebJS {
/** Creates a MessageMedia instance from a local file path */
static fromFilePath: (filePath: string) => MessageMedia
/** Creates a MessageMedia instance from a URL */
static fromUrl: (url: string, options?: MediaFromURLOptions) => Promise<MessageMedia>
}
export type MessageContent = string | MessageMedia | Location | Contact | Contact[]