alexander-akhmetov/python-telegram

please add send media example, Thank you in advance.

heitumo opened this issue · 4 comments

please add send media, like video, picture and voice. Thank you in advance.

Also wondering about this, I've tried using the sendPhoto api via call_method without success.

e.g.:

    data = {'chat_id': chat_id,
            'photo': url, 'caption' : message}

    tg.call_method('sendPhoto', data)

Ok looked a little at the source code and api and it would prob rater be something like this:

data = {
    'chat_id': chat_id,
    'input_message_content': {
        '@type': 'inputMessagePhoto',
        'photo': {
            '@type': 'inputFileLocal', # https://core.telegram.org/tdlib/docs/classtd_1_1td__api_1_1input_file_local.html
            'path': file_path,
        },
    },
}
tg.call_method('sendMessage', data)

I'll check later if I can get it to work.

Hi! Yes, sorry, there is no example in the documentation yet. @tbscode's code should work. A couple of years ago I wrote an example of how to send media with the internal _send_data here method but call_method is better and easier to use.

Ah I checked the issues must have overlooked that one, thanks. I've tested it (my example above) now and yes I can confirm it works.