python-telegram-bot/examples
Noam Meltzer acf1541395 Botapi2.3 (#471)
* New fields channel_post and edited_channel_post for Update

refs #468

* setGameScore() changes

 - Changed behaviour: messages with high scores will be update with new
   high scores by default. (documentation fix)
 - Use (new) disable_edit_message in setGameScore to disable the above new
   behaviour.
 - The edit_message parameter from setGameScore is no longer in use. For
   backward compatibility, it will be taken into account for a while,
   unless disable_edit_message is passed explicitly.

refs #468

* New field forward_from_message_id for Message.

refs #468

* New parameter cache_time for answerCallbackQuery

refs #468

* replykeyboardhide renamed to replykeyboardremove

refs #468

* Unitests for updated setGameScore semantics

refs #468

* Backward compatibility for ReplyKeyboardHide

refs #468

* Fix docstrings of wrapper methods in Message

* Unitest new field forward_from_message_id of Message

refs #468

* Fix testMaxCaptionLength

Telegram servers changed their behaviour - now they truncate a long
caption instead of returning an error.

* MessageHandler: Added support for channel posts

* Fix flake8 complaints in a manner which yapf will like it too.

* fix rst markup
2016-12-11 22:44:52 +01:00
..
conversationbot.png [ci skip] add state diagrams for conversation handler examples 2016-10-28 08:26:02 +02:00
conversationbot.py Botapi2.3 (#471) 2016-12-11 22:44:52 +01:00
conversationbot2.png [ci skip] add state diagrams for conversation handler examples 2016-10-28 08:26:02 +02:00
conversationbot2.py update examples to use bitwise filters 2016-10-25 19:51:56 +02:00
echobot.py update all examples to use instance methods (#421) 2016-09-24 15:32:22 +02:00
echobot2.py update examples to use bitwise filters 2016-10-25 19:51:56 +02:00
inlinebot.py update all examples to use instance methods (#421) 2016-09-24 15:32:22 +02:00
inlinekeyboard.py update all examples to use instance methods (#421) 2016-09-24 15:32:22 +02:00
LICENSE.txt dedicate examples to the public domain (CC0) 2015-12-25 15:19:17 +01:00
README.md [ci skip] add state diagrams for conversation handler examples 2016-10-28 08:26:02 +02:00
timerbot.py update all examples to use instance methods (#421) 2016-09-24 15:32:22 +02:00

Examples

The examples in this folder are small bots meant to show you how a bot that is 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.

Pure API

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