-
Notifications
You must be signed in to change notification settings - Fork 0
Internal test bots
Note: This guide is of no use to the regular user.
CI = AppVeyor|Travis
py_platform = CPython|PyPy
py_version = 2.7|3.4|3.5|3.6|3.7
bot_username = ptb_{CI.lower()}_{py_platform.lower()}_{py_version.replace('.', '')}_bot
Here is a script that does all the setup below in a semi automated way using Telethon. Also check this 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.
#
means send a message to @BotFather
%
means click 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 the Start
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.png
Upload 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 Test
Press start in @StripeTestBot
% Authorize
Press "Skip this account form" at the top of your browser
Go back to @StripeTestBot and make sure everything went well
Go 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 = YOURUSERID
sticker_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 = YOURUSERID
animated_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 of
python-telegram-bot
© Copyright 2015-2025 – Licensed by Creative 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