Ameko
Ameko

Reputation: 63

Telegram api: send text and photos in one message

I'm trying to write a telegram bot, which send wall posts from VK group to the telegram channel. I use pyTelegramBotAPI.

        post = u'{!s}'.format(item['text'])
        bot.send_message(CHANNEL_NAME, post)

        PHOTO_URL = str(item['attachments']['photo']['photo_604'])
        img_file = urllib2.urlopen(PHOTO_URL)
        im = StringIO(img_file.read())
        bot.send_photo(CHANNEL_NAME, im)

Is it possible to send text and photo in one message? Maybe you can advise me another library for telegram bot or some another magic.

Upvotes: 0

Views: 4756

Answers (1)

newsha
newsha

Reputation: 1438

sendPhoto method has a parameter caption. It will appear below the picture.

When using pyTelegramBotAPI simply adding a third parameter as caption should work.

bot.send_photo(CHANNEL_NAME, im,"Caption goes here")

Upvotes: 3

Related Questions