Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
3fb1488
Make `allow_sending_without_reply`, `reply_to_message_id` and `disabl…
Bibo-Joshi Feb 11, 2024
5785813
Merge branch 'master' into remove-api-7.0-deprecations
Bibo-Joshi Feb 11, 2024
c72d338
Remove `UserShared` and `KeyboardButtonRequestUser`
Bibo-Joshi Feb 12, 2024
f004701
Feat: API 7.1
Poolitzer Feb 15, 2024
ca3b638
Remove rest & adapt tests
Bibo-Joshi Feb 16, 2024
2816ffa
Try Fixing docs
Bibo-Joshi Feb 16, 2024
dd12f84
Try harder
Bibo-Joshi Feb 16, 2024
391cebf
Code Coverage
Bibo-Joshi Feb 16, 2024
e3fd1d2
Fix: move Chatboostadded to the correct file
Poolitzer Feb 16, 2024
f39d62d
Feat: Mark admin right stories as non optional
Poolitzer Feb 16, 2024
2a9812e
Feat: Mark chat member right stories as non optional
Poolitzer Feb 16, 2024
1aeee91
Fix: Small review things
Poolitzer Feb 16, 2024
0829abd
Feat: Trying to improve workflow trigger
Poolitzer Feb 16, 2024
fe7dff7
review
Bibo-Joshi Feb 18, 2024
2341d92
Apply suggestions from code review
Poolitzer Feb 24, 2024
ad654a5
Fix: Apply suggestions
Poolitzer Feb 24, 2024
b72df90
Fix: Fixing tests
Poolitzer Feb 24, 2024
7b354b1
Fix: Adding filters
Poolitzer Feb 24, 2024
03caaa1
Merge remote-tracking branch 'origin/api-7.1' into api-7.1
Poolitzer Feb 24, 2024
bb48f5b
Merge branch 'remove-api-7.0-deprecations' into api-7.1
Poolitzer Feb 24, 2024
7fe0639
Fix: Missed adding optionals here
Poolitzer Feb 24, 2024
5b6a116
Merge remote-tracking branch 'origin/api-7.1' into api-7.1
Poolitzer Feb 24, 2024
2e05aa5
Merge branch 'master' into api-7.1
Bibo-Joshi Feb 25, 2024
e1b4249
Merge branch 'master' into api-7.1
Poolitzer Feb 28, 2024
8791fc6
Update telegram/_chatadministratorrights.py
Poolitzer Feb 28, 2024
6b020fc
Fix: add ignore for official test
Poolitzer Feb 28, 2024
946f2af
Fix: remove optional from docstring
Poolitzer Feb 28, 2024
d150956
Merge remote-tracking branch 'origin/api-7.1' into api-7.1
Poolitzer Feb 28, 2024
b8489fe
Fix: pre commit failling
Poolitzer Feb 28, 2024
2cc97a7
Fix: Remove double version added
Poolitzer Feb 29, 2024
ad1e219
Fix: Improve workflow trigger
Poolitzer Feb 29, 2024
f20e0b7
Merge branch 'master' into api-7.1
Bibo-Joshi Mar 2, 2024
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
7 changes: 3 additions & 4 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
name: Test Documentation Build
on:
pull_request:
branches:
- master
- doc-fixes
paths:
- telegram/**
Comment thread
Bibo-Joshi marked this conversation as resolved.
- docs/**
push:
branches:
- master
- doc-fixes

jobs:
test-sphinx-build:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/test_official.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
name: Bot API Tests
on:
pull_request:
branches:
- master
paths:
- telegram/**
- tests/**
push:
branches:
- master
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/type_completeness.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Check Type Completeness
on:
pull_request:
branches:
- master
paths:
- telegram/**
push:
branches:
- master
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
name: Unit Tests
on:
pull_request:
branches:
- master

paths:
- telegram/**
- tests/**
push:
branches:
- master

schedule:
# Run monday and friday morning at 03:07 - odd time to spread load on GitHub Actions
- cron: '7 3 * * 1,5'
Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
:target: https://pypi.org/project/python-telegram-bot/
:alt: Supported Python versions

.. image:: https://img.shields.io/badge/Bot%20API-7.0-blue?logo=telegram
.. image:: https://img.shields.io/badge/Bot%20API-7.1-blue?logo=telegram
:target: https://core.telegram.org/bots/api-changelog
:alt: Supported Bot API versions

Expand Down Expand Up @@ -93,7 +93,7 @@ Installing both ``python-telegram-bot`` and ``python-telegram-bot-raw`` in conju
Telegram API support
====================

All types and methods of the Telegram Bot API **7.0** are supported.
All types and methods of the Telegram Bot API **7.1** are supported.

Installing
==========
Expand Down
4 changes: 2 additions & 2 deletions README_RAW.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
:target: https://pypi.org/project/python-telegram-bot-raw/
:alt: Supported Python versions

.. image:: https://img.shields.io/badge/Bot%20API-7.0-blue?logo=telegram
.. image:: https://img.shields.io/badge/Bot%20API-7.1-blue?logo=telegram
:target: https://core.telegram.org/bots/api-changelog
:alt: Supported Bot API versions

Expand Down Expand Up @@ -89,7 +89,7 @@ Installing both ``python-telegram-bot`` and ``python-telegram-bot-raw`` in conju
Telegram API support
====================

All types and methods of the Telegram Bot API **7.0** are supported.
All types and methods of the Telegram Bot API **7.1** are supported.

Installing
==========
Expand Down
1 change: 1 addition & 0 deletions docs/source/telegram.at-tree.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Available Types
telegram.chat
telegram.chatadministratorrights
telegram.chatboost
telegram.chatboostadded
telegram.chatboostremoved
telegram.chatboostsource
telegram.chatboostsourcegiftcode
Expand Down
6 changes: 6 additions & 0 deletions docs/source/telegram.chatboostadded.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ChatBoostAdded
==============

.. autoclass:: telegram.ChatBoostAdded
:members:
:show-inheritance:
2 changes: 2 additions & 0 deletions docs/substitutions/global.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,5 @@
.. |reply_quote| replace:: If set to :obj:`True`, the reply is sent as an actual reply to this message. If ``reply_to_message_id`` is passed, this parameter will be ignored. Default: :obj:`True` in group chats and :obj:`False` in private chats.

.. |do_quote| replace:: If set to :obj:`True`, the replied message is quoted. For a dict, it must be the output of :meth:`~telegram.Message.build_reply_arguments` to specify exact ``reply_parameters``. If ``reply_to_message_id`` or ``reply_parameters`` are passed, this parameter will be ignored. Default: :obj:`True` in group chats and :obj:`False` in private chats.

.. |non_optional_story_argument| replace:: As of this version, this argument is now required. In accordance with our `stability policy <https://docs.python-telegram-bot.org/en/stable/stability_policy.html>`__, the signature will be kept as optional for now, though they are mandatory and an error will be raised if you don't pass it.
2 changes: 2 additions & 0 deletions telegram/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"Chat",
"ChatAdministratorRights",
"ChatBoost",
"ChatBoostAdded",
"ChatBoostRemoved",
"ChatBoostSource",
"ChatBoostSourceGiftCode",
Expand Down Expand Up @@ -242,6 +243,7 @@
from ._chatadministratorrights import ChatAdministratorRights
from ._chatboost import (
ChatBoost,
ChatBoostAdded,
ChatBoostRemoved,
ChatBoostSource,
ChatBoostSourceGiftCode,
Expand Down
14 changes: 7 additions & 7 deletions telegram/_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -5250,10 +5250,10 @@ async def promote_chat_member(
user_id (:obj:`int`): Unique identifier of the target user.
is_anonymous (:obj:`bool`, optional): Pass :obj:`True`, if the administrator's presence
in the chat is hidden.
can_manage_chat (:obj:`bool`, optional): Pass :obj:`True`, if the administrator can
access the chat event log, chat statistics, boost list in channels, see channel
members, report spam messages, see anonymous administrators in supergroups and
ignore slow mode. Implied by any other administrator privilege.
can_manage_chat (:obj:`bool`, optional): Pass :obj:`True`, if the administrator can
access the chat event log, get boost list, see hidden supergroup and channel
members, report spam messages and ignore slow mode. Implied by any other
administrator privilege.

.. versionadded:: 13.4

Expand Down Expand Up @@ -5285,15 +5285,15 @@ async def promote_chat_member(

.. versionadded:: 20.0
can_post_stories (:obj:`bool`, optional): Pass :obj:`True`, if the administrator can
post stories in the channel; channels only.
post stories to the chat.

.. versionadded:: 20.6
can_edit_stories (:obj:`bool`, optional): Pass :obj:`True`, if the administrator can
edit stories posted by other users; channels only.
edit stories posted by other users.

.. versionadded:: 20.6
can_delete_stories (:obj:`bool`, optional): Pass :obj:`True`, if the administrator can
delete stories posted by other users; channels only.
delete stories posted by other users.

.. versionadded:: 20.6

Expand Down
26 changes: 26 additions & 0 deletions telegram/_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,16 @@ class Chat(TelegramObject):
:meth:`telegram.Bot.get_chat`.

.. versionadded:: 20.0
unrestrict_boost_count (:obj:`int`, optional): For supergroups, the minimum number of
boosts that a non-administrator user needs to add in order to ignore slow mode and chat
permissions. Returned only in :meth:`telegram.Bot.get_chat`.

.. versionadded:: NEXT.VERSION
custom_emoji_sticker_set_name (:obj:`str`, optional): For supergroups, the name of the
group's custom emoji sticker set. Custom emoji from this set can be used by all users
and bots in the group. Returned only in :meth:`telegram.Bot.get_chat`.

.. versionadded:: NEXT.VERSION

Attributes:
id (:obj:`int`): Unique identifier for this chat. This number may be greater than 32 bits
Expand Down Expand Up @@ -352,6 +362,16 @@ class Chat(TelegramObject):
:meth:`telegram.Bot.get_chat`.

.. versionadded:: 20.0
unrestrict_boost_count (:obj:`int`): Optional. For supergroups, the minimum number of
boosts that a non-administrator user needs to add in order to ignore slow mode and chat
permissions. Returned only in :meth:`telegram.Bot.get_chat`.

.. versionadded:: NEXT.VERSION
custom_emoji_sticker_set_name (:obj:`str`): Optional. For supergroups, the name of the
group's custom emoji sticker set. Custom emoji from this set can be used by all users
and bots in the group. Returned only in :meth:`telegram.Bot.get_chat`.

.. versionadded:: NEXT.VERSION

.. _topics: https://telegram.org/blog/topics-in-groups-collectible-usernames#topics-in-groups
.. _accent colors: https://core.telegram.org/bots/api#accent-colors
Expand All @@ -364,6 +384,7 @@ class Chat(TelegramObject):
"background_custom_emoji_id",
"bio",
"can_set_sticker_set",
"custom_emoji_sticker_set_name",
"description",
"emoji_status_custom_emoji_id",
"emoji_status_expiration_date",
Expand Down Expand Up @@ -392,6 +413,7 @@ class Chat(TelegramObject):
"sticker_set_name",
"title",
"type",
"unrestrict_boost_count",
"username",
)

Expand Down Expand Up @@ -446,6 +468,8 @@ def __init__(
profile_accent_color_id: Optional[int] = None,
profile_background_custom_emoji_id: Optional[str] = None,
has_visible_history: Optional[bool] = None,
unrestrict_boost_count: Optional[int] = None,
custom_emoji_sticker_set_name: Optional[str] = None,
*,
api_kwargs: Optional[JSONDict] = None,
):
Expand Down Expand Up @@ -493,6 +517,8 @@ def __init__(
self.background_custom_emoji_id: Optional[str] = background_custom_emoji_id
self.profile_accent_color_id: Optional[int] = profile_accent_color_id
self.profile_background_custom_emoji_id: Optional[str] = profile_background_custom_emoji_id
self.unrestrict_boost_count: Optional[int] = unrestrict_boost_count
self.custom_emoji_sticker_set_name: Optional[str] = custom_emoji_sticker_set_name

self._id_attrs = (self.id,)

Expand Down
58 changes: 37 additions & 21 deletions telegram/_chatadministratorrights.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@ class ChatAdministratorRights(TelegramObject):
Args:
is_anonymous (:obj:`bool`): :obj:`True`, if the user's presence in the chat is hidden.
can_manage_chat (:obj:`bool`): :obj:`True`, if the administrator can access the chat event
log, chat statistics, boost list in channels, see channel members, report spam
messages, see anonymous administrators in supergroups and ignore slow mode.
Implied by any other administrator privilege.
log, get boost list, see hidden supergroup and channel members, report spam messages
and ignore slow mode. Implied by any other administrator privilege.
can_delete_messages (:obj:`bool`): :obj:`True`, if the administrator can delete messages of
other users.
can_manage_video_chats (:obj:`bool`): :obj:`True`, if the administrator can manage video
Expand All @@ -70,18 +69,24 @@ class ChatAdministratorRights(TelegramObject):
messages of other users.
can_pin_messages (:obj:`bool`, optional): :obj:`True`, if the user is allowed to pin
messages; groups and supergroups only.
can_post_stories (:obj:`bool`, optional): :obj:`True`, if the administrator can post
stories in the channel; channels only.
can_post_stories (:obj:`bool`): :obj:`True`, if the administrator can post
stories to the chat.
Comment thread
Bibo-Joshi marked this conversation as resolved.

.. versionadded:: 20.6
can_edit_stories (:obj:`bool`, optional): :obj:`True`, if the administrator can edit
stories posted by other users; channels only.
.. versionchanged:: NEXT.VERSION
|non_optional_story_argument|
Comment thread
Poolitzer marked this conversation as resolved.
can_edit_stories (:obj:`bool`): :obj:`True`, if the administrator can edit
stories posted by other users.

.. versionadded:: 20.6
can_delete_stories (:obj:`bool`, optional): :obj:`True`, if the administrator can delete
stories posted by other users; channels only.
.. versionchanged:: NEXT.VERSION
|non_optional_story_argument|
can_delete_stories (:obj:`bool`): :obj:`True`, if the administrator can delete
stories posted by other users.

.. versionadded:: 20.6
.. versionchanged:: NEXT.VERSION
|non_optional_story_argument|
can_manage_topics (:obj:`bool`, optional): :obj:`True`, if the user is allowed
to create, rename, close, and reopen forum topics; supergroups only.

Expand All @@ -90,9 +95,8 @@ class ChatAdministratorRights(TelegramObject):
Attributes:
is_anonymous (:obj:`bool`): :obj:`True`, if the user's presence in the chat is hidden.
can_manage_chat (:obj:`bool`): :obj:`True`, if the administrator can access the chat event
log, chat statistics, boost list in channels, see channel members, report spam
messages, see anonymous administrators in supergroups and ignore slow mode.
Implied by any other administrator privilege.
log, get boost list, see hidden supergroup and channel members, report spam messages
and ignore slow mode. Implied by any other administrator privilege.
can_delete_messages (:obj:`bool`): :obj:`True`, if the administrator can delete messages of
other users.
can_manage_video_chats (:obj:`bool`): :obj:`True`, if the administrator can manage video
Expand All @@ -113,18 +117,24 @@ class ChatAdministratorRights(TelegramObject):
messages of other users.
can_pin_messages (:obj:`bool`): Optional. :obj:`True`, if the user is allowed to pin
messages; groups and supergroups only.
can_post_stories (:obj:`bool`): Optional. :obj:`True`, if the administrator can post
stories in the channel; channels only.
can_post_stories (:obj:`bool`): :obj:`True`, if the administrator can post
stories to the chat.

.. versionadded:: 20.6
can_edit_stories (:obj:`bool`): Optional. :obj:`True`, if the administrator can edit
stories posted by other users; channels only.
.. versionchanged:: NEXT.VERSION
|non_optional_story_argument|
can_edit_stories (:obj:`bool`): :obj:`True`, if the administrator can edit
stories posted by other users.

.. versionadded:: 20.6
can_delete_stories (:obj:`bool`): Optional. :obj:`True`, if the administrator can delete
stories posted by other users; channels only.
.. versionchanged:: NEXT.VERSION
|non_optional_story_argument|
can_delete_stories (:obj:`bool`): :obj:`True`, if the administrator can delete
stories posted by other users.

.. versionadded:: 20.6
.. versionchanged:: NEXT.VERSION
|non_optional_story_argument|
can_manage_topics (:obj:`bool`): Optional. :obj:`True`, if the user is allowed
to create, rename, close, and reopen forum topics; supergroups only.

Expand Down Expand Up @@ -179,13 +189,19 @@ def __init__(
self.can_promote_members: bool = can_promote_members
self.can_change_info: bool = can_change_info
self.can_invite_users: bool = can_invite_users
# Not actually optionals but because of backwards compatability we pretend they are
if can_post_stories is None or can_edit_stories is None or can_delete_stories is None:
raise TypeError(
"As of vNEXT.VERSION can_post_stories, can_edit_stories and can_delete_stories"
" must be set in order to create this object."
)
self.can_post_stories: bool = can_post_stories
self.can_edit_stories: bool = can_edit_stories
self.can_delete_stories: bool = can_delete_stories
# Optionals
self.can_post_messages: Optional[bool] = can_post_messages
self.can_edit_messages: Optional[bool] = can_edit_messages
self.can_pin_messages: Optional[bool] = can_pin_messages
self.can_post_stories: Optional[bool] = can_post_stories
self.can_edit_stories: Optional[bool] = can_edit_stories
self.can_delete_stories: Optional[bool] = can_delete_stories
self.can_manage_topics: Optional[bool] = can_manage_topics

self._id_attrs = (
Expand Down
33 changes: 33 additions & 0 deletions telegram/_chatboost.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,39 @@
from telegram import Bot


class ChatBoostAdded(TelegramObject):
"""
This object represents a service message about a user boosting a chat.

Objects of this class are comparable in terms of equality.
Two objects of this class are considered equal, if their
:attr:`boost_count` are equal.

.. versionadded:: NEXT.VERSION

Args:
boost_count (:obj:`int`): Number of boosts added by the user.

Attributes:
boost_count (:obj:`int`): Number of boosts added by the user.

"""

__slots__ = ("boost_count",)

def __init__(
self,
boost_count: int,
*,
api_kwargs: Optional[JSONDict] = None,
) -> None:
super().__init__(api_kwargs=api_kwargs)
self.boost_count: int = boost_count
self._id_attrs = (self.boost_count,)

self._freeze()


class ChatBoostSource(TelegramObject):
"""
Base class for Telegram ChatBoostSource objects. It can be one of:
Expand Down
Loading