Skip to content

Commit af4de91

Browse files
Merge branch 'master' into inline_handler_update
2 parents d113d02 + 12937a6 commit af4de91

File tree

8 files changed

+26
-23
lines changed

8 files changed

+26
-23
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<p align="center">A simple, but extensible Python implementation for the <a href="https://core.telegram.org/bots/api">Telegram Bot API</a>.</p>
1111
<p align="center">Both synchronous and asynchronous.</p>
1212

13-
## <p align="center">Supported Bot API version: <a href="https://core.telegram.org/bots/api#april-11-2025"><img src="https://img.shields.io/badge/Bot%20API-9.0-blue?logo=telegram" alt="Supported Bot API version"></a>
13+
## <p align="center">Supported Bot API version: <a href="https://core.telegram.org/bots/api#july-3-2025"><img src="https://img.shields.io/badge/Bot%20API-9.1-blue?logo=telegram" alt="Supported Bot API version"></a>
1414

1515
<h2><a href='https://pytba.readthedocs.io/en/latest/index.html'>Official documentation</a></h2>
1616
<h2><a href='https://pytba.readthedocs.io/ru/latest/index.html'>Official ru documentation</a></h2>

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
copyright = f'2022-{datetime.now().year}, {author}'
2323

2424
# The full version, including alpha/beta/rc tags
25-
release = '4.27.0'
25+
release = '4.28.0'
2626

2727

2828
# -- General configuration ---------------------------------------------------

pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "pyTelegramBotAPI"
7-
version = "4.27.0"
7+
version = "4.28.0"
88
description = "Python Telegram bot api."
99
authors = [{name = "eternnoir", email = "eternnoir@gmail.com"}]
1010
license = {text = "GPL2"}
@@ -35,7 +35,6 @@ Issues = "https://github.com/eternnoir/pyTelegramBotAPI/issues"
3535
json = ["ujson"]
3636
PIL = ["Pillow"]
3737
redis = ["redis>=3.4.1"]
38-
aiohttp = ["aiohttp"]
3938
fastapi = ["fastapi"]
4039
uvicorn = ["uvicorn"]
4140
psutil = ["psutil"]

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
pytest
22
requests==2.32.4
33
wheel==0.38.1
4-
aiohttp==3.10.11
4+
aiohttp==3.12.14

telebot/apihelper.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ def _make_request(token, method_name, method='get', params=None, files=None):
168168
json_result = _check_result(method_name, result)
169169
if json_result:
170170
return json_result['result']
171+
else:
172+
return None
171173

172174

173175
def _check_result(method_name, result):
@@ -1139,8 +1141,10 @@ def send_data(token, chat_id, data, data_type, reply_markup=None, parse_mode=Non
11391141
def get_method_by_type(data_type):
11401142
if data_type == 'document':
11411143
return r'sendDocument'
1142-
if data_type == 'sticker':
1144+
elif data_type == 'sticker':
11431145
return r'sendSticker'
1146+
else:
1147+
raise ValueError(f"Unsupported data type: {data_type}.")
11441148

11451149

11461150
def ban_chat_member(token, chat_id, user_id, until_date=None, revoke_messages=None):
@@ -2524,6 +2528,7 @@ def convert_input_media_array(array):
25242528
for input_media in array:
25252529
if isinstance(input_media, types.InputMedia) or isinstance(input_media, types.InputPaidMedia):
25262530
media_dict = input_media.to_dict()
2531+
key = "x" # stub
25272532
if media_dict['media'].startswith('attach://'):
25282533
key = media_dict['media'].replace('attach://', '')
25292534
files[key] = input_media.media

telebot/util.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,29 +27,30 @@
2727

2828
#: Contains all media content types.
2929
content_type_media = [
30-
'text', 'animation', 'audio', 'document', 'photo', 'sticker', 'story', 'video', 'video_note', 'voice', 'contact',
31-
'dice', 'game', 'poll', 'venue', 'location', 'invoice', 'successful_payment', 'connected_website',
32-
'passport_data', 'web_app_data',
30+
'text', 'audio', 'document', 'animation', 'game', 'photo', 'sticker', 'video', 'video_note', 'voice', 'contact',
31+
'location', 'venue', 'dice', 'invoice', 'successful_payment', 'connected_website', 'poll', 'passport_data',
32+
'web_app_data', 'story', 'giveaway', 'gift', 'unique_gift',
3333
]
3434

3535
#: Contains all service content types such as `User joined the group`.
3636
content_type_service = [
3737
'new_chat_members', 'left_chat_member', 'new_chat_title', 'new_chat_photo', 'delete_chat_photo',
38-
'group_chat_created', 'supergroup_chat_created', 'channel_chat_created', 'message_auto_delete_timer_changed',
39-
'migrate_to_chat_id', 'migrate_from_chat_id', 'pinned_message', 'users_shared', 'chat_shared',
40-
'write_access_allowed', 'proximity_alert_triggered', 'forum_topic_created', 'forum_topic_edited',
41-
'forum_topic_closed', 'forum_topic_reopened', 'general_forum_topic_hidden', 'general_forum_topic_unhidden',
42-
'giveaway_created', 'giveaway', 'giveaway_winners', 'giveaway_completed', 'video_chat_scheduled',
43-
'video_chat_started', 'video_chat_ended', 'video_chat_participants_invited','checklist_tasks_done',
44-
'checklist_tasks_added','direct_message_price_changed'
38+
'group_chat_created', 'supergroup_chat_created', 'channel_chat_created', 'migrate_to_chat_id',
39+
'migrate_from_chat_id', 'pinned_message', 'proximity_alert_triggered', 'video_chat_scheduled',
40+
'video_chat_started', 'video_chat_ended', 'video_chat_participants_invited', 'message_auto_delete_timer_changed',
41+
'chat_background_set', 'forum_topic_created', 'forum_topic_closed', 'forum_topic_reopened', 'forum_topic_edited',
42+
'general_forum_topic_hidden', 'general_forum_topic_unhidden', 'write_access_allowed', 'users_shared', 'chat_shared',
43+
'giveaway_created', 'giveaway_winners', 'giveaway_completed', 'boost_added', 'paid_message_price_changed',
44+
'checklist_tasks_done', 'checklist_tasks_added', 'direct_message_price_changed',
4545
]
4646

4747
#: All update types, should be used for allowed_updates parameter in polling.
4848
update_types = [
4949
"message", "edited_message", "channel_post", "edited_channel_post", "inline_query", "chosen_inline_result",
5050
"callback_query", "shipping_query", "pre_checkout_query", "poll", "poll_answer", "my_chat_member", "chat_member",
51-
"chat_join_request", "message_reaction", "message_reaction_count", "chat_boost", "removed_chat_boost",
52-
"business_connection", "business_message", "edited_business_message", "deleted_business_messages", "purchased_paid_media"
51+
"chat_join_request", "message_reaction", "message_reaction_count", "removed_chat_boost", "chat_boost",
52+
"business_connection", "business_message", "edited_business_message", "deleted_business_messages",
53+
"purchased_paid_media",
5354
]
5455

5556

telebot/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Versions should comply with PEP440.
22
# This line is parsed in setup.py:
3-
__version__ = '4.27.0'
3+
__version__ = '4.28.0'

tests/test_types.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,13 +242,13 @@ def test_json_chat_invite_link():
242242

243243

244244
def test_chat_member_updated():
245-
json_string = r'{"chat": {"id": -1234567890123, "type": "supergroup", "title": "No Real Group", "username": "NoRealGroup"}, "from": {"id": 133869498, "is_bot": false, "first_name": "Vincent"}, "date": 1624119999, "old_chat_member": {"user": {"id": 77777777, "is_bot": false, "first_name": "Pepe"}, "status": "member"}, "new_chat_member": {"user": {"id": 77777777, "is_bot": false, "first_name": "Pepe"}, "status": "administrator"}}'
245+
json_string = r'{"chat": {"id": -1234567890123, "type": "supergroup", "title": "No Real Group", "username": "NoRealGroup"}, "from": {"id": 133869498, "is_bot": false, "first_name": "Vincent"}, "date": 1624119999, "old_chat_member": {"user": {"id": 77777777, "is_bot": false, "first_name": "Pepe"}, "status": "member"}, "new_chat_member": {"user": {"id": 77777777, "is_bot": false, "first_name": "Pepe"}, "status": "left"}}'
246246
cm_updated = types.ChatMemberUpdated.de_json(json_string)
247247
assert cm_updated.chat.id == -1234567890123
248248
assert cm_updated.from_user.id == 133869498
249249
assert cm_updated.date == 1624119999
250250
assert cm_updated.old_chat_member.status == "member"
251-
assert cm_updated.new_chat_member.status == "administrator"
251+
assert cm_updated.new_chat_member.status == "left"
252252

253253

254254
def test_webhook_info():
@@ -309,5 +309,3 @@ def test_message_entity():
309309
sample_string_7 = r'{"update_id":934522167,"message":{"message_id":1374526,"from":{"id":927266710,"is_bot":false,"first_name":">_run","username":"coder2020","language_code":"en","is_premium":true},"chat":{"id":927266710,"first_name":">_run","username":"coder2020","type":"private"},"date":1682179716,"reply_to_message":{"message_id":1374510,"from":{"id":927266710,"is_bot":false,"first_name":">_run","username":"coder2020","language_code":"en"},"chat":{"id":927266710,"first_name":">_run","username":"coder2020","type":"private"},"date":1712765863,"text":"text @UserName b i s u c p #hashtag https://example.com","entities":[{"offset":5,"length":9,"type":"mention"},{"offset":15,"length":1,"type":"bold"},{"offset":17,"length":1,"type":"italic"},{"offset":19,"length":1,"type":"strikethrough"},{"offset":21,"length":1,"type":"underline"},{"offset":23,"length":1,"type":"code"},{"offset":25,"length":1,"type":"spoiler"},{"offset":27,"length":8,"type":"hashtag"},{"offset":36,"length":19,"type":"url"}],"link_preview_options":{"is_disabled":true}},"quote":{"text":"text @UserName b i s u c p #hashtag https://example.com","entities":[{"offset":15,"length":1,"type":"bold"},{"offset":17,"length":1,"type":"italic"},{"offset":19,"length":1,"type":"strikethrough"},{"offset":21,"length":1,"type":"underline"},{"offset":25,"length":1,"type":"spoiler"}],"position":0,"is_manual":true},"text":"quote reply"}}'
310310
message_7 = types.Update.de_json(sample_string_7).message
311311
assert message_7.quote.html_text == 'text @UserName <b>b</b> <i>i</i> <s>s</s> <u>u</u> c <span class="tg-spoiler">p</span> #hashtag https://example.com'
312-
313-

0 commit comments

Comments
 (0)