Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<p align="center">A simple, but extensible Python implementation for the <a href="https://core.telegram.org/bots/api">Telegram Bot API</a>.</p>
<p align="center">Both synchronous and asynchronous.</p>

## <p align="center">Supported Bot API version: <a href="https://core.telegram.org/bots/api#june-11-2026"><img src="https://img.shields.io/badge/Bot%20API-10.1-blue?logo=telegram" alt="Supported Bot API version"></a>
## <p align="center">Supported Bot API version: <a href="https://core.telegram.org/bots/api#august-24-2026"><img src="https://img.shields.io/badge/Bot%20API-10.3-blue?logo=telegram" alt="Supported Bot API version"></a>

<h2><a href='https://pytba.readthedocs.io/en/latest/index.html'>Official documentation</a></h2>
<h2><a href='https://pytba.readthedocs.io/ru/latest/index.html'>Official ru documentation</a></h2>
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
copyright = f'2022-{datetime.now().year}, {author}'

# The full version, including alpha/beta/rc tags
release = '4.36.1'
release = '4.37.0'


# -- General configuration ---------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "pyTelegramBotAPI"
version = "4.36.1"
version = "4.37.0"
description = "Python Telegram bot API."
authors = [{name = "eternnoir", email = "eternnoir@gmail.com"}]
license = {text = "GPL2"}
Expand Down
371 changes: 272 additions & 99 deletions telebot/__init__.py

Large diffs are not rendered by default.

127 changes: 62 additions & 65 deletions telebot/apihelper.py

Large diffs are not rendered by default.

363 changes: 271 additions & 92 deletions telebot/async_telebot.py

Large diffs are not rendered by default.

123 changes: 59 additions & 64 deletions telebot/asyncio_helper.py

Large diffs are not rendered by default.

549 changes: 538 additions & 11 deletions telebot/types.py

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions telebot/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
'checklist_tasks_done', 'checklist_tasks_added', 'direct_message_price_changed', 'suggested_post_refunded',
'suggested_post_info', 'suggested_post_approved', 'suggested_post_approval_failed', 'suggested_post_declined',
'suggested_post_paid', 'gift_upgrade_sent', 'chat_owner_left', 'chat_owner_changed', 'managed_bot_created',
'poll_option_added', 'poll_option_deleted', 'community_chat_added', 'community_chat_removed'
'poll_option_added', 'poll_option_deleted', 'community_chat_added', 'community_chat_removed',
'community_chat_joined'
]

#: All update types, should be used for allowed_updates parameter in polling.
Expand All @@ -53,7 +54,7 @@
"callback_query", "shipping_query", "pre_checkout_query", "poll", "poll_answer", "my_chat_member", "chat_member",
"chat_join_request", "message_reaction", "message_reaction_count", "removed_chat_boost", "chat_boost",
"business_connection", "business_message", "edited_business_message", "deleted_business_messages",
"purchased_paid_media", "managed_bot", "guest_message", "subscription"
"purchased_paid_media", "managed_bot", "guest_message", "subscription", "stopped_message_generation"
]


Expand Down
2 changes: 1 addition & 1 deletion telebot/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Versions should comply with PEP440.
# This line is parsed in setup.py:
__version__ = '4.36.1'
__version__ = '4.37.0'
4 changes: 2 additions & 2 deletions tests/test_handler_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def update_type(message):
return types.Update(1001234038283, message, edited_message, channel_post, edited_channel_post, inline_query,
chosen_inline_result, callback_query, shipping_query, pre_checkout_query, poll, poll_answer,
my_chat_member, chat_member, chat_join_request, message_reaction, message_reaction_count, chat_boost, chat_boost_removed, None,
None, None, None, None, None, None, None)
None, None, None, None, None, None, None, None)


@pytest.fixture()
Expand All @@ -97,7 +97,7 @@ def reply_to_message_update_type(reply_to_message):
return types.Update(1001234038284, reply_to_message, edited_message, channel_post, edited_channel_post,
inline_query, chosen_inline_result, callback_query, shipping_query, pre_checkout_query,
poll, poll_answer, my_chat_member, chat_member, chat_join_request, message_reaction, message_reaction_count, chat_boost, chat_boost_removed, None, None, None, None, None, None, None,
None)
None, None)


def next_handler(message):
Expand Down
3 changes: 2 additions & 1 deletion tests/test_telebot.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,8 @@ def create_message_update(text):
deleted_business_messages=None,
managed_bot=None,
guest_message=None,
subscription=None)
subscription=None,
stopped_message_generation=None)

def test_is_string_unicode(self):
s1 = u'string'
Expand Down
77 changes: 77 additions & 0 deletions tests/test_types.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,87 @@
# -*- coding: utf-8 -*-
import json
import sys

sys.path.append('../')
from telebot import types


def test_api_103_ephemeral_message_parameters():
parameters = types.EphemeralMessageParameters(1, callback_query_id='query')

assert parameters.to_dict() == {'receiver_user_id': 1, 'callback_query_id': 'query'}


def test_api_103_rich_message_button():
button = types.RichMessageButton('Open', callback_data='open')

assert button.to_dict() == {'text': 'Open', 'callback_data': 'open'}


def test_api_103_disabled_inline_button():
button = types.InlineKeyboardButton('Unavailable', disabled=types.DisabledButton())

assert button.to_dict()['disabled'] == {}


def test_api_103_rich_text_button_round_trip():
button = types.RichMessageButton(types.RichTextBold('Open'), callback_data='open')
rich_text = types.RichTextButton(button)

assert types.RichText.de_json(rich_text.to_dict()).to_dict() == rich_text.to_dict()


def test_api_103_rich_blocks():
button = types.RichMessageButton('Open', callback_data='open')
document = types.InputRichBlockDocument(types.InputMediaDocument('document-id'))
buttons = types.RichBlock.de_json({
'type': 'buttons',
'buttons': [button.to_dict()],
})
quotation = types.RichBlock.de_json({
'type': 'expandable_blockquote',
'text': 'Quote',
})

assert isinstance(buttons, types.RichBlockButtons)
assert buttons.buttons[0].callback_data == 'open'
assert isinstance(quotation, types.RichBlockExpandableBlockQuotation)
assert quotation.text == 'Quote'
assert document.to_dict() == {
'type': 'document',
'document': {'type': 'document', 'media': 'document-id'},
}


def test_api_103_new_optional_fields():
table = types.InputRichBlockTable([], is_compact=True)
reply_keyboard = types.ReplyKeyboardMarkup(force_reply=True)
inline_keyboard = types.InlineKeyboardMarkup(force_reply=True)

assert table.to_dict()['is_compact'] is True
assert json.loads(reply_keyboard.to_json())['force_reply'] is True
assert inline_keyboard.to_dict()['force_reply'] is True


def test_api_103_new_service_objects():
update = types.Update.de_json({
'update_id': 1,
'stopped_message_generation': {
'chat': {'id': 1, 'type': 'private'},
'draft_id': 2,
},
})
message = types.Message.de_json({
'message_id': 1,
'date': 1,
'chat': {'id': 1, 'type': 'private'},
'community_chat_joined': {'community': {'id': 1, 'name': 'Community'}},
})

assert isinstance(update.stopped_message_generation, types.MessageGenerationStopped)
assert isinstance(message.community_chat_joined, types.CommunityChatJoined)


def test_json_user():
json_str = r'{"id": 123456789, "is_bot": false, "first_name": "John", "last_name": "Doe", "username": "@johndoe", "language_code": "en", "can_join_groups": true, "can_read_all_group_messages": false, "supports_inline_queries": true, "is_premium": true, "added_to_attachment_menu": false, "can_connect_to_business": true, "has_main_web_app": false, "has_topics_enabled": true, "allows_users_to_create_topics": true, "can_manage_bots": true, "supports_guest_queries": true, "supports_join_request_queries": true}'
result = types.User.de_json(json_str)
Expand Down
Loading