- Notifications
You must be signed in to change notification settings - Fork5.9k
Internal test bots
Note: This guide is of no use to the regular user.
CI = AppVeyor|Travispy_platform = CPython|PyPypy_version = 2.7|3.4|3.5|3.6|3.7bot_username = ptb_{CI.lower()}_{py_platform.lower()}_{py_version.replace('.', '')}_botHere is a script that does all the setup below in a semi automated way using Telethon. Also checkthis version, which was updated for the animated sticker sets and automatically creates a new super group for the bot to be added to (see#1919).ToggleForumRequest is helpful for converting groups to forums.
Note: It doesn't create the video sticker set yet, but the test suite creates that on the fly, if necessary.
# meanssend a message to @BotFather% meansclick button in inlinekeyboard
# /newbot# Python-telegram-bot tests on {CI} using {py_platform} {py_version}(Bot name)# {bot_username}(Bot username)
The token for the new bot will be shown.
Search for the bot, and press theStart button
# /set_description# @{bot_username}# This bot is only for running tests for python-telegram-bot and has no actual functionality.
# /set_abouttext# @{bot_username}# This bot is only for running tests for python-telegram-bot and has no actual functionality.
# /setjoingroups# @{bot_username}# Enable
>>> telegram.Bot() - Developers
# /setjoingroups# @{bot_username}# Disable
# /set_inline# @{bot_username}# This bot is only for running tests.
# /newgame# OK# Accept# @{bot_username}# Python-telegram-bot test game# A no-op test game, for python-telegram-bot bot framework testing.Upload tests/data/game.pngUpload tests/data/game.gif# test_game
Now we need to setup payment. This can only be done via the beta /mybots interface.
# /mybots% @{bot_username}% Payments% Stripe(might have a flag in front, depending on your country)% Connect Stripe TestPress start in @StripeTestBot% AuthorizePress "Skip this account form" at the top of your browserGo back to @StripeTestBot and make sure everything went wellGo back to @BotFather
The payment provider token should be displayed in the last message.
We need to use the bot api to do this.
me_id = YOURUSERIDsticker_set_name = 'test_by_{username}sticker_set_title = 'Test',sticker = 'tests/data/telegram_sticker.png',sticker_emoji = '😄'bot = telegram.Bot(token)with open(sticker, 'rb') as f: assert bot.create_new_sticker_set(me.id, sticker_set_name, sticker_set_title, f, sticker_emoji)We need to use the bot api to do this.
me_id = YOURUSERIDanimated_sticker_set_name = 'test_by_{username}animated_sticker_set_title = 'Test',animated_sticker = 'tests/data/telegram_animated_sticker.png',sticker_emoji = '😄'bot = telegram.Bot(token)with open(animated_sticker, 'rb') as f: assert bot.create_new_sticker_set(me.id, animated_sticker_set_name, animated_sticker_set_title, f, sticker_emoji)Similar to above
Wiki ofpython-telegram-bot © Copyright 2015-2025 – Licensed byCreative Commons
- Architecture Overview
- Builder Pattern for
Application - Types of Handlers
- Working with Files and Media
- Exceptions, Warnings and Logging
- Concurrency in PTB
- Advanced Filters
- Storing data
- Making your bot persistent
- Adding Defaults
- Job Queue
- Arbitrary
callback_data - Avoiding flood limits
- Webhooks
- Bot API Forward Compatiblity
- Frequently requested design patterns
- Code snippets
- Performance Optimizations
- Telegram Passport
- Bots built with PTB
- Automated Bot Tests