python-telegram-bot/examples
Jasmin Bom 09bdb88822
Bot api 4.1 (#1198)
* Fix passport decryption failing at random times

Sometimes a decrypted secret was being treated as b64 and therefore got decoded even further. Fix by decoding b64 right before call to decrypt so we have better control of when not to do it

* Bot api 4.1

Telegram passport 1.1
Added support for middle names.
Added support for translations for documents
Add errors for translations for documents
Added support for requesting names in the language of the user's country of residence
Replaced the payload parameter with the new parameter nonce

NOTE: Scope stuff is NOT implemented, as we wanna STRONGLY encourage users to use the telegram provided SDKs anyway (and not generate telegram auth links in their bot, but rather on a server)

* Minor fixes

* Add hash to EncryptedPassportElement

For use with PassportElementErrorUnspecified apparently
2018-09-01 16:58:08 +02:00
..
conversationbot.png [ci skip] add state diagrams for conversation handler examples 2016-10-28 08:26:02 +02:00
conversationbot.py Revert "Context based callbacks (#1100)" 2018-05-31 14:22:57 +02:00
conversationbot2.png [ci skip] add state diagrams for conversation handler examples 2016-10-28 08:26:02 +02:00
conversationbot2.py Revert "Context based callbacks (#1100)" 2018-05-31 14:22:57 +02:00
echobot.py Update examples with consistent string formatting (#870) 2017-10-20 21:24:00 +03:00
echobot2.py Revert "Context based callbacks (#1100)" 2018-05-31 14:22:57 +02:00
inlinebot.py Revert "Context based callbacks (#1100)" 2018-05-31 14:22:57 +02:00
inlinekeyboard.py Revert "Context based callbacks (#1100)" 2018-05-31 14:22:57 +02:00
LICENSE.txt dedicate examples to the public domain (CC0) 2015-12-25 15:19:17 +01:00
passportbot.html Prepare for 11.0.0 release 2018-08-29 15:21:02 +02:00
passportbot.py Bot api 4.1 (#1198) 2018-09-01 16:58:08 +02:00
paymentbot.py Revert "Context based callbacks (#1100)" 2018-05-31 14:22:57 +02:00
README.md Simplify sentence in examples/README.md (#1061) 2018-04-19 15:20:16 +03:00
timerbot.py Revert "Context based callbacks (#1100)" 2018-05-31 14:22:57 +02:00

Examples

In this folder there are small examples to show what a bot written with python-telegram-bot looks like. Some bots focus on one specific aspect of the Telegram Bot API while others focus on one of the mechanics of this library. Except for the echobot.py example, they all use the high-level framework this library provides with the telegram.ext submodule.

All examples are licensed under the CC0 License and are therefore fully dedicated to the public domain. You can use them as the base for your own bots without worrying about copyrights.

echobot2.py

This is probably the base for most of the bots made with python-telegram-bot. It simply replies to each text message with a message that contains the same text.

timerbot.py

This bot uses the JobQueue class to send timed messages. The user sets a timer by using /set command with a specific time, for example /set 30. The bot then sets up a job to send a message to that user after 30 seconds. The user can also cancel the timer by sending /unset. To learn more about the JobQueue, read this wiki article.

conversationbot.py

A common task for a bot is to ask information from the user. In v5.0 of this library, we introduced the ConversationHandler for that exact purpose. This example uses it to retrieve user-information in a conversation-like style. To get a better understanding, take a look at the state diagram.

conversationbot2.py

A more complex example of a bot that uses the ConversationHandler. It is also more confusing. Good thing there is a fancy state diagram for this one, too!

inlinekeyboard.py

This example sheds some light on inline keyboards, callback queries and message editing.

inlinebot.py

A basic example of an inline bot. Don't forget to enable inline mode with @BotFather.

paymentbot.py

A basic example of a bot that can accept payments. Don't forget to enable and configure payments with @BotFather.

Pure API

The echobot.py example uses only the pure, "bare-metal" API wrapper.