From cabbef8780bd88fb1e0c504624aef4c62f1e01e8 Mon Sep 17 00:00:00 2001 From: Shtarev Date: Mon, 1 Feb 2016 20:14:17 +0300 Subject: [PATCH] how to send photo --- README.rst | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/README.rst b/README.rst index 9abac6103..cfce16f0a 100644 --- a/README.rst +++ b/README.rst @@ -34,7 +34,7 @@ A Python wrapper around the Telegram Bot API. .. image:: https://coveralls.io/repos/python-telegram-bot/python-telegram-bot/badge.svg?branch=master&service=github :target: https://coveralls.io/github/python-telegram-bot/python-telegram-bot?branch=master :alt: Coveralls - + .. image:: https://img.shields.io/badge/Telegram-Group-blue.svg :target: https://telegram.me/joinchat/ALnA-AJQm5R7Km9hdCgyng :alt: Telegram Group @@ -58,9 +58,9 @@ Table of contents - `Getting started`_ 1. `The Updater class`_ - + 2. `API`_ - + 3. `JobQueue`_ 4. `Logging`_ @@ -190,7 +190,7 @@ Now, we need to define a function that should process a specific type of update: We want this function to be called on a Telegram message that contains the ``/start`` command, so we need to register it in the dispatcher:: >>> dispatcher.addTelegramCommandHandler('start', start) - + The last step is to tell the ``Updater`` to start working:: >>> updater.start_polling() @@ -216,7 +216,7 @@ Let's add some functionality to our bot. We want to add the ``/caps`` command, t >>> def caps(bot, update, args): ... text_caps = ' '.join(args).upper() ... bot.sendMessage(chat_id=update.message.chat_id, text=text_caps) - ... + ... >>> dispatcher.addTelegramCommandHandler('caps', caps) Now it's time to stop the bot:: @@ -283,6 +283,10 @@ To post an image file via URL:: >>> bot.sendPhoto(chat_id=chat_id, photo='https://telegram.org/img/t_logo.png') +To post an image file from disk:: + + >>> bot.sendPhoto(chat_id=chat_id, photo=open('tests/test.png', 'rb')) + To post a voice file from disk:: >>> bot.sendVoice(chat_id=chat_id, voice=open('tests/telegram.ogg', 'rb'))