From 4495a5b7046c0d30524984c765168973ef2a43ea Mon Sep 17 00:00:00 2001 From: Sreelal TS Date: Sat, 2 Nov 2024 12:20:50 +0530 Subject: [PATCH 1/3] =?UTF-8?q?=E2=AD=90=EF=B8=8F=20Fix=20`sendPaidMedia`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../models/abstracts/input_paid_media.dart | 3 +++ .../telegram/models/input_paid_media_photo.dart | 8 ++++++++ .../telegram/models/input_paid_media_video.dart | 14 ++++++++++++++ lib/src/televerse/api/raw_api.dart | 6 ++++-- 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/lib/src/telegram/models/abstracts/input_paid_media.dart b/lib/src/telegram/models/abstracts/input_paid_media.dart index 772a7ba8..1da72de5 100644 --- a/lib/src/telegram/models/abstracts/input_paid_media.dart +++ b/lib/src/telegram/models/abstracts/input_paid_media.dart @@ -17,4 +17,7 @@ sealed class InputPaidMedia { /// Converts an [InputPaidMedia] to a [Map] for JSON encoding. Map toJson(); + + /// Converts [InputPaidMedia] to a [Map] for JSON encoding + Map getValue([String? field, String? thumb]); } diff --git a/lib/src/telegram/models/input_paid_media_photo.dart b/lib/src/telegram/models/input_paid_media_photo.dart index fbff167e..3324becc 100644 --- a/lib/src/telegram/models/input_paid_media_photo.dart +++ b/lib/src/telegram/models/input_paid_media_photo.dart @@ -25,4 +25,12 @@ class InputPaidMediaPhoto implements InputPaidMedia { 'media': media.getValue('media'), }; } + + @override + Map getValue([String? field, String? thumb]) { + return { + 'type': type.value, + 'media': media.getValue(field), + }; + } } diff --git a/lib/src/telegram/models/input_paid_media_video.dart b/lib/src/telegram/models/input_paid_media_video.dart index 0a206648..0901bf6c 100644 --- a/lib/src/telegram/models/input_paid_media_video.dart +++ b/lib/src/telegram/models/input_paid_media_video.dart @@ -50,4 +50,18 @@ class InputPaidMediaVideo implements InputPaidMedia { 'supports_streaming': supportsStreaming, }..removeWhere(_nullFilter); } + + /// Converts a [InputPaidMediaVideo] object to JSON. + @override + Map getValue([String? field, String? thumb]) { + return { + 'type': type.value, + 'media': media.getValue(field), + 'thumbnail': thumbnail?.getValue(thumb), + 'width': width, + 'height': height, + 'duration': duration, + 'supports_streaming': supportsStreaming, + }..removeWhere(_nullFilter); + } } diff --git a/lib/src/televerse/api/raw_api.dart b/lib/src/televerse/api/raw_api.dart index 5bdaf2cf..bc40742b 100644 --- a/lib/src/televerse/api/raw_api.dart +++ b/lib/src/televerse/api/raw_api.dart @@ -4076,9 +4076,11 @@ class RawAPI { final length = media.length; for (int i = 0; i < length; i++) { + final id = "media$i"; + final thumb = "$_thumb$i"; final m = media[i]; - mediaList.add(m.toJson()); - helpers.add(_MultipartHelper(m.media, "media$i")); + mediaList.add(m.getValue(id, thumb)); + helpers.add(_MultipartHelper(m.media, id)); } final files = _getFiles(helpers); From ab666334639950329cfaed0121e8cdc541f2d3a5 Mon Sep 17 00:00:00 2001 From: Sreelal TS Date: Sat, 2 Nov 2024 12:22:37 +0530 Subject: [PATCH 2/3] =?UTF-8?q?=E2=84=B9=EF=B8=8F=20Version=20&=20Changelo?= =?UTF-8?q?gs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 4 ++++ pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7cdbe1e6..96477ee8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 1.27.1 + +- Fix `RawAPI.sendPaidMedia` crashes while sending local file using `InputFile.fromFile` + # 1.27.0 - 🤖 Bot API 7.11 🎃 diff --git a/pubspec.yaml b/pubspec.yaml index 55aab201..5df6e1af 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: televerse description: Televerse lets you create your own efficient Telegram bots with ease in Dart. Supports latest Telegram Bot API - 7.11! -version: 1.27.0 +version: 1.27.1 homepage: https://televerse.xooniverse.com repository: https://github.com/xooniverse/televerse topics: From ea75631be5bfd9b173d0dc9982ba557b2f49247e Mon Sep 17 00:00:00 2001 From: Sreelal TS Date: Sat, 2 Nov 2024 12:23:06 +0530 Subject: [PATCH 3/3] =?UTF-8?q?=E2=84=B9=EF=B8=8F=20Changelog=20update?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 96477ee8..23f6dd1c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,7 @@ # 1.26.5 -- Fixed in `ReactionTypeCustomEmoji.customEmojiId` +- Fix typo in `ReactionTypeCustomEmoji.customEmojiId` # 1.26.4