Skip to content

Serialize checklists and upload replacement stickers - #2639

Merged
Badiboy merged 1 commit into
eternnoir:masterfrom
cristianchiriac:fix-checklist-json-and-replace-sticker-upload
Oct 24, 2026
Merged

Badiboy merged 1 commit into
eternnoir:masterfrom
cristianchiriac:fix-checklist-json-and-replace-sticker-upload

Conversation

@cristianchiriac

Copy link
Copy Markdown
Contributor

Description

Covers item 3 of #2624.

  • Checklists: send_checklist and edit_message_checklist put the InputChecklist object into the request parameters as is. requests then sends str(checklist), i.e. <telebot.types.InputChecklist object at ...>, instead of the JSON the API expects. Both now send checklist.to_json(), like reply_parameters.to_json() next to them.
  • replace_sticker_in_set: it sent sticker.to_json() with a GET request. For an InputSticker built from an InputFile, the JSON refers to the file as attach://<name>, but the file itself was never sent. It now uses sticker.convert_input_sticker() and POSTs the files, the same as add_sticker_to_set.

The same changes are in apihelper.py and asyncio_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.py replace apihelper._make_request / asyncio_helper._process_request and check what would be sent:

  • the checklist parameter of send_checklist and edit_message_checklist is a JSON string with the checklist's title and tasks (sync and async);
  • replace_sticker_in_set with an InputFile sticker sends the file under the name the attach:// reference uses, with method='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:

  • I added/edited example on new feature/change (if exists)
  • My changes won't break backward compatibility
  • I made changes both for sync and async

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 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

@Badiboy

Badiboy commented Oct 24, 2026

Copy link
Copy Markdown
Collaborator

LGTM, thank you.

@Badiboy
Badiboy merged commit e92b898 into eternnoir:master Oct 24, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants