From 76a4012e42c6df9231c83e58d2fdab993f838be4 Mon Sep 17 00:00:00 2001 From: Sreelal TS Date: Sat, 5 Oct 2024 18:06:54 +0530 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=8D=80=20Allow=20specifying=20custom?= =?UTF-8?q?=20headers=20and=20mime=20type=20for=20InputFile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/src/televerse/api/raw_api.dart | 2 ++ lib/src/televerse/models/input_file.dart | 22 +++++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/lib/src/televerse/api/raw_api.dart b/lib/src/televerse/api/raw_api.dart index 878d91c5..66b003b8 100644 --- a/lib/src/televerse/api/raw_api.dart +++ b/lib/src/televerse/api/raw_api.dart @@ -171,6 +171,8 @@ class RawAPI { e.field: LocalFile( e.file.getBytes(), fileName: e.name, + headers: e.file.headers, + contentType: e.file.mimeType, ), }; }).toList(); diff --git a/lib/src/televerse/models/input_file.dart b/lib/src/televerse/models/input_file.dart index fd3a25d4..97bc6cf8 100644 --- a/lib/src/televerse/models/input_file.dart +++ b/lib/src/televerse/models/input_file.dart @@ -35,18 +35,28 @@ class InputFile { /// The bytes of the file. final Uint8List? bytes; + /// Mime Type of the File + final String? mimeType; + + /// Additional headers + final Map>? headers; + /// Private constructor for [InputFile]. const InputFile._({ this.fileId, this.url, this.bytes, this.name, + this.headers, + this.mimeType, }); /// Creates a new [InputFile] using a local file. factory InputFile.fromFile( io.File file, { String? name, + String? mimeType, + Map>? headers, }) { if (!file.existsSync()) { throw TeleverseException.fileDoesNotExist(file.path); @@ -54,6 +64,8 @@ class InputFile { return InputFile._( bytes: file.readAsBytesSync(), name: name ?? file.filename, + mimeType: mimeType, + headers: headers, ); } @@ -70,9 +82,17 @@ class InputFile { ); /// Creates a new [InputFile] using the bytes of the file. - factory InputFile.fromBytes(Uint8List bytes, {String? name}) => InputFile._( + factory InputFile.fromBytes( + Uint8List bytes, { + String? name, + String? mimeType, + Map>? headers, + }) => + InputFile._( bytes: bytes, name: name, + mimeType: mimeType, + headers: headers, ); /// Returns the type of the [InputFile]. From 6d2ac10696cec703b76c4cc7fb0d95d88257de3b Mon Sep 17 00:00:00 2001 From: Sreelal TS Date: Wed, 23 Oct 2024 11:57:06 +0530 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=90=9E=20Fix:=20`ReactionTypeCustomEm?= =?UTF-8?q?oji.customEmojiId`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/src/telegram/models/reaction_type_custom_emoji.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/src/telegram/models/reaction_type_custom_emoji.dart b/lib/src/telegram/models/reaction_type_custom_emoji.dart index e2c5e2ae..39fe7968 100644 --- a/lib/src/telegram/models/reaction_type_custom_emoji.dart +++ b/lib/src/telegram/models/reaction_type_custom_emoji.dart @@ -7,11 +7,11 @@ class ReactionTypeCustomEmoji implements ReactionType { final ReactionTypeType type = ReactionTypeType.customEmoji; /// Custom emoji identifier - final String customEmoji; + final String customEmojiId; /// Constructs a [ReactionTypeCustomEmoji] object const ReactionTypeCustomEmoji({ - required this.customEmoji, + required this.customEmojiId, }); /// Converts a [ReactionTypeCustomEmoji] object to JSON object @@ -19,14 +19,14 @@ class ReactionTypeCustomEmoji implements ReactionType { Map toJson() { return { 'type': type.value, - 'custom_emoji': customEmoji, + 'custom_emoji_id': customEmojiId, }; } /// Creates a [ReactionTypeCustomEmoji] object from JSON object factory ReactionTypeCustomEmoji.fromJson(Map json) { return ReactionTypeCustomEmoji( - customEmoji: json['custom_emoji']!, + customEmojiId: json['custom_emoji_id']!, ); } } From 259ff2c60a603f6fa696e801c8cf18d5c9878d6c Mon Sep 17 00:00:00 2001 From: Sreelal TS Date: Wed, 23 Oct 2024 11:58:07 +0530 Subject: [PATCH 3/3] =?UTF-8?q?=E2=84=B9=EF=B8=8F=20Changes?= 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 77ccca61..00a09a9b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 1.26.5 + +- Fixed in `ReactionTypeCustomEmoji.customEmojiId` + # 1.26.4 - Added `LocalFile` class. diff --git a/pubspec.yaml b/pubspec.yaml index 12a57610..7ba61f00 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.10! -version: 1.26.4 +version: 1.26.5 homepage: https://televerse.xooniverse.com repository: https://github.com/xooniverse/televerse topics: