Skip to content

Commit

Permalink
updated sticker methods
Browse files Browse the repository at this point in the history
  • Loading branch information
DinoLeung committed Aug 27, 2023
1 parent 741cc26 commit 4e01eb3
Show file tree
Hide file tree
Showing 6 changed files with 216 additions and 96 deletions.
1 change: 1 addition & 0 deletions lib/src/telegram/model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ part 'models/input_media_photo.dart';
part 'models/input_media_video.dart';
part 'models/input_media.dart';
part 'models/input_message_content.dart';
part 'models/input_sticker.dart';
part 'models/input_text_message_content.dart';
part 'models/input_venue_message_content.dart';
part 'models/invoice.dart';
Expand Down
32 changes: 32 additions & 0 deletions lib/src/telegram/model.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 50 additions & 0 deletions lib/src/telegram/models/input_sticker.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* TeleDart - Telegram Bot API for Dart
* Copyright (C) 2023 Dino PH Leung
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

part of '../model.dart';

/// This object describes a sticker to be added to a sticker set.
///
/// https://core.telegram.org/bots/api#inputsticker
@JsonSerializable(fieldRename: FieldRename.snake)
class InputSticker {
dynamic sticker; // InputFile or String
List<String> emojiList;
MaskPosition? maskPosition;
List<String>? keywords;

InputSticker({
required this.sticker,
required this.emojiList,
this.maskPosition,
this.keywords,
});

factory InputSticker.fromJson(Map<String, dynamic> json) =>
_$InputStickerFromJson(json);
Map<String, dynamic> toJson() => _$InputStickerToJson(this);
}

// TODO: The added sticker. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, upload a new one using multipart/form-data, or pass “attach://<file_attach_name>” to upload a new one using multipart/form-data under <file_attach_name> name. Animated and video stickers can't be uploaded via HTTP URL.
// Need to update files uploading for InputMedia type
// filename cannot be empty when posting to Telegram server
// var files = List<MultipartFile>.filled(
// 1,
// MultipartFile(
// 'png_sticker', pngSticker.openRead(), pngSticker.lengthSync(),
// filename: '${pngSticker.lengthSync()}'));
2 changes: 2 additions & 0 deletions lib/src/telegram/models/sticker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class Sticker {
File? premiumAnimation;
MaskPosition? maskPosition;
String? customEmojiId;
bool? needsRepainting;
int? fileSize;
Sticker({
required this.fileId,
Expand All @@ -49,6 +50,7 @@ class Sticker {
this.premiumAnimation,
this.maskPosition,
this.customEmojiId,
this.needsRepainting,
this.fileSize,
});
factory Sticker.fromJson(Map<String, dynamic> json) =>
Expand Down
2 changes: 1 addition & 1 deletion lib/src/telegram/models/voice.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

part of '../model.dart';

///This object represents a voice note.
/// This object represents a voice note.
///
/// https://core.telegram.org/bots/api#voice
@JsonSerializable(fieldRename: FieldRename.snake)
Expand Down
Loading

0 comments on commit 4e01eb3

Please sign in to comment.