Repository navigation
Conversation
send_checklist and edit_message_checklist put the InputChecklist object into the request parameters as is, so it was sent as its str() instead of JSON. replace_sticker_in_set used sticker.to_json() and a GET request, so an InputSticker with an InputFile was sent as an attach:// reference without the file. It now uses convert_input_sticker() and POSTs the file, like add_sticker_to_set. Both in apihelper and asyncio_helper. Item 3 of eternnoir#2624.
3 tasks done
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The focused fixes follow existing helper patterns, include regression coverage, and have no identified blocking issues.
No open issues 🎉
What changed in this PR
Addresses item 3 of #2624 by fixing checklist serialization and replacement sticker uploads in both request helpers.
Changes:
- Serialize checklists as JSON for send and edit requests.
- Upload replacement sticker files using multipart POST requests.
- Add regression tests for synchronous and asynchronous helpers.
| File | Description |
|---|---|
| tests/test_apihelper_95.py | Tests checklist serialization and sticker uploads. |
| telebot/asyncio_helper.py | Fixes asynchronous serialization and uploads. |
| telebot/apihelper.py | Applies matching synchronous fixes. |
Review effort: Balanced
Collaborator
|
LGTM, thank you. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Covers item 3 of #2624.
send_checklistandedit_message_checklistput theInputChecklistobject into the request parameters as is. requests then sendsstr(checklist), i.e.<telebot.types.InputChecklist object at ...>, instead of the JSON the API expects. Both now sendchecklist.to_json(), likereply_parameters.to_json()next to them.replace_sticker_in_set: it sentsticker.to_json()with a GET request. For anInputStickerbuilt from anInputFile, the JSON refers to the file asattach://<name>, but the file itself was never sent. It now usessticker.convert_input_sticker()and POSTs the files, the same asadd_sticker_to_set.The same changes are in
apihelper.pyandasyncio_helper.py. Items 1 and 2 of #2624 (rich message media uploads) are not touched.Describe your tests
New tests in
tests/test_apihelper_95.pyreplaceapihelper._make_request/asyncio_helper._process_requestand check what would be sent:checklistparameter ofsend_checklistandedit_message_checklistis a JSON string with the checklist's title and tasks (sync and async);replace_sticker_in_setwith anInputFilesticker sends the file under the name theattach://reference uses, withmethod='post'(sync and async).All three tests fail without the change and pass with it.
pytest tests --ignore=tests/test_telebot.py: 290 passed, 2 skipped.Python version: 3.12
OS: Windows 11
Checklist: