Skip to content

Commit

Permalink
updated changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
DinoLeung committed Mar 31, 2024
1 parent 54b5a07 commit 80c9651
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
8 changes: 7 additions & 1 deletion example/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> main() async {
final envVars = Platform.environment;
Expand Down Expand Up @@ -31,7 +32,12 @@ Future<void> 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
Expand Down
16 changes: 4 additions & 12 deletions lib/src/telegram/models/dice.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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('🎲')
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion lib/src/telegram/telegram.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1066,7 +1066,7 @@ class Telegram {
var body = <String, dynamic>{
'chat_id': chatId,
'message_thread_id': messageThreadId,
'emoji': emoji.getEmoji(),
'emoji': emoji.value(),
'disable_notification': disableNotification,
'protect_content': protectContent,
'reply_to_message_id': replyToMessageId,
Expand Down

0 comments on commit 80c9651

Please sign in to comment.