feat: add getMedia
This commit is contained in:
@@ -150,4 +150,8 @@ export class WhatsAppClient {
|
||||
sendText(params: SendTextParams) {
|
||||
return this.request<any>("sendText", params);
|
||||
}
|
||||
|
||||
getMedia(msgId: string) {
|
||||
return this.request<string>("getMedia", msgId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,4 +68,5 @@ export type BridgeRequest =
|
||||
| RpcRequest<"listGroups">
|
||||
| RpcRequest<"getMessages", GetMessagesParams>
|
||||
| RpcRequest<"searchMessages", SearchMessagesParams>
|
||||
| RpcRequest<"sendText", SendTextParams>;
|
||||
| RpcRequest<"sendText", SendTextParams>
|
||||
| RpcRequest<"getMedia", string>;
|
||||
|
||||
@@ -108,6 +108,12 @@ async function handleRequest(request: BridgeRequest) {
|
||||
return serialize(result);
|
||||
}
|
||||
|
||||
case "getMedia":
|
||||
const media = await WPP.chat
|
||||
.downloadMedia(request.params)
|
||||
.then(WPP.util.blobToBase64);
|
||||
return media;
|
||||
|
||||
default:
|
||||
throw new Error(`Unknown method: ${(request as any).method}`);
|
||||
}
|
||||
|
||||
Vendored
+6
@@ -48,6 +48,8 @@ declare const WPP: {
|
||||
},
|
||||
): Promise<any>;
|
||||
|
||||
downloadMedia(msgId: string): Promise<Blob>;
|
||||
|
||||
on(event: string, callback: (...args: any[]) => void): void;
|
||||
};
|
||||
|
||||
@@ -60,5 +62,9 @@ declare const WPP: {
|
||||
getAllGroups(): Promise<any[]>;
|
||||
};
|
||||
|
||||
util: {
|
||||
blobToBase64: (blob: Blob) => Promise<string>;
|
||||
};
|
||||
|
||||
on(event: string, callback: (...args: any[]) => void): void;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user