Skip to content
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

Fix issue with thumbnail in InputMedia types #2434

Merged
merged 2 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions telebot/apihelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -2271,6 +2271,12 @@ def convert_input_media_array(array):
if media_dict['media'].startswith('attach://'):
key = media_dict['media'].replace('attach://', '')
files[key] = input_media.media
if 'thumbnail' in media_dict:
thumbnail = media_dict['thumbnail']
if isinstance(thumbnail, types.InputFile):
thumbnail_key = 'thumbnail_' + key
files[thumbnail_key] = thumbnail
media_dict['thumbnail'] = 'attach://' + thumbnail_key
media.append(media_dict)
return json.dumps(media), files

Expand Down
6 changes: 6 additions & 0 deletions telebot/asyncio_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -2243,6 +2243,12 @@ async def convert_input_media_array(array):
if media_dict['media'].startswith('attach://'):
key = media_dict['media'].replace('attach://', '')
files[key] = input_media.media
if 'thumbnail' in media_dict:
thumbnail = media_dict['thumbnail']
if isinstance(thumbnail, types.InputFile):
thumbnail_key = 'thumbnail_' + key
files[thumbnail_key] = thumbnail
media_dict['thumbnail'] = 'attach://' + thumbnail_key
media.append(media_dict)
return json.dumps(media), files

Expand Down
Loading