mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2024-11-21 22:56:38 +01:00
how to send photo
This commit is contained in:
parent
6d2e159d75
commit
cabbef8780
1 changed files with 9 additions and 5 deletions
14
README.rst
14
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'))
|
||||
|
|
Loading…
Reference in a new issue