diff --git a/CHANGELOG.md b/CHANGELOG.md index 03bd64f..d16b8c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## unreleased - support Telegram API 6.9 +- **Breaking** Updated class `Dice`, function `telegram:Telegram.sendDice` and function `teledart:Message.replyDice` to accept enum of `DiceEmoji` instead of emoji string ## 0.6.1 diff --git a/example/main.dart b/example/main.dart index 9eddded..24fcee6 100644 --- a/example/main.dart +++ b/example/main.dart @@ -4,6 +4,7 @@ import 'dart:io' show Platform; import 'package:teledart/teledart.dart'; import 'package:teledart/telegram.dart'; import 'package:teledart/model.dart'; +import 'package:test/test.dart'; Future main() async { final envVars = Platform.environment; @@ -31,7 +32,12 @@ Future main() async { // Sick of boilerplates? Reply messages like below, nice and tidy // Short hands also available for answer query methods teledart.onCommand('glory').listen((message) => message.reply('to Ukraine!')); - teledart.onCommand('dice').listen((message) => message.replyDice(emoji: DiceEmoji.slotMachine)); + teledart.onCommand('dice').listen((message) async { + + var msg = await message.replyDice(emoji: DiceEmoji.slotMachine); + + print(msg.dice?.emoji.value() ?? "no emoji"); + }); // You can also utilise regular expressions teledart diff --git a/lib/src/telegram/models/dice.dart b/lib/src/telegram/models/dice.dart index be5216a..82ab33a 100644 --- a/lib/src/telegram/models/dice.dart +++ b/lib/src/telegram/models/dice.dart @@ -18,9 +18,6 @@ part of '../model.dart'; -/// This object represents an animated emoji that displays a random value. -/// -/// https://core.telegram.org/bots/api#dice @JsonEnum() enum DiceEmoji { @JsonValue('🎲') @@ -38,20 +35,15 @@ enum DiceEmoji { } extension DiceEmojiExtenson on DiceEmoji { - String getEmoji() => _$DiceEmojiEnumMap[this] ?? '🎲'; + String value() => _$DiceEmojiEnumMap[this]!; } +/// This object represents an animated emoji that displays a random value. +/// +/// https://core.telegram.org/bots/api#dice @JsonSerializable(fieldRename: FieldRename.snake) class Dice { - static const emojiDice = '🎲'; - static const emojiDart = '🎯'; - static const emojiBowling = '🎳'; - static const emojiBasketball = '🏀'; - static const emojiFootball = '⚽'; - static const emojiSlotMachine = '🎰'; - int value; - // String emoji; DiceEmoji emoji; Dice({ required this.value, diff --git a/lib/src/telegram/telegram.dart b/lib/src/telegram/telegram.dart index 895e56f..955ee82 100644 --- a/lib/src/telegram/telegram.dart +++ b/lib/src/telegram/telegram.dart @@ -1066,7 +1066,7 @@ class Telegram { var body = { 'chat_id': chatId, 'message_thread_id': messageThreadId, - 'emoji': emoji.getEmoji(), + 'emoji': emoji.value(), 'disable_notification': disableNotification, 'protect_content': protectContent, 'reply_to_message_id': replyToMessageId,