Skip to content

Full Support for Bot API 8.3 #4676

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Mar 1, 2025
Merged

Full Support for Bot API 8.3 #4676

merged 21 commits into from
Mar 1, 2025

Conversation

Poolitzer
Copy link
Member

@Poolitzer Poolitzer commented Feb 12, 2025

First take, needs to be extended

when ready closes #4677


  • Added .. versionadded:: NEXT.VERSION, .. versionchanged:: NEXT.VERSION, .. deprecated:: NEXT.VERSION or .. versionremoved:: NEXT.VERSION to the docstrings for user facing changes (for methods/class descriptions, arguments and attributes)
  • Created new or adapted existing unit tests
  • Documented code changes according to the CSI standard_
  • Added myself alphabetically to AUTHORS.rst (optional)
  • Added new classes & modules to the docs and all suitable __all__ s
  • Checked the Stability Policy in case of deprecations or changes to documented behavior
  • Check the diff files in this channel for documentation updates

If the PR contains API changes (otherwise, you can ignore this passage)

  • Checked the Bot API specific sections of the Stability Policy

  • Created a PR to remove functionality deprecated in the previous Bot API release (see here)

  • New classes:

    • Added self._id_attrs and corresponding documentation
    • __init__ accepts api_kwargs as kw-only
  • Added new shortcuts:

    • In telegram.Chat & telegram.User for all methods that accept chat/user_id
    • In telegram.Message for all methods that accept chat_id and message_id
    • For new telegram.Message shortcuts: Added quote argument if methods accepts reply_to_message_id
    • In telegram.CallbackQuery for all methods that accept either chat_id and message_id or inline_message_id
  • If relevant:

    • Added new constants at telegram.constants and shortcuts to them as class variables

    • Link new and existing constants in docstrings instead of hard-coded numbers and strings

    • Add new message types to telegram.Message.effective_attachment

    • Added new handlers for new update types

      • Add the handlers to the warning loop in the telegram.ext.ConversationHandler
    • Added new filters for new message (sub)types

    • Added or updated documentation for the changed class(es) and/or method(s)

    • Added the new method(s) to _extbot.py

    • Added or updated bot_methods.rst

    • Updated the Bot API version number in all places: README.rst (including the badge) and telegram.constants.BOT_API_VERSION_INFO

    • Added logic for arbitrary callback data in telegram.ext.ExtBot for new methods that either accept a reply_markup in some form or have a return type that is/contains telegram.Message

Copy link

codecov bot commented Feb 12, 2025

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
6529 1 6528 533
View the top 1 failed test(s) by shortest run time
tests.test_gifts.TestGiftWithoutRequest::test_send_gift_without_gift_id
Stack Traces | 0.004s run time
self = <tests.test_gifts.TestGiftWithoutRequest object at 0x00000176A4007790>
offline_bot = PytestExtBot[token=5737018356:AAH138SuiKQF0LDCWsfgWeXfjJ5d63kCWLA]
gift = Gift(id='some_id', remaining_count=5, star_count=5, sticker=Sticker(file_id='file_id', file_unique_id='file_unique_id'...=512, is_animated=False, is_video=False, type=<StickerType.REGULAR>, width=512), total_count=10, upgrade_star_count=10)
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x00000176A5BB8DD0>

    async def test_send_gift_without_gift_id(self, offline_bot, gift, monkeypatch):
        # Only here because we have to temporarily mark gift_id as optional.
        # tags: deprecated NEXT.VERSION
    
        # We can't send actual gifts, so we just check that the correct parameters are passed
        text_entities = [
            MessageEntity(MessageEntity.TEXT_LINK, 0, 4, "url"),
            MessageEntity(MessageEntity.BOLD, 5, 9),
        ]
    
        async def make_assertion(url, request_data: RequestData, *args, **kwargs):
            user_id = request_data.parameters["chat_id"] == "chat_id"
            gift_id = request_data.parameters["gift_id"] == "gift_id"
            text = request_data.parameters["text"] == "text"
            text_parse_mode = request_data.parameters["text_parse_mode"] == "text_parse_mode"
            tes = request_data.parameters["text_entities"] == [
                me.to_dict() for me in text_entities
            ]
            pay_for_upgrade = request_data.parameters["pay_for_upgrade"] is True
    
            return user_id and gift_id and text and text_parse_mode and tes and pay_for_upgrade
    
        monkeypatch.setattr(offline_bot.request, "post", make_assertion)
>       assert await offline_bot.send_gift(
            gift_id=gift,
            text="text",
            text_parse_mode="text_parse_mode",
            text_entities=text_entities,
            pay_for_upgrade=True,
            chat_id="chat_id",
        )
E       assert False

tests\test_gifts.py:190: AssertionError

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@Bibo-Joshi Bibo-Joshi changed the title Api 8.3 Full Support for Bot API 8.3 Feb 12, 2025
@Bibo-Joshi Bibo-Joshi added ⚙️ bot-api affected functionality: bot-api 🔌 enhancement pr description: enhancement labels Feb 17, 2025
@Bibo-Joshi Bibo-Joshi mentioned this pull request Feb 17, 2025
4 tasks
Copy link
Member

@Bibo-Joshi Bibo-Joshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for the PR Pool! I went through the changes a first time and left some comments, nothing mejor though.

@harshil21 harshil21 requested a review from Copilot February 26, 2025 18:25
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 16 out of 16 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (2)

tests/_payment/stars/test_transactionpartner.py:498

  • The equality test creates a TransactionPartnerChat without explicitly passing the 'gift' parameter, while the fixture instance includes it. This may lead to unexpected behavior if 'gift' does not have a consistent default; consider passing 'gift' explicitly or documenting the default behavior.
b = TransactionPartnerChat(
            chat=self.chat,

tests/_payment/stars/test_transactionpartner.py:475

  • [nitpick] Using the literal 'err' as the default value in getattr for verifying slots might mask cases where an attribute's value is legitimately 'err'. Consider using a unique sentinel value to reliably detect missing attributes.
for attr in inst.__slots__:

Bibo-Joshi and others added 7 commits February 26, 2025 21:08
Co-authored-by: Bibo-Joshi <22366557+Bibo-Joshi@users.noreply.github.com>
Co-authored-by: Bibo-Joshi <22366557+Bibo-Joshi@users.noreply.github.com>
Co-authored-by: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com>
@Bibo-Joshi Bibo-Joshi merged commit b75948e into master Mar 1, 2025
26 checks passed
@Bibo-Joshi Bibo-Joshi deleted the api_8.3 branch March 1, 2025 10:13
@github-actions github-actions bot locked and limited conversation to collaborators Mar 9, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
⚙️ bot-api affected functionality: bot-api 🔌 enhancement pr description: enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API 8.3
3 participants