feat: send Media HD (#3535)
* Changing the quality of media downloads * return function result * add option sendImageAsHd * change example * fix quotes * chore: remove unused code --------- Co-authored-by: alechkos <93551621+alechkos@users.noreply.github.com>
This commit is contained in:
parent
c142c3bf93
commit
0ffb66fdb1
4 changed files with 25 additions and 9 deletions
|
|
@ -34,6 +34,7 @@ exports.LoadUtils = () => {
|
|||
forceGif: options.sendVideoAsGif,
|
||||
forceVoice: options.sendAudioAsVoice,
|
||||
forceDocument: options.sendMediaAsDocument,
|
||||
forceMediaHd: options.sendMediaAsHd,
|
||||
sendToChannel: isChannel
|
||||
});
|
||||
mediaOptions.caption = options.caption;
|
||||
|
|
@ -363,16 +364,21 @@ exports.LoadUtils = () => {
|
|||
};
|
||||
};
|
||||
|
||||
window.WWebJS.processMediaData = async (mediaInfo, { forceSticker, forceGif, forceVoice, forceDocument, sendToChannel }) => {
|
||||
window.WWebJS.processMediaData = async (mediaInfo, { forceSticker, forceGif, forceVoice, forceDocument, forceMediaHd, sendToChannel }) => {
|
||||
const file = window.WWebJS.mediaInfoToFile(mediaInfo);
|
||||
const opaqueData = await window.Store.OpaqueData.createFromData(file, file.type);
|
||||
const mediaPrep = window.Store.MediaPrep.prepRawMedia(
|
||||
opaqueData, {
|
||||
asSticker: forceSticker,
|
||||
asGif: forceGif,
|
||||
isPtt: forceVoice,
|
||||
asDocument: forceDocument
|
||||
});
|
||||
const mediaParams = {
|
||||
asSticker: forceSticker,
|
||||
asGif: forceGif,
|
||||
isPtt: forceVoice,
|
||||
asDocument: forceDocument
|
||||
};
|
||||
|
||||
if (forceMediaHd && file.type.indexOf('image/') === 0) {
|
||||
mediaParams.maxDimension = 2560;
|
||||
}
|
||||
|
||||
const mediaPrep = window.Store.MediaPrep.prepRawMedia(opaqueData, mediaParams);
|
||||
const mediaData = await mediaPrep.waitForPrep();
|
||||
const mediaObject = window.Store.MediaObject.getOrCreateMediaObject(mediaData.filehash);
|
||||
const mediaType = window.Store.MediaTypes.msgToMediaType({
|
||||
|
|
|
|||
Loading…
Reference in a new issue