Add support for stream as media message input (#905)

* Add support for stream as media message input

* refactor: use async/await on readable toBuffer

* refactor: be more explicit about using a readable stream

Co-authored-by: Adhiraj Singh <adhirajsingh1001@gmail.com>
This commit is contained in:
Maurilho Batista
2021-11-26 02:00:15 -03:00
committed by GitHub
parent 6e830c1e1b
commit e810f2dec5
3 changed files with 25 additions and 4 deletions

View File

@@ -3,6 +3,7 @@ import type { Logger } from "pino"
import type { URL } from "url"
import type NodeCache from "node-cache"
import type { GroupMetadata } from "./GroupMetadata"
import type { Readable } from "stream"
import { proto } from '../../WAProto'
// export the WAMessage Prototypes
@@ -18,7 +19,7 @@ export type WALocationMessage = proto.ILocationMessage
export type WAGenericMediaMessage = proto.IVideoMessage | proto.IImageMessage | proto.IAudioMessage | proto.IDocumentMessage | proto.IStickerMessage
export import WAMessageStubType = proto.WebMessageInfo.WebMessageInfoStubType
export import WAMessageStatus = proto.WebMessageInfo.WebMessageInfoStatus
export type WAMediaUpload = Buffer | { url: URL | string }
export type WAMediaUpload = Buffer | { url: URL | string } | { stream: Readable }
/** Set of message types that are supported by the library */
export type MessageType = keyof proto.Message