Telegram api:在一条消息中发送文本和照片

Telegram api: send text and photos in one message

我正在尝试编写一个电报机器人,它将墙贴从 VK 组发送到电报频道。 我使用 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)

是否可以在一条消息中发送文本和照片?也许你可以建议我另一个用于电报机器人或其他魔法的库。

sendPhoto 方法有一个参数 caption。它将出现在图片下方。

使用 pyTelegramBotAPI 时,只需添加第三个参数作为标题即可。

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