diff --git a/CHANGELOG.md b/CHANGELOG.md index 64c675e..8600d8c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.11.3 + +- Updated to bot API 7.11 + ## 1.11.2 - Added missing type factories diff --git a/README.md b/README.md index bf4044c..0daf2f6 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Dart Telegram Bot is a [Dart](https://dart.dev) wrapper for [Telegram](https://t bot [API](https://core.telegram.org/bots/api). \ It is compatible with Native, Flutter and JS. -[![Bot API Version](https://img.shields.io/badge/Bot%20API-7.9-blue.svg?style=flat-square)](https://core.telegram.org/bots/api) +[![Bot API Version](https://img.shields.io/badge/Bot%20API-7.11-blue.svg?style=flat-square)](https://core.telegram.org/bots/api) [![Dart Version](https://img.shields.io/badge/Dart-3.2.0-blue.svg?style=flat-square)](https://dart.dev) Using Dart Telegram Bot is straightforward, here's an example echo bot: diff --git a/lib/src/entities/internal/tgapi_methods.dart b/lib/src/entities/internal/tgapi_methods.dart index 7d28e35..1fa7c3e 100644 --- a/lib/src/entities/internal/tgapi_methods.dart +++ b/lib/src/entities/internal/tgapi_methods.dart @@ -95,6 +95,7 @@ mixin TGAPIMethods { LinkPreviewOptions? linkPreviewOptions, bool? disableNotification, bool? protectContent, + bool? allowPaidBroadcast, String? messageEffectId, ReplyParameters? replyParameters, ReplyMarkup? replyMarkup, @@ -109,6 +110,7 @@ mixin TGAPIMethods { 'link_preview_options': linkPreviewOptions, 'disable_notification': disableNotification, 'protect_content': protectContent, + 'allow_paid_broadcast': allowPaidBroadcast, 'message_effect_id': messageEffectId, 'reply_parameters': replyParameters, 'reply_markup': replyMarkup, @@ -188,6 +190,7 @@ mixin TGAPIMethods { bool? showCaptionAboveMedia, bool? disableNotification, bool? protectContent, + bool? allowPaidBroadcast, ReplyParameters? replyParameters, ReplyMarkup? replyMarkup, }) { @@ -202,6 +205,7 @@ mixin TGAPIMethods { 'show_caption_above_media': showCaptionAboveMedia, 'disable_notification': disableNotification, 'protect_content': protectContent, + 'allow_paid_broadcast': allowPaidBroadcast, 'reply_parameters': replyParameters, 'reply_markup': replyMarkup, }); @@ -259,6 +263,7 @@ mixin TGAPIMethods { bool? hasSpoiler, bool? disableNotification, bool? protectContent, + bool? allowPaidBroadcast, String? messageEffectId, ReplyParameters? replyParameters, ReplyMarkup? replyMarkup, @@ -275,6 +280,7 @@ mixin TGAPIMethods { 'has_spoiler': hasSpoiler, 'disable_notification': disableNotification, 'protect_content': protectContent, + 'allow_paid_broadcast': allowPaidBroadcast, 'message_effect_id': messageEffectId, 'reply_parameters': replyParameters, 'reply_markup': replyMarkup, @@ -306,6 +312,7 @@ mixin TGAPIMethods { HttpFile? thumbnail, bool? disableNotification, bool? protectContent, + bool? allowPaidBroadcast, String? messageEffectId, ReplyParameters? replyParameters, ReplyMarkup? replyMarkup, @@ -324,6 +331,7 @@ mixin TGAPIMethods { 'thumbnail': thumbnail, 'disable_notification': disableNotification, 'protect_content': protectContent, + 'allow_paid_broadcast': allowPaidBroadcast, 'message_effect_id': messageEffectId, 'reply_parameters': replyParameters, 'reply_markup': replyMarkup, @@ -347,6 +355,7 @@ mixin TGAPIMethods { List? captionEntities, bool? disableNotification, bool? protectContent, + bool? allowPaidBroadcast, String? messageEffectId, ReplyParameters? replyParameters, ReplyMarkup? replyMarkup, @@ -363,6 +372,7 @@ mixin TGAPIMethods { 'thumbnail': thumbnail, 'disable_notification': disableNotification, 'protect_content': protectContent, + 'allow_paid_broadcast': allowPaidBroadcast, 'message_effect_id': messageEffectId, 'reply_parameters': replyParameters, 'reply_markup': replyMarkup, @@ -395,6 +405,7 @@ mixin TGAPIMethods { bool? supportsStreaming, bool? disableNotification, bool? protectContent, + bool? allowPaidBroadcast, String? messageEffectId, ReplyParameters? replyParameters, ReplyMarkup? replyMarkup, @@ -416,6 +427,7 @@ mixin TGAPIMethods { 'supports_streaming': supportsStreaming, 'disable_notification': disableNotification, 'protect_content': protectContent, + 'allow_paid_broadcast': allowPaidBroadcast, 'message_effect_id': messageEffectId, 'reply_parameters': replyParameters, 'reply_markup': replyMarkup, @@ -444,6 +456,7 @@ mixin TGAPIMethods { bool? hasSpoiler, bool? disableNotification, bool? protectContent, + bool? allowPaidBroadcast, String? messageEffectId, ReplyParameters? replyParameters, ReplyMarkup? replyMarkup, @@ -464,6 +477,7 @@ mixin TGAPIMethods { 'has_spoiler': hasSpoiler, 'disable_notification': disableNotification, 'protect_content': protectContent, + 'allow_paid_broadcast': allowPaidBroadcast, 'message_effect_id': messageEffectId, 'reply_parameters': replyParameters, 'reply_markup': replyMarkup, @@ -492,6 +506,7 @@ mixin TGAPIMethods { int? duration, bool? disableNotification, bool? protectContent, + bool? allowPaidBroadcast, String? messageEffectId, ReplyParameters? replyParameters, ReplyMarkup? replyMarkup, @@ -507,6 +522,7 @@ mixin TGAPIMethods { 'duration': duration, 'disable_notification': disableNotification, 'protect_content': protectContent, + 'allow_paid_broadcast': allowPaidBroadcast, 'message_effect_id': messageEffectId, 'reply_parameters': replyParameters, 'reply_markup': replyMarkup, @@ -526,6 +542,7 @@ mixin TGAPIMethods { HttpFile? thumbnail, bool? disableNotification, bool? protectContent, + bool? allowPaidBroadcast, String? messageEffectId, ReplyParameters? replyParameters, ReplyMarkup? replyMarkup, @@ -540,6 +557,7 @@ mixin TGAPIMethods { 'thumbnail': thumbnail, 'disable_notification': disableNotification, 'protect_content': protectContent, + 'allow_paid_broadcast': allowPaidBroadcast, 'message_effect_id': messageEffectId, 'reply_parameters': replyParameters, 'reply_markup': replyMarkup, @@ -597,6 +615,7 @@ mixin TGAPIMethods { int? messageThreadId, bool? disableNotification, bool? protectContent, + bool? allowPaidBroadcast, String? messageEffectId, ReplyParameters? replyParameters, }) { @@ -607,6 +626,7 @@ mixin TGAPIMethods { 'media': media, 'disable_notification': disableNotification, 'protect_content': protectContent, + 'allow_paid_broadcast': allowPaidBroadcast, 'message_effect_id': messageEffectId, 'reply_parameters': replyParameters, }); @@ -627,6 +647,7 @@ mixin TGAPIMethods { int? proximityAlertRadius, bool? disableNotification, bool? protectContent, + bool? allowPaidBroadcast, String? messageEffectId, ReplyParameters? replyParameters, ReplyMarkup? replyMarkup, @@ -643,6 +664,7 @@ mixin TGAPIMethods { 'proximity_alert_radius': proximityAlertRadius, 'disable_notification': disableNotification, 'protect_content': protectContent, + 'allow_paid_broadcast': allowPaidBroadcast, 'message_effect_id': messageEffectId, 'reply_parameters': replyParameters, 'reply_markup': replyMarkup, @@ -666,6 +688,7 @@ mixin TGAPIMethods { String? googlePlaceType, bool? disableNotification, bool? protectContent, + bool? allowPaidBroadcast, String? messageEffectId, ReplyParameters? replyParameters, ReplyMarkup? replyMarkup, @@ -684,6 +707,7 @@ mixin TGAPIMethods { 'google_place_type': googlePlaceType, 'disable_notification': disableNotification, 'protect_content': protectContent, + 'allow_paid_broadcast': allowPaidBroadcast, 'message_effect_id': messageEffectId, 'reply_parameters': replyParameters, 'reply_markup': replyMarkup, @@ -703,6 +727,7 @@ mixin TGAPIMethods { String? vcard, bool? disableNotification, bool? protectContent, + bool? allowPaidBroadcast, String? messageEffectId, ReplyParameters? replyParameters, ReplyMarkup? replyMarkup, @@ -717,6 +742,7 @@ mixin TGAPIMethods { 'vcard': vcard, 'disable_notification': disableNotification, 'protect_content': protectContent, + 'allow_paid_broadcast': allowPaidBroadcast, 'message_effect_id': messageEffectId, 'reply_parameters': replyParameters, 'reply_markup': replyMarkup, @@ -746,6 +772,7 @@ mixin TGAPIMethods { bool? isClosed, bool? disableNotification, bool? protectContent, + bool? allowPaidBroadcast, String? messageEffectId, ReplyParameters? replyParameters, ReplyMarkup? replyMarkup, @@ -770,6 +797,7 @@ mixin TGAPIMethods { 'is_closed': isClosed, 'disable_notification': disableNotification, 'protect_content': protectContent, + 'allow_paid_broadcast': allowPaidBroadcast, 'message_effect_id': messageEffectId, 'reply_parameters': replyParameters, 'reply_markup': replyMarkup, @@ -787,6 +815,7 @@ mixin TGAPIMethods { Emoji? emoji, bool? disableNotification, bool? protectContent, + bool? allowPaidBroadcast, String? messageEffectId, ReplyParameters? replyParameters, ReplyMarkup? replyMarkup, @@ -798,6 +827,7 @@ mixin TGAPIMethods { 'emoji': emoji, 'disable_notification': disableNotification, 'protect_content': protectContent, + 'allow_paid_broadcast': allowPaidBroadcast, 'message_effect_id': messageEffectId, 'reply_parameters': replyParameters, 'reply_markup': replyMarkup, @@ -2190,6 +2220,7 @@ mixin TGAPIMethods { String? emoji, bool? disableNotification, bool? protectContent, + bool? allowPaidBroadcast, String? messageEffectId, ReplyParameters? replyParameters, ReplyMarkup? replyMarkup, @@ -2202,6 +2233,7 @@ mixin TGAPIMethods { 'emoji': emoji, 'disable_notification': disableNotification, 'protect_content': protectContent, + 'allow_paid_broadcast': allowPaidBroadcast, 'message_effect_id': messageEffectId, 'reply_parameters': replyParameters, 'reply_markup': replyMarkup, @@ -2483,6 +2515,7 @@ mixin TGAPIMethods { bool? isFlexible, bool? disableNotification, bool? protectContent, + bool? allowPaidBroadcast, String? messageEffectId, ReplyParameters? replyParameters, InlineKeyboardMarkup? replyMarkup, @@ -2513,6 +2546,7 @@ mixin TGAPIMethods { 'is_flexible': isFlexible, 'disable_notification': disableNotification, 'protect_content': protectContent, + 'allow_paid_broadcast': allowPaidBroadcast, 'message_effect_id': messageEffectId, 'reply_parameters': replyParameters, 'reply_markup': replyMarkup, @@ -2715,6 +2749,7 @@ mixin TGAPIMethods { int? messageThreadId, bool? disableNotification, bool? protectContent, + bool? allowPaidBroadcast, String? messageEffectId, ReplyParameters? replyParameters, InlineKeyboardMarkup? replyMarkup, @@ -2726,6 +2761,7 @@ mixin TGAPIMethods { 'game_short_name': gameShortName, 'disable_notification': disableNotification, 'protect_content': protectContent, + 'allow_paid_broadcast': allowPaidBroadcast, 'message_effect_id': messageEffectId, 'reply_parameters': replyParameters, 'reply_markup': replyMarkup, diff --git a/lib/src/entities/telegram/copy_text_button.dart b/lib/src/entities/telegram/copy_text_button.dart new file mode 100644 index 0000000..e10631d --- /dev/null +++ b/lib/src/entities/telegram/copy_text_button.dart @@ -0,0 +1,26 @@ +import 'dart:convert'; + +/// This object represents an inline keyboard button that copies specified text +/// to the clipboard. +class CopyTextButton { + /// The text to be copied to the clipboard; 1-256 characters + String text; + + /// Basic constructor + CopyTextButton(this.text); + + /// Creates an object from a json + factory CopyTextButton.fromJson(Map json) { + return CopyTextButton(json['text']); + } + + /// Creates a json from the object + Map toJson() { + return { + 'text': text, + }; + } + + @override + String toString() => json.encode(this); +} diff --git a/lib/src/entities/telegram/inline_keyboard_button.dart b/lib/src/entities/telegram/inline_keyboard_button.dart index bdd5841..0995174 100644 --- a/lib/src/entities/telegram/inline_keyboard_button.dart +++ b/lib/src/entities/telegram/inline_keyboard_button.dart @@ -62,6 +62,10 @@ class InlineKeyboardButton { /// Not supported for messages sent on behalf of a Telegram Business account. SwitchInlineQueryChosenChat? switchInlineQueryChosenChat; + /// Optional. Description of the button that copies the specified text to the + /// clipboard + CopyTextButton? copy_text; + /// Optional. Description of the game that will be launched when the user /// presses the button. /// This type of button must always be the first button in the first row. @@ -84,6 +88,7 @@ class InlineKeyboardButton { this.switchInlineQuery, this.switchInlineQueryCurrentChat, this.switchInlineQueryChosenChat, + this.copy_text, this.callbackGame, this.pay, }); @@ -115,6 +120,9 @@ class InlineKeyboardButton { this.switchInlineQueryChosenChat, ); + /// CopyText constructor + InlineKeyboardButton.copyText(this.text, this.copy_text); + /// CallbackGame constructor InlineKeyboardButton.callbackGame(this.text, this.callbackGame); @@ -135,6 +143,7 @@ class InlineKeyboardButton { SwitchInlineQueryChosenChat.fromJson, json['switch_inline_query_chosen_chat'], ), + copy_text: callIfNotNull(CopyTextButton.fromJson, json['copy_text']), callbackGame: callIfNotNull(CallbackGame.fromJson, json['callback_game']), pay: json['pay'], ); @@ -172,6 +181,7 @@ class InlineKeyboardButton { 'switch_inline_query': switchInlineQuery, 'switch_inline_query_current_chat': switchInlineQueryCurrentChat, 'switch_inline_query_chosen_chat': switchInlineQueryChosenChat, + 'copy_text': copy_text, 'callback_game': callbackGame, 'pay': pay, }..removeWhere((_, v) => v == null); diff --git a/lib/src/entities/telegram/transaction_partner.dart b/lib/src/entities/telegram/transaction_partner.dart index 78ced5f..d3cc6d4 100644 --- a/lib/src/entities/telegram/transaction_partner.dart +++ b/lib/src/entities/telegram/transaction_partner.dart @@ -19,6 +19,8 @@ abstract class TransactionPartner { return TransactionPartnerFragment.fromJson(json); case 'telegram_ads': return TransactionPartnerTelegramAds.fromJson(json); + case 'telegram_api': + return TransactionPartnerTelegramApi.fromJson(json); case 'other': return TransactionPartnerOther.fromJson(json); default: diff --git a/lib/src/entities/telegram/transaction_partner_telegram_api.dart b/lib/src/entities/telegram/transaction_partner_telegram_api.dart new file mode 100644 index 0000000..16d92c5 --- /dev/null +++ b/lib/src/entities/telegram/transaction_partner_telegram_api.dart @@ -0,0 +1,33 @@ +import 'dart:convert'; + +import '../../../telegram_entities.dart'; + +/// Describes a transaction with payment for paid broadcasting. +class TransactionPartnerTelegramApi extends TransactionPartner { + /// Type of the transaction partner, always “telegram_api” + @override + String type = 'telegram_api'; + + /// The number of successful requests that exceeded regular limits and were + /// therefore billed + int requestCount; + + /// Basic constructor + TransactionPartnerTelegramApi(this.requestCount); + + /// Creates an object from a json + factory TransactionPartnerTelegramApi.fromJson(Map json) { + return TransactionPartnerTelegramApi(json['request_count']); + } + + /// Creates a json from the object + Map toJson() { + return { + 'type': type, + 'request_count': requestCount, + }..removeWhere((_, v) => v == null); + } + + @override + String toString() => json.encode(this); +} diff --git a/lib/telegram_entities.dart b/lib/telegram_entities.dart index d24918b..37f79f1 100644 --- a/lib/telegram_entities.dart +++ b/lib/telegram_entities.dart @@ -61,6 +61,7 @@ export 'src/entities/telegram/chat_photo.dart'; export 'src/entities/telegram/chat_shared.dart'; export 'src/entities/telegram/chosen_inline_result.dart'; export 'src/entities/telegram/contact.dart'; +export 'src/entities/telegram/copy_text_button.dart'; export 'src/entities/telegram/dice.dart'; export 'src/entities/telegram/document.dart'; export 'src/entities/telegram/encrypted_credentials.dart'; @@ -198,6 +199,7 @@ export 'src/entities/telegram/transaction_partner.dart'; export 'src/entities/telegram/transaction_partner_fragment.dart'; export 'src/entities/telegram/transaction_partner_other.dart'; export 'src/entities/telegram/transaction_partner_telegram_ads.dart'; +export 'src/entities/telegram/transaction_partner_telegram_api.dart'; export 'src/entities/telegram/transaction_partner_user.dart'; export 'src/entities/telegram/update.dart'; export 'src/entities/telegram/user.dart'; diff --git a/pubspec.yaml b/pubspec.yaml index 4ddb2c7..8350f9c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: dart_telegram_bot description: A Telegram Bot API wrapper made to make fast Telegram bots with as less code as possible. -version: 1.11.2 +version: 1.11.3 homepage: https://github.com/KaikyuDev/dart-telegram-bot environment: