Загрузка...

User api (SendMedia)

Thread in Node.js created by pinilopa May 22, 2022. 202 views

  1. pinilopa
    pinilopa Topic starter May 22, 2022 Banned 69 Apr 17, 2021
    Ebanii tg
    Есть код для отправки медии,
    Но получается ошибка: Error: Disconnect (caused from messages.SendMedia)
    JavaScript
        const media = await tg_user.uploadMedia(client, setting.message.file);


    /*
    media возвращает (если фото):
    {
    CONSTRUCTOR_ID: 505969924,
    SUBCLASS_OF_ID: 4210575092,
    className: 'InputMediaUploadedPhoto',
    classType: 'constructor',
    flags: undefined,
    file: {
    CONSTRUCTOR_ID: 4113560191,
    SUBCLASS_OF_ID: 3882180383,
    className: 'InputFile',
    classType: 'constructor',
    id: Integer { value: -499754294517618022n },
    parts: 1,
    name: '1653225630556_file_8.jpg',
    md5Checksum: ''
    },
    stickers: undefined,
    ttlSeconds: undefined
    }
    */

    const result = await client.invoke(
    new Api.messages.SendMedia({
    peer: 'me',
    media,
    message: 'Test',
    randomId: BigInt(new Date().getTime())
    })
    );

    console.log(result)
    JavaScript
    tg_user.uploadMedia = async(client, file) => {
    const media = await client.uploadFile({
    file: new CustomFile(file.name, file.size, file.path),
    workers: 3
    })


    /*
    media возвращает (на примере фото) это:
    {
    CONSTRUCTOR_ID: 4113560191,
    SUBCLASS_OF_ID: 3882180383,
    className: 'InputFile',
    classType: 'constructor',
    id: Integer { value: -499754294517618022n },
    parts: 1,
    name: '1653225630556_file_8.jpg',
    md5Checksum: ''
    }
    */

    if(file.type === 'photo') {
    return new Api.InputMediaUploadedPhoto({
    file: media
    });
    }

    else if(file.type === 'document') {
    return new Api.InputMediaUploadedDocument({
    file: media,
    attributes: [
    new Api.DocumentAttributeFilename({
    fileName: file.name
    })
    ],
    mimeType: file.mime_type,
    });
    }

    return media;
    }





     
  2. eqshka
    eqshka May 23, 2022 11 Nov 14, 2018
    Привет. Скинь полную ошибку пожалуйстаю.
     
Loading...
Top