python-telegram-bot/examples
Jannes Höke 5116a77221 Class methods (#362)
* bot.py: add create_references method

* create bot reference in webhook handler, use create_references on new updates

* message.py: implement reply_text

* echobot2.py: use Message.reply_text

* fix create_references in webhook handler

* add some more instance methods

* Chat.kick_member and unban_member

* bot.py: Create bot references in outgoing messages

* add tests for everything testable

* test_updater.py: add create_references method to MockBot

* remove Bot.create_references and refactor TelegramObject.de_json to take the additional parameter bot

* List bot as named kwarg where used

* file.py: Use Bot.request property instead of Bot._request attr
2016-09-20 06:36:55 +02:00
..
conversationbot.py ConversationHandler (#331) 2016-07-15 01:30:54 +02:00
echobot.py echobot: simplify handling messageless updates 2016-06-12 17:06:03 +02:00
echobot2.py Class methods (#362) 2016-09-20 06:36:55 +02:00
inlinebot.py Update examples to column width to 99 [ci skip] 2016-05-23 17:45:01 -03:00
inlinekeyboard.py new inlinekeyboard example (#355) 2016-07-20 00:15:03 +02:00
LICENSE.txt dedicate examples to the public domain (CC0) 2015-12-25 15:19:17 +01:00
README.md Create README.md 2016-07-24 02:35:01 +02:00
timerbot.py unset but (#383) 2016-08-16 21:13:31 +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.

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.