GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — python-telegram-bot/examples at master · saintbyte/python-telegram-bot

Expand file tree

/

examples

/
Copy path

Directory actions

More options

More options

Directory actions

More options

More options

Latest commit

 

History

History
History
 
 
/

examples

/
Copy path

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
LICENSE.txt
LICENSE.txt
 
 
README.md
README.md
 
 
conversationbot.png
conversationbot.png
 
 
conversationbot.py
conversationbot.py
 
 
conversationbot2.png
conversationbot2.png
 
 
conversationbot2.py
conversationbot2.py
 
 
echobot.py
echobot.py
 
 
echobot2.py
echobot2.py
 
 
inlinebot.py
inlinebot.py
 
 
inlinekeyboard.py
inlinekeyboard.py
 
 
passportbot.html
passportbot.html
 
 
passportbot.py
passportbot.py
 
 
paymentbot.py
paymentbot.py
 
 
persistentconversationbot.py
persistentconversationbot.py
 
 
timerbot.py
timerbot.py
 
 

README.md

Outline

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.

persistentconversationbot.py

A basic example of a bot store conversation state and user_data over multiple restarts.

Pure API

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

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.