Skip to content

Commit

Permalink
πŸ§‘πŸ»β€πŸ”§ Merge #303: Fix sendPaidMedia
Browse files Browse the repository at this point in the history
  • Loading branch information
HeySreelal authored Nov 2, 2024
2 parents a296f9e + ea75631 commit 91b8dac
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 4 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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 πŸŽƒ
Expand All @@ -12,7 +16,7 @@

# 1.26.5

- Fixed in `ReactionTypeCustomEmoji.customEmojiId`
- Fix typo in `ReactionTypeCustomEmoji.customEmojiId`

# 1.26.4

Expand Down
3 changes: 3 additions & 0 deletions lib/src/telegram/models/abstracts/input_paid_media.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ sealed class InputPaidMedia {

/// Converts an [InputPaidMedia] to a [Map] for JSON encoding.
Map<String, dynamic> toJson();

/// Converts [InputPaidMedia] to a [Map] for JSON encoding
Map<String, dynamic> getValue([String? field, String? thumb]);
}
8 changes: 8 additions & 0 deletions lib/src/telegram/models/input_paid_media_photo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,12 @@ class InputPaidMediaPhoto implements InputPaidMedia {
'media': media.getValue('media'),
};
}

@override
Map<String, dynamic> getValue([String? field, String? thumb]) {
return {
'type': type.value,
'media': media.getValue(field),
};
}
}
14 changes: 14 additions & 0 deletions lib/src/telegram/models/input_paid_media_video.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,18 @@ class InputPaidMediaVideo implements InputPaidMedia {
'supports_streaming': supportsStreaming,
}..removeWhere(_nullFilter);
}

/// Converts a [InputPaidMediaVideo] object to JSON.
@override
Map<String, dynamic> 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);
}
}
6 changes: 4 additions & 2 deletions lib/src/televerse/api/raw_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down

0 comments on commit 91b8dac

Please sign in to comment.