From 29c20ccb7dbfc8883e1fc3d25c735a74c07d3754 Mon Sep 17 00:00:00 2001 From: Sreelal TS Date: Fri, 10 May 2024 16:43:54 +0530 Subject: [PATCH 01/11] =?UTF-8?q?=F0=9F=92=AC=20Update=20comments=20in=20C?= =?UTF-8?q?hat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/src/telegram/models/chat_full_info.dart | 75 +++++++++++---------- 1 file changed, 38 insertions(+), 37 deletions(-) diff --git a/lib/src/telegram/models/chat_full_info.dart b/lib/src/telegram/models/chat_full_info.dart index 02d92b85..84bc7f6b 100644 --- a/lib/src/telegram/models/chat_full_info.dart +++ b/lib/src/telegram/models/chat_full_info.dart @@ -2,109 +2,109 @@ part of 'models.dart'; /// This object represents a chat. class ChatFullInfo extends Chat { - /// Optional. Chat photo. Returned only in getChat. + /// Optional. Chat photo. final ChatPhoto? photo; - /// Optional. If non-empty, the list of all active chat usernames; for private chats, supergroups and channels. Returned only in getChat. + /// Optional. If non-empty, the list of all active chat usernames; for private chats, supergroups and channels. final List? activeUsernames; - /// Optional. Bio of the other party in a private chat. Returned only in getChat. + /// Optional. Bio of the other party in a private chat. final String? bio; - /// Optional. True, if privacy settings of the other party in the private chat allows to use tg://user?id= links only in chats with the user. Returned only in getChat. + /// Optional. True, if privacy settings of the other party in the private chat allows to use tg://user?id= links only in chats with the user. final bool? hasPrivateForwards; - /// Optional. True, if the privacy settings of the other party restrict sending voice and video note messages in the private chat. Returned only in getChat. + /// Optional. True, if the privacy settings of the other party restrict sending voice and video note messages in the private chat. final bool? hasRestrictedVoiceAndVideoMessages; - /// Optional. True, if users need to join the supergroup before they can send messages. Returned only in getChat. + /// Optional. True, if users need to join the supergroup before they can send messages. final bool? joinToSendMessages; - /// Optional. True, if all users directly joining the supergroup need to be approved by supergroup administrators. Returned only in getChat. + /// Optional. True, if all users directly joining the supergroup need to be approved by supergroup administrators. final bool? joinByRequest; - /// Optional. Description, for groups, supergroups and channel chats. Returned only in getChat. + /// Optional. Description, for groups, supergroups and channel chats. final String? description; - /// Optional. Primary invite link, for groups, supergroups and channel chats. Returned only in getChat. + /// Optional. Primary invite link, for groups, supergroups and channel chats. final String? inviteLink; - /// Optional. The most recent pinned message (by sending date). Returned only in getChat. + /// Optional. The most recent pinned message (by sending date). final Message? pinnedMessage; - /// Optional. Default chat member permissions, for groups and supergroups. Returned only in getChat. + /// Optional. Default chat member permissions, for groups and supergroups. final ChatPermissions? permissions; - /// Optional. For supergroups, the minimum allowed delay between consecutive messages sent by each unpriviledged user; in seconds. Returned only in getChat. + /// Optional. For supergroups, the minimum allowed delay between consecutive messages sent by each unpriviledged user; in seconds. final int? slowModeDelay; - /// Optional. The time after which all messages sent to the chat will be automatically deleted; in seconds. Returned only in getChat. + /// Optional. The time after which all messages sent to the chat will be automatically deleted; in seconds. final int? messageAutoDeleteTime; - /// Optional. True, if messages from the chat can't be forwarded to other chats. Returned only in getChat. + /// Optional. True, if messages from the chat can't be forwarded to other chats. final bool? hasProtectedContent; - /// Optional. For supergroups, name of group sticker set. Returned only in getChat. + /// Optional. For supergroups, name of group sticker set. final String? stickerSetName; - /// Optional. True, if the bot can change the group sticker set. Returned only in getChat. + /// Optional. True, if the bot can change the group sticker set. final bool? canSetStickerSet; - /// Optional. Unique identifier for the linked chat, i.e. the discussion group identifier for a channel and vice versa; for supergroups and channel chats. This identifier may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it is smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier. Returned only in getChat. + /// Optional. Unique identifier for the linked chat, i.e. the discussion group identifier for a channel and vice versa; for supergroups and channel chats. This identifier may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it is smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier. final int? linkedChatId; - /// Optional. For supergroups, the location to which the supergroup is connected. Returned only in getChat. + /// Optional. For supergroups, the location to which the supergroup is connected. final ChatLocation? location; - /// Optional. True, if non-administrators can only get the list of bots and administrators in the chat. Returned only in getChat. + /// Optional. True, if non-administrators can only get the list of bots and administrators in the chat. final bool? hasHiddenMembers; - /// Optional. True, if aggressive anti-spam checks are enabled in the supergroup. The field is only available to chat administrators. Returned only in getChat. + /// Optional. True, if aggressive anti-spam checks are enabled in the supergroup. The field is only available to chat administrators. final bool? hasAggressiveAntiSpamEnabled; - /// Optional. Expiration date of the emoji status of the other party in a private chat, if any. Returned only in getChat. + /// Optional. Expiration date of the emoji status of the other party in a private chat, if any. final int? emojiStatusExpirationDate; - /// Optional. Expiration date of the emoji status of the chat or the other party in a private chat, in Unix time, if any. Returned only in getChat. + /// Optional. Expiration date of the emoji status of the chat or the other party in a private chat, in Unix time, if any. final List? availableReactions; - /// Optional. Custom emoji identifier of the emoji status of the chat or the other party in a private chat. Returned only in getChat. + /// Optional. Custom emoji identifier of the emoji status of the chat or the other party in a private chat. final String? emojiStatusCustomEmojiId; - /// Optional. Identifier of the accent color for the chat name and backgrounds of the chat photo, reply header, and link preview. See [accent colors](https://core.telegram.org/bots/api#accent-colors) for more details. Returned only in getChat. Always returned in [getChat](https://core.telegram.org/bots/api#getchat) + /// Optional. Identifier of the accent color for the chat name and backgrounds of the chat photo, reply header, and link preview. See [accent colors](https://core.telegram.org/bots/api#accent-colors) for more details. Always returned in [getChat](https://core.telegram.org/bots/api#getchat) final int? accentColorId; - /// Optional. Custom emoji identifier of emoji chosen by the chat for the reply header and link preview background. Returned only in getChat. + /// Optional. Custom emoji identifier of emoji chosen by the chat for the reply header and link preview background. final String? backgroundCustomEmojiId; - /// Optional. Identifier of the accent color for the chat's profile background. See profile accent colors for more details. Returned only in getChat. + /// Optional. Identifier of the accent color for the chat's profile background. See profile accent colors for more details. final int? profileAccentColorId; - /// Optional. Custom emoji identifier of the emoji chosen by the chat for its profile background. Returned only in getChat. + /// Optional. Custom emoji identifier of the emoji chosen by the chat for its profile background. final String? profileBackgroundCustomEmojiId; - /// Optional. True, if new chat members will have access to old messages; available only to chat administrators. Returned only in getChat. + /// Optional. True, if new chat members will have access to old messages; available only to chat administrators. final bool? hasVisibleHistory; - /// Optional. For supergroups, the minimum number of boosts that a non-administrator user needs to add in order to ignore slow mode and chat permissions. Returned only in getChat. + /// Optional. For supergroups, the minimum number of boosts that a non-administrator user needs to add in order to ignore slow mode and chat permissions. final int? unrestrictBoostCount; - /// Optional. For supergroups, the name of the group's custom emoji sticker set. Custom emoji from this set can be used by all users and bots in the group. Returned only in getChat. + /// Optional. For supergroups, the name of the group's custom emoji sticker set. Custom emoji from this set can be used by all users and bots in the group. final String? customEmojiStickerSetName; - /// Optional. For private chats with business accounts, the intro of the business. Returned only in getChat. + /// Optional. For private chats with business accounts, the intro of the business. final BusinessIntro? businessIntro; - /// Optional. For private chats with business accounts, the location of the business. Returned only in getChat. + /// Optional. For private chats with business accounts, the location of the business. final BusinessLocation? businessLocation; - /// Optional. For private chats with business accounts, the opening hours of the business. Returned only in getChat. + /// Optional. For private chats with business accounts, the opening hours of the business. final BusinessOpeningHours? businessOpeningHours; - /// Optional. For private chats, the personal channel of the user. Returned only in getChat. + /// Optional. For private chats, the personal channel of the user. final Chat? personalChat; - /// Optional. For private chats, the date of birth of the user. Returned only in getChat. + /// Optional. For private chats, the date of birth of the user. final Birthdate? birthdate; /// The maximum number of reactions that can be set on a message in the chat @@ -261,8 +261,9 @@ class ChatFullInfo extends Chat { 'has_hidden_members': hasHiddenMembers, 'has_aggressive_anti_spam_enabled': hasAggressiveAntiSpamEnabled, 'emoji_status_expiration_date': emojiStatusExpirationDate, - 'available_reactions': - availableReactions?.map((e) => e.toJson()).toList(), + 'available_reactions': availableReactions?.map((e) { + return e.toJson(); + }).toList(), 'emoji_status_custom_emoji_id': emojiStatusCustomEmojiId, 'accent_color_id': accentColorId, 'background_custom_emoji_id': backgroundCustomEmojiId, From 41d691200705deb959a55b6883f5a26043e68980 Mon Sep 17 00:00:00 2001 From: Sreelal TS Date: Sun, 19 May 2024 10:51:51 +0530 Subject: [PATCH 02/11] =?UTF-8?q?=F0=9F=A7=AA=20Refactors=20and=20improvem?= =?UTF-8?q?ents?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../abstracts/passport_element_error.dart | 4 +- lib/src/telegram/models/callback_game.dart | 2 +- .../models/encrypted_credentials.dart | 4 +- .../models/encrypted_passport_element.dart | 4 +- lib/src/telegram/models/game.dart | 2 +- lib/src/telegram/models/game_high_score.dart | 2 +- lib/src/telegram/models/games.dart | 50 ------------------- lib/src/telegram/models/models.dart | 29 ++++++++--- lib/src/telegram/models/passport.dart | 30 ----------- lib/src/telegram/models/passport_data.dart | 4 +- .../passport_element_error_data_field.dart | 4 +- .../models/passport_element_error_file.dart | 4 +- .../models/passport_element_error_files.dart | 4 +- .../passport_element_error_front_side.dart | 4 +- .../passport_element_error_reverse_side.dart | 4 +- .../models/passport_element_error_selfie.dart | 4 +- ...ssport_element_error_translation_file.dart | 4 +- ...sport_element_error_translation_files.dart | 4 +- .../passport_element_error_unspecified.dart | 4 +- lib/src/telegram/models/passport_file.dart | 4 +- lib/src/televerse/models/chat_id.dart | 6 +-- 21 files changed, 57 insertions(+), 120 deletions(-) delete mode 100644 lib/src/telegram/models/games.dart delete mode 100644 lib/src/telegram/models/passport.dart diff --git a/lib/src/telegram/models/abstracts/passport_element_error.dart b/lib/src/telegram/models/abstracts/passport_element_error.dart index 0f649f1f..87821e61 100644 --- a/lib/src/telegram/models/abstracts/passport_element_error.dart +++ b/lib/src/telegram/models/abstracts/passport_element_error.dart @@ -1,4 +1,4 @@ -part of '../passport.dart'; +part of '../models.dart'; /// This object represents an error in the Telegram Passport element which was submitted that should be resolved by the user. abstract class PassportElementError { @@ -21,4 +21,4 @@ abstract class PassportElementError { 'type': type, }..removeWhere(_nullFilter); } -} +} \ No newline at end of file diff --git a/lib/src/telegram/models/callback_game.dart b/lib/src/telegram/models/callback_game.dart index 80fdb96f..a5840ea1 100644 --- a/lib/src/telegram/models/callback_game.dart +++ b/lib/src/telegram/models/callback_game.dart @@ -1,4 +1,4 @@ -part of 'games.dart'; +part of 'models.dart'; /// A placeholder, currently holds no information. Use BotFather to set up your game. class CallbackGame { diff --git a/lib/src/telegram/models/encrypted_credentials.dart b/lib/src/telegram/models/encrypted_credentials.dart index a02b872c..5f078ce3 100644 --- a/lib/src/telegram/models/encrypted_credentials.dart +++ b/lib/src/telegram/models/encrypted_credentials.dart @@ -1,4 +1,4 @@ -part of 'passport.dart'; +part of 'models.dart'; /// Describes data required for decrypting and authenticating EncryptedPassportElement. See the Telegram Passport Documentation for a complete description of the data decryption and authentication processes. class EncryptedCredentials { @@ -35,4 +35,4 @@ class EncryptedCredentials { secret: json['secret']!, ); } -} +} \ No newline at end of file diff --git a/lib/src/telegram/models/encrypted_passport_element.dart b/lib/src/telegram/models/encrypted_passport_element.dart index f095f79f..29892015 100644 --- a/lib/src/telegram/models/encrypted_passport_element.dart +++ b/lib/src/telegram/models/encrypted_passport_element.dart @@ -1,4 +1,4 @@ -part of 'passport.dart'; +part of 'models.dart'; /// Describes documents or other Telegram Passport elements shared with the bot by the user. class EncryptedPassportElement { @@ -87,4 +87,4 @@ class EncryptedPassportElement { hash: json['hash']!, ); } -} +} \ No newline at end of file diff --git a/lib/src/telegram/models/game.dart b/lib/src/telegram/models/game.dart index 719e9c53..cee23900 100644 --- a/lib/src/telegram/models/game.dart +++ b/lib/src/telegram/models/game.dart @@ -1,4 +1,4 @@ -part of 'games.dart'; +part of 'models.dart'; /// This object represents a game. Use BotFather to create and edit games, their short names will act as unique identifiers. class Game { diff --git a/lib/src/telegram/models/game_high_score.dart b/lib/src/telegram/models/game_high_score.dart index d3369132..a8a1d7b8 100644 --- a/lib/src/telegram/models/game_high_score.dart +++ b/lib/src/telegram/models/game_high_score.dart @@ -1,4 +1,4 @@ -part of 'games.dart'; +part of 'models.dart'; /// This object represents one row of the high scores table for a game. class GameHighScore { diff --git a/lib/src/telegram/models/games.dart b/lib/src/telegram/models/games.dart deleted file mode 100644 index 0152deb9..00000000 --- a/lib/src/telegram/models/games.dart +++ /dev/null @@ -1,50 +0,0 @@ -/// ## GAMES -/// -/// Your bot can offer users HTML5 games to play solo or to compete against each -/// other in groups and one-on-one chats. Create games via @BotFather using the -/// /newgame command. Please note that this kind of power requires responsibility: -/// you will need to accept the terms for each game that your bots will be offering. -/// -/// - Games are a new type of content on Telegram, represented by the Game and -/// InlineQueryResultGame objects. -/// -/// - Once you've created a game via BotFather, you can send games to chats as -/// regular messages using the sendGame method, or use inline mode with [InlineQueryResultGame](https://core.telegram.org/bots/api#inlinequeryresultgame). -/// -/// - If you send the game message without any buttons, it will automatically -/// have a 'Play GameName' button. When this button is pressed, your bot gets -/// a CallbackQuery with the game_short_name of the requested game. You provide -/// the correct URL for this particular user and the app opens the game in the -/// in-app browser. -/// -/// - You can manually add multiple buttons to your game message. Please note -/// that the first button in the first row must always launch the game, using -/// the field callback_game in [InlineKeyboardButton](https://core.telegram.org/bots/api#inlinekeyboardbutton). -/// You can add extra buttons according to taste: e.g., for a description of the -/// rules, or to open thegame's official community. -/// -/// - To make your game more attractive, you can upload a GIF animation that -/// demostrates the game to the users via BotFather (see Lumberjack for example). -/// -/// - A game message will also display high scores for the current chat. Use -/// setGameScore to post high scores to the chat with the game, add the -/// edit_message parameter to automatically update the message with the current -/// scoreboard. -/// -/// - Use getGameHighScores to get data for in-game high score tables. -/// -/// - You can also add an extra sharing button for users to share their best -/// score to different chats. -/// -/// - For examples of what can be done using this new stuff, check the @gamebot -/// and @gamee bots. -library; - -import 'package:televerse/src/telegram/models/models.dart'; - -part 'game.dart'; -part 'callback_game.dart'; -part 'game_high_score.dart'; - -/// Null filter function. -bool _nullFilter(String _, dynamic value) => value == null; diff --git a/lib/src/telegram/models/models.dart b/lib/src/telegram/models/models.dart index 071c54d8..c6c634ad 100644 --- a/lib/src/telegram/models/models.dart +++ b/lib/src/telegram/models/models.dart @@ -10,12 +10,6 @@ import 'package:dio/dio.dart'; import 'package:televerse/televerse.dart'; import 'dart:io' as io; -import 'games.dart'; -import 'passport.dart'; - -export 'games.dart'; -export 'passport.dart'; - /// Abstractions part 'abstractions.dart'; @@ -141,6 +135,29 @@ part 'video_chat_participants_invited.dart'; part 'bot_command.dart'; part 'inline_query_result_video.dart'; +// Telegram Games +part 'game.dart'; +part 'callback_game.dart'; +part 'game_high_score.dart'; + +// Telegram Passport +part 'passport_data.dart'; +part 'encrypted_passport_element.dart'; +part 'passport_file.dart'; +part 'encrypted_credentials.dart'; +part 'abstracts/passport_element_error.dart'; + +// Passport Errors +part 'passport_element_error_data_field.dart'; +part 'passport_element_error_front_side.dart'; +part 'passport_element_error_reverse_side.dart'; +part 'passport_element_error_selfie.dart'; +part 'passport_element_error_file.dart'; +part 'passport_element_error_files.dart'; +part 'passport_element_error_translation_file.dart'; +part 'passport_element_error_translation_files.dart'; +part 'passport_element_error_unspecified.dart'; + // Bot API 6.4 part 'forum_topic_edited.dart'; part 'general_forum_topic_hidden.dart'; diff --git a/lib/src/telegram/models/passport.dart b/lib/src/telegram/models/passport.dart deleted file mode 100644 index 65421c3d..00000000 --- a/lib/src/telegram/models/passport.dart +++ /dev/null @@ -1,30 +0,0 @@ -/// ## Telegram Passport -/// -/// Telegram Passport is a unified authorization method for services that require -/// personal identification. Users can upload their documents once, then instantly -/// share their data with services that require real-world ID (finance, ICOs, etc.). -/// -/// Please see the [manual](https://core.telegram.org/passport) for details. -library; - -import 'package:televerse/televerse.dart'; - -part 'passport_data.dart'; -part 'encrypted_passport_element.dart'; -part 'passport_file.dart'; -part 'encrypted_credentials.dart'; -part 'abstracts/passport_element_error.dart'; - -// Errors -part 'passport_element_error_data_field.dart'; -part 'passport_element_error_front_side.dart'; -part 'passport_element_error_reverse_side.dart'; -part 'passport_element_error_selfie.dart'; -part 'passport_element_error_file.dart'; -part 'passport_element_error_files.dart'; -part 'passport_element_error_translation_file.dart'; -part 'passport_element_error_translation_files.dart'; -part 'passport_element_error_unspecified.dart'; - -/// Null filter function. -bool _nullFilter(String _, dynamic value) => value == null; diff --git a/lib/src/telegram/models/passport_data.dart b/lib/src/telegram/models/passport_data.dart index fe15e4e8..8b29435e 100644 --- a/lib/src/telegram/models/passport_data.dart +++ b/lib/src/telegram/models/passport_data.dart @@ -1,4 +1,4 @@ -part of 'passport.dart'; +part of 'models.dart'; /// Describes Telegram Passport data shared with the bot by the user. class PassportData { @@ -31,4 +31,4 @@ class PassportData { credentials: EncryptedCredentials.fromJson(json['credentials']!), ); } -} +} \ No newline at end of file diff --git a/lib/src/telegram/models/passport_element_error_data_field.dart b/lib/src/telegram/models/passport_element_error_data_field.dart index 407b13bd..2d4487b1 100644 --- a/lib/src/telegram/models/passport_element_error_data_field.dart +++ b/lib/src/telegram/models/passport_element_error_data_field.dart @@ -1,4 +1,4 @@ -part of 'passport.dart'; +part of 'models.dart'; /// Represents an issue in one of the data fields that was provided by the user. The error is considered resolved when the field's value changes. class PassportElementErrorDataField extends PassportElementError { @@ -42,4 +42,4 @@ class PassportElementErrorDataField extends PassportElementError { dataHash: json['data_hash']!, ); } -} +} \ No newline at end of file diff --git a/lib/src/telegram/models/passport_element_error_file.dart b/lib/src/telegram/models/passport_element_error_file.dart index a7cb9224..71ddc724 100644 --- a/lib/src/telegram/models/passport_element_error_file.dart +++ b/lib/src/telegram/models/passport_element_error_file.dart @@ -1,4 +1,4 @@ -part of 'passport.dart'; +part of 'models.dart'; /// Represents an issue with a document scan. The error is considered resolved when the file with the document scan changes. class PassportElementErrorFile extends PassportElementError { @@ -36,4 +36,4 @@ class PassportElementErrorFile extends PassportElementError { fileHash: json['file_hash']!, ); } -} +} \ No newline at end of file diff --git a/lib/src/telegram/models/passport_element_error_files.dart b/lib/src/telegram/models/passport_element_error_files.dart index a5cb7648..3dc8cf18 100644 --- a/lib/src/telegram/models/passport_element_error_files.dart +++ b/lib/src/telegram/models/passport_element_error_files.dart @@ -1,4 +1,4 @@ -part of 'passport.dart'; +part of 'models.dart'; /// Represents an issue with a list of scans. The error is considered resolved when the list of files containing the scans changes. class PassportElementErrorFiles extends PassportElementError { @@ -36,4 +36,4 @@ class PassportElementErrorFiles extends PassportElementError { fileHashes: List.from(json['file_hashes']! as List), ); } -} +} \ No newline at end of file diff --git a/lib/src/telegram/models/passport_element_error_front_side.dart b/lib/src/telegram/models/passport_element_error_front_side.dart index 464df7a8..55c4abd3 100644 --- a/lib/src/telegram/models/passport_element_error_front_side.dart +++ b/lib/src/telegram/models/passport_element_error_front_side.dart @@ -1,4 +1,4 @@ -part of 'passport.dart'; +part of 'models.dart'; /// Represents an issue with the front side of a document. The error is considered resolved when the file with the front side of the document changes. class PassportElementErrorFrontSide extends PassportElementError { @@ -36,4 +36,4 @@ class PassportElementErrorFrontSide extends PassportElementError { fileHash: json['file_hash']!, ); } -} +} \ No newline at end of file diff --git a/lib/src/telegram/models/passport_element_error_reverse_side.dart b/lib/src/telegram/models/passport_element_error_reverse_side.dart index 249bc87c..3cd22385 100644 --- a/lib/src/telegram/models/passport_element_error_reverse_side.dart +++ b/lib/src/telegram/models/passport_element_error_reverse_side.dart @@ -1,4 +1,4 @@ -part of 'passport.dart'; +part of 'models.dart'; /// Represents an issue with the reverse side of a document. The error is considered resolved when the file with reverse side of the document changes. class PassportElementErrorReverseSide extends PassportElementError { @@ -36,4 +36,4 @@ class PassportElementErrorReverseSide extends PassportElementError { fileHash: json['file_hash']!, ); } -} +} \ No newline at end of file diff --git a/lib/src/telegram/models/passport_element_error_selfie.dart b/lib/src/telegram/models/passport_element_error_selfie.dart index 7af5e2f8..71876995 100644 --- a/lib/src/telegram/models/passport_element_error_selfie.dart +++ b/lib/src/telegram/models/passport_element_error_selfie.dart @@ -1,4 +1,4 @@ -part of 'passport.dart'; +part of 'models.dart'; /// Represents an issue with the selfie with a document. The error is considered resolved when the file with the selfie changes. class PassportElementErrorSelfie extends PassportElementError { @@ -36,4 +36,4 @@ class PassportElementErrorSelfie extends PassportElementError { fileHash: json['file_hash']!, ); } -} +} \ No newline at end of file diff --git a/lib/src/telegram/models/passport_element_error_translation_file.dart b/lib/src/telegram/models/passport_element_error_translation_file.dart index f0030602..ebc640ab 100644 --- a/lib/src/telegram/models/passport_element_error_translation_file.dart +++ b/lib/src/telegram/models/passport_element_error_translation_file.dart @@ -1,4 +1,4 @@ -part of 'passport.dart'; +part of 'models.dart'; /// Represents an issue with one of the files that constitute the translation of a document. The error is considered resolved when the file changes. class PassportElementErrorTranslationFile extends PassportElementError { @@ -38,4 +38,4 @@ class PassportElementErrorTranslationFile extends PassportElementError { fileHash: json['file_hash']!, ); } -} +} \ No newline at end of file diff --git a/lib/src/telegram/models/passport_element_error_translation_files.dart b/lib/src/telegram/models/passport_element_error_translation_files.dart index e5a71541..7fa5af58 100644 --- a/lib/src/telegram/models/passport_element_error_translation_files.dart +++ b/lib/src/telegram/models/passport_element_error_translation_files.dart @@ -1,4 +1,4 @@ -part of 'passport.dart'; +part of 'models.dart'; /// Represents an issue with the translated version of a document. The error is considered resolved when a file with the document translation change. class PassportElementErrorTranslationFiles extends PassportElementError { @@ -38,4 +38,4 @@ class PassportElementErrorTranslationFiles extends PassportElementError { fileHashes: List.from(json['file_hashes']! as List), ); } -} +} \ No newline at end of file diff --git a/lib/src/telegram/models/passport_element_error_unspecified.dart b/lib/src/telegram/models/passport_element_error_unspecified.dart index 3631c58c..cd427b9f 100644 --- a/lib/src/telegram/models/passport_element_error_unspecified.dart +++ b/lib/src/telegram/models/passport_element_error_unspecified.dart @@ -1,4 +1,4 @@ -part of 'passport.dart'; +part of 'models.dart'; /// Represents an issue in an unspecified place. The error is considered resolved when new data is added. class PassportElementErrorUnspecified extends PassportElementError { @@ -36,4 +36,4 @@ class PassportElementErrorUnspecified extends PassportElementError { elementHash: json['element_hash']!, ); } -} +} \ No newline at end of file diff --git a/lib/src/telegram/models/passport_file.dart b/lib/src/telegram/models/passport_file.dart index ef15088e..59e67c9a 100644 --- a/lib/src/telegram/models/passport_file.dart +++ b/lib/src/telegram/models/passport_file.dart @@ -1,4 +1,4 @@ -part of 'passport.dart'; +part of 'models.dart'; /// This object represents a file uploaded to Telegram Passport. Currently all Telegram Passport files are in JPEG format when decrypted and don't exceed 10MB. class PassportFile { @@ -47,4 +47,4 @@ class PassportFile { /// Returns the [DateTime] object of [fileDate]. /// [DateTime] object of [fileDate]. DateTime get fileDateTime => fileDate.toDateTime(); -} +} \ No newline at end of file diff --git a/lib/src/televerse/models/chat_id.dart b/lib/src/televerse/models/chat_id.dart index ae97e77a..21e7e37f 100644 --- a/lib/src/televerse/models/chat_id.dart +++ b/lib/src/televerse/models/chat_id.dart @@ -87,7 +87,7 @@ class ChatID extends ID { /// // Print the chat's title. /// print(chat.title); /// ``` - ChatID(super.id); + const ChatID(super.id); /// The ID getter, returns the actual integer value @override @@ -104,7 +104,7 @@ class ChatID extends ID { /// Simply pass the channel's username to the constructor to create a channel id. class ChannelID extends ID { /// Creates a new [ChannelID] object with the passed [id] which is a string. - ChannelID(String super.id); + const ChannelID(String super.id); /// Creates a new [ChannelID] object with the passed [id] which is a string. factory ChannelID.create(String id) { @@ -121,7 +121,7 @@ class ChannelID extends ID { /// Simply pass the supergroup's username to the constructor to create a supergroup id. class SupergroupID extends ID { /// Creates a new [SupergroupID] object with the passed [id] which is a string. - SupergroupID(String super.id); + const SupergroupID(String super.id); /// Creates a new [SupergroupID] object with the passed [id] which is a string. factory SupergroupID.create(String id) { From 55c9df623ab4d102022fb0c44b01fb7cee0545fd Mon Sep 17 00:00:00 2001 From: Sreelal TS Date: Sun, 19 May 2024 10:53:05 +0530 Subject: [PATCH 03/11] =?UTF-8?q?=F0=9F=8E=A9=20Formatting?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/src/telegram/models/abstracts/passport_element_error.dart | 2 +- lib/src/telegram/models/encrypted_credentials.dart | 2 +- lib/src/telegram/models/encrypted_passport_element.dart | 2 +- lib/src/telegram/models/passport_data.dart | 2 +- lib/src/telegram/models/passport_element_error_data_field.dart | 2 +- lib/src/telegram/models/passport_element_error_file.dart | 2 +- lib/src/telegram/models/passport_element_error_files.dart | 2 +- lib/src/telegram/models/passport_element_error_front_side.dart | 2 +- .../telegram/models/passport_element_error_reverse_side.dart | 2 +- lib/src/telegram/models/passport_element_error_selfie.dart | 2 +- .../models/passport_element_error_translation_file.dart | 2 +- .../models/passport_element_error_translation_files.dart | 2 +- lib/src/telegram/models/passport_element_error_unspecified.dart | 2 +- lib/src/telegram/models/passport_file.dart | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/src/telegram/models/abstracts/passport_element_error.dart b/lib/src/telegram/models/abstracts/passport_element_error.dart index 87821e61..153aa324 100644 --- a/lib/src/telegram/models/abstracts/passport_element_error.dart +++ b/lib/src/telegram/models/abstracts/passport_element_error.dart @@ -21,4 +21,4 @@ abstract class PassportElementError { 'type': type, }..removeWhere(_nullFilter); } -} \ No newline at end of file +} diff --git a/lib/src/telegram/models/encrypted_credentials.dart b/lib/src/telegram/models/encrypted_credentials.dart index 5f078ce3..b4edc0f7 100644 --- a/lib/src/telegram/models/encrypted_credentials.dart +++ b/lib/src/telegram/models/encrypted_credentials.dart @@ -35,4 +35,4 @@ class EncryptedCredentials { secret: json['secret']!, ); } -} \ No newline at end of file +} diff --git a/lib/src/telegram/models/encrypted_passport_element.dart b/lib/src/telegram/models/encrypted_passport_element.dart index 29892015..4856ff08 100644 --- a/lib/src/telegram/models/encrypted_passport_element.dart +++ b/lib/src/telegram/models/encrypted_passport_element.dart @@ -87,4 +87,4 @@ class EncryptedPassportElement { hash: json['hash']!, ); } -} \ No newline at end of file +} diff --git a/lib/src/telegram/models/passport_data.dart b/lib/src/telegram/models/passport_data.dart index 8b29435e..439ff198 100644 --- a/lib/src/telegram/models/passport_data.dart +++ b/lib/src/telegram/models/passport_data.dart @@ -31,4 +31,4 @@ class PassportData { credentials: EncryptedCredentials.fromJson(json['credentials']!), ); } -} \ No newline at end of file +} diff --git a/lib/src/telegram/models/passport_element_error_data_field.dart b/lib/src/telegram/models/passport_element_error_data_field.dart index 2d4487b1..f0e1a216 100644 --- a/lib/src/telegram/models/passport_element_error_data_field.dart +++ b/lib/src/telegram/models/passport_element_error_data_field.dart @@ -42,4 +42,4 @@ class PassportElementErrorDataField extends PassportElementError { dataHash: json['data_hash']!, ); } -} \ No newline at end of file +} diff --git a/lib/src/telegram/models/passport_element_error_file.dart b/lib/src/telegram/models/passport_element_error_file.dart index 71ddc724..ea3615d3 100644 --- a/lib/src/telegram/models/passport_element_error_file.dart +++ b/lib/src/telegram/models/passport_element_error_file.dart @@ -36,4 +36,4 @@ class PassportElementErrorFile extends PassportElementError { fileHash: json['file_hash']!, ); } -} \ No newline at end of file +} diff --git a/lib/src/telegram/models/passport_element_error_files.dart b/lib/src/telegram/models/passport_element_error_files.dart index 3dc8cf18..879838f4 100644 --- a/lib/src/telegram/models/passport_element_error_files.dart +++ b/lib/src/telegram/models/passport_element_error_files.dart @@ -36,4 +36,4 @@ class PassportElementErrorFiles extends PassportElementError { fileHashes: List.from(json['file_hashes']! as List), ); } -} \ No newline at end of file +} diff --git a/lib/src/telegram/models/passport_element_error_front_side.dart b/lib/src/telegram/models/passport_element_error_front_side.dart index 55c4abd3..fc7e55b8 100644 --- a/lib/src/telegram/models/passport_element_error_front_side.dart +++ b/lib/src/telegram/models/passport_element_error_front_side.dart @@ -36,4 +36,4 @@ class PassportElementErrorFrontSide extends PassportElementError { fileHash: json['file_hash']!, ); } -} \ No newline at end of file +} diff --git a/lib/src/telegram/models/passport_element_error_reverse_side.dart b/lib/src/telegram/models/passport_element_error_reverse_side.dart index 3cd22385..be89a7f4 100644 --- a/lib/src/telegram/models/passport_element_error_reverse_side.dart +++ b/lib/src/telegram/models/passport_element_error_reverse_side.dart @@ -36,4 +36,4 @@ class PassportElementErrorReverseSide extends PassportElementError { fileHash: json['file_hash']!, ); } -} \ No newline at end of file +} diff --git a/lib/src/telegram/models/passport_element_error_selfie.dart b/lib/src/telegram/models/passport_element_error_selfie.dart index 71876995..018dc502 100644 --- a/lib/src/telegram/models/passport_element_error_selfie.dart +++ b/lib/src/telegram/models/passport_element_error_selfie.dart @@ -36,4 +36,4 @@ class PassportElementErrorSelfie extends PassportElementError { fileHash: json['file_hash']!, ); } -} \ No newline at end of file +} diff --git a/lib/src/telegram/models/passport_element_error_translation_file.dart b/lib/src/telegram/models/passport_element_error_translation_file.dart index ebc640ab..0dc9866c 100644 --- a/lib/src/telegram/models/passport_element_error_translation_file.dart +++ b/lib/src/telegram/models/passport_element_error_translation_file.dart @@ -38,4 +38,4 @@ class PassportElementErrorTranslationFile extends PassportElementError { fileHash: json['file_hash']!, ); } -} \ No newline at end of file +} diff --git a/lib/src/telegram/models/passport_element_error_translation_files.dart b/lib/src/telegram/models/passport_element_error_translation_files.dart index 7fa5af58..0abd80c8 100644 --- a/lib/src/telegram/models/passport_element_error_translation_files.dart +++ b/lib/src/telegram/models/passport_element_error_translation_files.dart @@ -38,4 +38,4 @@ class PassportElementErrorTranslationFiles extends PassportElementError { fileHashes: List.from(json['file_hashes']! as List), ); } -} \ No newline at end of file +} diff --git a/lib/src/telegram/models/passport_element_error_unspecified.dart b/lib/src/telegram/models/passport_element_error_unspecified.dart index cd427b9f..ffae055b 100644 --- a/lib/src/telegram/models/passport_element_error_unspecified.dart +++ b/lib/src/telegram/models/passport_element_error_unspecified.dart @@ -36,4 +36,4 @@ class PassportElementErrorUnspecified extends PassportElementError { elementHash: json['element_hash']!, ); } -} \ No newline at end of file +} diff --git a/lib/src/telegram/models/passport_file.dart b/lib/src/telegram/models/passport_file.dart index 59e67c9a..09ca0c65 100644 --- a/lib/src/telegram/models/passport_file.dart +++ b/lib/src/telegram/models/passport_file.dart @@ -47,4 +47,4 @@ class PassportFile { /// Returns the [DateTime] object of [fileDate]. /// [DateTime] object of [fileDate]. DateTime get fileDateTime => fileDate.toDateTime(); -} \ No newline at end of file +} From ce0549293ea9cb62ba756fa73ced36498b24c61a Mon Sep 17 00:00:00 2001 From: Sreelal TS Date: Fri, 31 May 2024 16:24:40 +0530 Subject: [PATCH 04/11] =?UTF-8?q?=F0=9F=92=B0=20Payments=20in=20Telegram?= =?UTF-8?q?=20Stars?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../models/input_invoice_message_content.dart | 8 +-- lib/src/televerse/raw_api.dart | 67 +++++++++++++++++-- lib/src/types/methods.dart | 3 + 3 files changed, 70 insertions(+), 8 deletions(-) diff --git a/lib/src/telegram/models/input_invoice_message_content.dart b/lib/src/telegram/models/input_invoice_message_content.dart index 4aaffdfa..6e674342 100644 --- a/lib/src/telegram/models/input_invoice_message_content.dart +++ b/lib/src/telegram/models/input_invoice_message_content.dart @@ -11,8 +11,8 @@ class InputInvoiceMessageContent extends InputMessageContent { /// Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes. final String payload; - /// Payment provider token, obtained via @BotFather - final String providerToken; + /// Optional. Payment provider token, obtained via @BotFather. Pass an empty string for payments in Telegram Stars. + final String? providerToken; /// Three-letter ISO 4217 currency code, [see more on currencies](https://core.telegram.org/bots/payments#supported-currencies) final String currency; @@ -67,7 +67,7 @@ class InputInvoiceMessageContent extends InputMessageContent { required this.title, required this.description, required this.payload, - required this.providerToken, + this.providerToken, required this.currency, required this.prices, this.maxTipAmount, @@ -119,7 +119,7 @@ class InputInvoiceMessageContent extends InputMessageContent { title: json['title'] as String, description: json['description'] as String, payload: json['payload'] as String, - providerToken: json['provider_token'] as String, + providerToken: json['provider_token'] as String?, currency: json['currency'] as String, prices: (json['prices'] as List) .map((e) => LabeledPrice.fromJson(e as Map)) diff --git a/lib/src/televerse/raw_api.dart b/lib/src/televerse/raw_api.dart index c1c2b406..fb235279 100644 --- a/lib/src/televerse/raw_api.dart +++ b/lib/src/televerse/raw_api.dart @@ -2769,16 +2769,35 @@ class RawAPI { } /// Use this method to send invoices. On success, the sent Message is returned. + /// + /// ## Important Parameters + /// - [chatId] : Unique identifier for the target chat or username of the target channel (in the format @channelusername) + /// + /// - [title] : Product name, 1-32 characters + /// + /// - [description] : Product description, 1-255 characters + /// + /// - [payload] : Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes. + /// + /// - [providerToken] : Payment token is obtained via [@BotFather](https://t.me/botfather). + /// Pass empty string for payments in [Telegram Stars](https://t.me/BotNews/90). + /// + /// - [currency] : Three-letter ISO 4217 currency code, [see more on currencies](https://core.telegram.org/bots/payments#supported-currencies). + /// Pass “XTR” for payments in Telegram Stars](https://t.me/BotNews/90). + /// + /// - [prices] : Price breakdown, a JSON-serialized list of components + /// (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.). + /// Must contain exactly one item for payments in Telegram Stars. Future sendInvoice( ID chatId, { required String title, required String description, required String payload, - required String providerToken, + String? providerToken, required String currency, required List prices, int? messageThreadId, - int? maxTipAmount = 0, + int? maxTipAmount, List? suggestedTipAmounts, String? startParameter, String? providerData, @@ -2837,14 +2856,31 @@ class RawAPI { } /// Use this method to create a link for an invoice. Returns the created invoice link as String on success. + /// + /// ## Important Parameters + /// - [title] : Product name, 1-32 characters + /// + /// - [description] : Product description, 1-255 characters + /// + /// - [payload] : Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes. + /// + /// - [providerToken] : Payment token is obtained via [@BotFather](https://t.me/botfather). + /// Pass empty string for payments in [Telegram Stars](https://t.me/BotNews/90). + /// + /// - [currency] : Three-letter ISO 4217 currency code, [see more on currencies](https://core.telegram.org/bots/payments#supported-currencies). + /// Pass “XTR” for payments in Telegram Stars](https://t.me/BotNews/90). + /// + /// - [prices] : Price breakdown, a JSON-serialized list of components + /// (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.). + /// Must contain exactly one item for payments in Telegram Stars. Future createInvoiceLink({ required String title, required String description, required String payload, - required String providerToken, + String? providerToken, required String currency, required List prices, - int? maxTipAmount = 0, + int? maxTipAmount, List? suggestedTipAmounts, String? providerData, String? photoUrl, @@ -3603,4 +3639,27 @@ class RawAPI { return response; } + + /// Refunds a successful payment in [Telegram Stars](https://t.me/BotNews/90). Returns True on success. + /// + /// (Since Bot API 7.4) + /// + /// - [userId] : Identifier of the user whose payment will be refunded + /// + /// - [telegramPaymentChargeId] : Telegram payment identifier + Future refundStarPayment({ + required int userId, + required String telegramPaymentChargeId, + }) async { + Map params = { + "user_id": userId, + "telegram_payment_charge_id": telegramPaymentChargeId, + }; + + bool response = await _httpClient.postURI( + _buildUri(APIMethod.refundStarPayment), + params, + ); + return response; + } } diff --git a/lib/src/types/methods.dart b/lib/src/types/methods.dart index 0a549b57..d310b935 100644 --- a/lib/src/types/methods.dart +++ b/lib/src/types/methods.dart @@ -370,6 +370,9 @@ enum APIMethod { /// To replace an exsiting sticker in a sticker pack replaceStickerInSet._("replaceStickerInSet"), + + /// To refunds a successful payment in Telegram Stars. + refundStarPayment._("refundStarPayment"), ; /// The name of the method. From 50ef770f81a8d06b68e24a555d68b993fe1ff5ec Mon Sep 17 00:00:00 2001 From: Sreelal TS Date: Fri, 31 May 2024 16:36:21 +0530 Subject: [PATCH 05/11] =?UTF-8?q?=F0=9F=AA=85=20Message=20Effects=20&=20Re?= =?UTF-8?q?factors?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/src/telegram/models/message.dart | 71 +++---------------- lib/src/televerse/extensions/extensions.dart | 1 + lib/src/televerse/extensions/message_ext.dart | 70 ++++++++++++++++++ lib/src/televerse/raw_api.dart | 34 +++++++++ 4 files changed, 113 insertions(+), 63 deletions(-) create mode 100644 lib/src/televerse/extensions/message_ext.dart diff --git a/lib/src/telegram/models/message.dart b/lib/src/telegram/models/message.dart index 39d732e3..f3b6231b 100644 --- a/lib/src/telegram/models/message.dart +++ b/lib/src/telegram/models/message.dart @@ -251,6 +251,11 @@ class Message implements MaybeInaccessibleMessage, WithUser { /// Optional. Service message: chat background set final ChatBackground? chatBackgroundSet; + /// Optional. Unique identifier of the message effect added to the message + /// + /// (Since Bot API 7.4) + final String? effectId; + /// Creates a Message object. const Message({ this.from, @@ -334,6 +339,7 @@ class Message implements MaybeInaccessibleMessage, WithUser { this.senderBusinessBot, this.isFromOffline, this.chatBackgroundSet, + this.effectId, }); /// Creates a [Message] object from json map. @@ -518,6 +524,7 @@ class Message implements MaybeInaccessibleMessage, WithUser { chatBackgroundSet: json["chat_background_set"] != null ? ChatBackground.fromJson(json["chat_background_set"]) : null, + effectId: json["effect_id"], ); } @@ -607,72 +614,10 @@ class Message implements MaybeInaccessibleMessage, WithUser { 'sender_business_bot': senderBusinessBot?.toJson(), 'is_from_offline': isFromOffline, 'chat_background_set': chatBackgroundSet?.toJson(), + 'effect_id': effectId, }..removeWhere(_nullFilter); } - /// Getter for the [DateTime] object that represents the message sent date - DateTime get dateTime => date.toDateTime(); - - /// Getter for the [DateTime] object that represents the message edit date - DateTime? get editDateTime => editDate?.toDateTime(); - - /// Getter for the [DateTime] object that represents the message forward date - DateTime? get forwardDateTime { - if (forwardOrigin == null) return null; - return forwardOrigin!.date.toDateTime(); - } - - /// Returns true if the message is a command - bool get isCommand => entities != null && entities!.isNotEmpty - ? entities!.first.type == MessageEntityType.botCommand && - entities!.first.offset == 0 - : false; - - /// Returns the text where the given [MessageEntityType] is found - String? getEntityText(MessageEntityType type) { - if (entities == null || entities!.isEmpty) return null; - if ((text ?? caption) == null) return null; - if (entities?.any((element) => element.type == type) != true) return null; - final entity = (entities ?? captionEntities) - ?.firstWhere((element) => element.type == type); - if (entity == null) return null; - String entxt = - text!.substring(entity.offset, entity.offset + entity.length); - - switch (type) { - case MessageEntityType.mention: - case MessageEntityType.hashtag: - case MessageEntityType.cashtag: - entxt = entxt.substring(1); - break; - case MessageEntityType.botCommand: - if (entxt.contains('@')) { - entxt = entxt.substring(0, entxt.indexOf('@')); - } else { - entxt = entxt.substring(1); - } - break; - case MessageEntityType.textMention: - case MessageEntityType.url: - case MessageEntityType.email: - case MessageEntityType.phoneNumber: - case MessageEntityType.bold: - case MessageEntityType.italic: - case MessageEntityType.underline: - case MessageEntityType.strikethrough: - case MessageEntityType.spoiler: - case MessageEntityType.code: - case MessageEntityType.pre: - case MessageEntityType.textLink: - case MessageEntityType.blockquote: - break; - case MessageEntityType.customEmoji: - entxt = entity.customEmojiId!; - break; - } - return entxt; - } - @override bool get isAccessible => true; diff --git a/lib/src/televerse/extensions/extensions.dart b/lib/src/televerse/extensions/extensions.dart index ade57815..368b9805 100644 --- a/lib/src/televerse/extensions/extensions.dart +++ b/lib/src/televerse/extensions/extensions.dart @@ -5,3 +5,4 @@ import 'package:televerse/telegram.dart'; import 'package:televerse/televerse.dart'; part 'user_mention.dart'; +part 'message_ext.dart'; diff --git a/lib/src/televerse/extensions/message_ext.dart b/lib/src/televerse/extensions/message_ext.dart new file mode 100644 index 00000000..908975de --- /dev/null +++ b/lib/src/televerse/extensions/message_ext.dart @@ -0,0 +1,70 @@ +part of 'extensions.dart'; + +/// Additional useful methods and properties on the [Message] class. +extension MessageExtension on Message { + /// Getter for the [DateTime] object that represents the message sent date + DateTime get dateTime => date.toDateTime(); + + /// Getter for the [DateTime] object that represents the message edit date + DateTime? get editDateTime => editDate?.toDateTime(); + + /// Getter for the [DateTime] object that represents the message forward date + DateTime? get forwardDateTime { + if (forwardOrigin == null) return null; + return forwardOrigin!.date.toDateTime(); + } + + /// Returns true if the message is a command + bool get isCommand => entities != null && entities!.isNotEmpty + ? entities!.first.type == MessageEntityType.botCommand && + entities!.first.offset == 0 + : false; + + /// Returns the text where the given [MessageEntityType] is found + String? getEntityText(MessageEntityType type) { + if (entities == null || entities!.isEmpty) return null; + if ((text ?? caption) == null) return null; + if (entities?.any((element) => element.type == type) != true) return null; + final entity = (entities ?? captionEntities) + ?.firstWhere((element) => element.type == type); + if (entity == null) return null; + String entxt = + text!.substring(entity.offset, entity.offset + entity.length); + + switch (type) { + case MessageEntityType.mention: + case MessageEntityType.hashtag: + case MessageEntityType.cashtag: + entxt = entxt.substring(1); + break; + case MessageEntityType.botCommand: + if (entxt.contains('@')) { + entxt = entxt.substring(0, entxt.indexOf('@')); + } else { + entxt = entxt.substring(1); + } + break; + case MessageEntityType.textMention: + case MessageEntityType.url: + case MessageEntityType.email: + case MessageEntityType.phoneNumber: + case MessageEntityType.bold: + case MessageEntityType.italic: + case MessageEntityType.underline: + case MessageEntityType.strikethrough: + case MessageEntityType.spoiler: + case MessageEntityType.code: + case MessageEntityType.pre: + case MessageEntityType.textLink: + case MessageEntityType.blockquote: + break; + case MessageEntityType.customEmoji: + entxt = entity.customEmojiId!; + break; + } + return entxt; + } + + /// Flag to determine whether a message effect is added to the current message + bool get hasEffect => effectId != null; +} diff --git a/lib/src/televerse/raw_api.dart b/lib/src/televerse/raw_api.dart index fb235279..056045ff 100644 --- a/lib/src/televerse/raw_api.dart +++ b/lib/src/televerse/raw_api.dart @@ -283,6 +283,7 @@ class RawAPI { ReplyParameters? replyParameters, LinkPreviewOptions? linkPreviewOptions, String? businessConnectionId, + String? messageEffectId, }) async { Map params = { "chat_id": chatId.id, @@ -296,6 +297,7 @@ class RawAPI { "reply_parameters": replyParameters?.toJson(), "link_preview_options": linkPreviewOptions?.toJson(), "business_connection_id": businessConnectionId, + "message_effect_id": messageEffectId, }; Uri uri = _buildUri(APIMethod.sendMessage); @@ -397,6 +399,7 @@ class RawAPI { bool? hasSpoiler, ReplyParameters? replyParameters, String? businessConnectionId, + String? messageEffectId, }) async { Map params = { "chat_id": chatId.id, @@ -410,6 +413,7 @@ class RawAPI { "protect_content": protectContent, "reply_parameters": replyParameters?.toJson(), "business_connection_id": businessConnectionId, + "message_effect_id": messageEffectId, }; const field = "photo"; Map response; @@ -450,6 +454,7 @@ class RawAPI { ReplyMarkup? replyMarkup, ReplyParameters? replyParameters, String? businessConnectionId, + String? messageEffectId, }) async { Map params = { "chat_id": chatId.id, @@ -465,6 +470,7 @@ class RawAPI { "reply_markup": replyMarkup?.toJson(), "reply_parameters": replyParameters?.toJson(), "business_connection_id": businessConnectionId, + "message_effect_id": messageEffectId, }; const field = "audio"; @@ -507,6 +513,7 @@ class RawAPI { ReplyMarkup? replyMarkup, ReplyParameters? replyParameters, String? businessConnectionId, + String? messageEffectId, }) async { Map params = { "chat_id": chatId.id, @@ -520,6 +527,7 @@ class RawAPI { "reply_markup": replyMarkup?.toJson(), "reply_parameters": replyParameters?.toJson(), "business_connection_id": businessConnectionId, + "message_effect_id": messageEffectId, }; const field = "document"; @@ -565,6 +573,7 @@ class RawAPI { ReplyMarkup? replyMarkup, ReplyParameters? replyParameters, String? businessConnectionId, + String? messageEffectId, }) async { Map params = { "chat_id": chatId.id, @@ -582,6 +591,7 @@ class RawAPI { "reply_markup": replyMarkup?.toJson(), "reply_parameters": replyParameters?.toJson(), "business_connection_id": businessConnectionId, + "message_effect_id": messageEffectId, }; final field = "video"; Map response; @@ -623,6 +633,7 @@ class RawAPI { ReplyMarkup? replyMarkup, ReplyParameters? replyParameters, String? businessConnectionId, + String? messageEffectId, }) async { Map params = { "chat_id": chatId.id, @@ -639,6 +650,7 @@ class RawAPI { "reply_markup": replyMarkup?.toJson(), "reply_parameters": replyParameters?.toJson(), "business_connection_id": businessConnectionId, + "message_effect_id": messageEffectId, }; const field = "animation"; Map response; @@ -678,6 +690,7 @@ class RawAPI { ReplyMarkup? replyMarkup, ReplyParameters? replyParameters, String? businessConnectionId, + String? messageEffectId, }) async { Map params = { "chat_id": chatId.id, @@ -691,6 +704,7 @@ class RawAPI { "reply_markup": replyMarkup?.toJson(), "reply_parameters": replyParameters?.toJson(), "business_connection_id": businessConnectionId, + "message_effect_id": messageEffectId, }; const field = "voice"; Map response; @@ -726,6 +740,7 @@ class RawAPI { ReplyMarkup? replyMarkup, ReplyParameters? replyParameters, String? businessConnectionId, + String? messageEffectId, }) async { Map params = { "chat_id": chatId.id, @@ -738,6 +753,7 @@ class RawAPI { "reply_markup": replyMarkup?.toJson(), "reply_parameters": replyParameters?.toJson(), "business_connection_id": businessConnectionId, + "message_effect_id": messageEffectId, }; const field = "video_note"; Map response; @@ -769,6 +785,7 @@ class RawAPI { bool? protectContent, ReplyParameters? replyParameters, String? businessConnectionId, + String? messageEffectId, }) async { if (media.length > 10) { throw TeleverseException( @@ -804,6 +821,7 @@ class RawAPI { "protect_content": protectContent, "reply_parameters": replyParameters?.toJson(), "business_connection_id": businessConnectionId, + "message_effect_id": messageEffectId, }; List<_MultipartHelper> helpers = []; @@ -850,6 +868,7 @@ class RawAPI { ReplyMarkup? replyMarkup, ReplyParameters? replyParameters, String? businessConnectionId, + String? messageEffectId, }) async { Map params = { "chat_id": chatId.id, @@ -865,6 +884,7 @@ class RawAPI { "reply_markup": replyMarkup?.toJson(), "reply_parameters": replyParameters?.toJson(), "business_connection_id": businessConnectionId, + "message_effect_id": messageEffectId, }; Map response = await _httpClient.postURI( _buildUri(APIMethod.sendLocation), @@ -1005,6 +1025,7 @@ class RawAPI { ReplyMarkup? replyMarkup, ReplyParameters? replyParameters, String? businessConnectionId, + String? messageEffectId, }) async { Map params = { "chat_id": chatId.id, @@ -1022,6 +1043,7 @@ class RawAPI { "reply_markup": replyMarkup?.toJson(), "reply_parameters": replyParameters?.toJson(), "business_connection_id": businessConnectionId, + "message_effect_id": messageEffectId, }; Map response = await _httpClient.postURI( _buildUri(APIMethod.sendVenue), @@ -1043,6 +1065,7 @@ class RawAPI { ReplyMarkup? replyMarkup, ReplyParameters? replyParameters, String? businessConnectionId, + String? messageEffectId, }) async { Map params = { "chat_id": chatId.id, @@ -1056,6 +1079,7 @@ class RawAPI { "reply_markup": replyMarkup?.toJson(), "reply_parameters": replyParameters?.toJson(), "business_connection_id": businessConnectionId, + "message_effect_id": messageEffectId, }; Map response = await _httpClient.postURI( _buildUri(APIMethod.sendContact), @@ -1087,6 +1111,7 @@ class RawAPI { String? businessConnectionId, ParseMode? questionParseMode, List? questionEntities, + String? messageEffectId, }) async { if (options.length < 2 || options.length > 10) { throw TeleverseException( @@ -1164,6 +1189,7 @@ class RawAPI { "business_connection_id": businessConnectionId, "question_entities": questionEntities?.map((e) => e.toJson()).toList(), "question_parse_mode": questionParseMode?.value, + "message_effect_id": messageEffectId, }; Map response = await _httpClient.postURI( _buildUri(APIMethod.sendPoll), @@ -1191,6 +1217,7 @@ class RawAPI { ReplyMarkup? replyMarkup, ReplyParameters? replyParameters, String? businessConnectionId, + String? messageEffectId, }) async { Map params = { "chat_id": chatId.id, @@ -1201,6 +1228,7 @@ class RawAPI { "reply_markup": replyMarkup?.toJson(), "reply_parameters": replyParameters?.toJson(), "business_connection_id": businessConnectionId, + "message_effect_id": messageEffectId, }; Map response = await _httpClient.postURI( _buildUri(APIMethod.sendDice), @@ -2517,6 +2545,7 @@ class RawAPI { String? emoji, ReplyParameters? replyParameters, String? businessConnectionId, + String? messageEffectId, }) async { Map params = { "chat_id": chatId.id, @@ -2527,6 +2556,7 @@ class RawAPI { "emoji": emoji, "reply_parameters": replyParameters?.toJson(), "business_connection_id": businessConnectionId, + "message_effect_id": messageEffectId, }; const field = "sticker"; Map response; @@ -2816,6 +2846,7 @@ class RawAPI { bool? protectContent, InlineKeyboardMarkup? replyMarkup, ReplyParameters? replyParameters, + String? messageEffectId, }) async { Map params = { "chat_id": chatId.id, @@ -2845,6 +2876,7 @@ class RawAPI { "protect_content": protectContent, "reply_markup": replyMarkup?.toJson(), "reply_parameters": replyParameters?.toJson(), + "message_effect_id": messageEffectId, }; Map response = await _httpClient.postURI( @@ -3032,6 +3064,7 @@ class RawAPI { ReplyMarkup? replyMarkup, ReplyParameters? replyParameters, String? businessConnectionId, + String? messageEffectId, }) async { Map params = { "chat_id": chatId.id, @@ -3042,6 +3075,7 @@ class RawAPI { "reply_markup": replyMarkup?.toJson(), "reply_parameters": replyParameters?.toJson(), "business_connection_id": businessConnectionId, + "message_effect_id": messageEffectId, }; Map response = await _httpClient.postURI( From caa80320f6d88e27e8e3827c857231c2b7377981 Mon Sep 17 00:00:00 2001 From: Sreelal TS Date: Fri, 31 May 2024 16:55:54 +0530 Subject: [PATCH 06/11] =?UTF-8?q?=F0=9F=91=A9=F0=9F=8F=BB=E2=80=8D?= =?UTF-8?q?=E2=9C=88=EF=B8=8F=20Show=20caption=20above=20media?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../models/inline_query_result_cached_gif.dart | 9 +++++++++ .../models/inline_query_result_cached_mpeg4_gif.dart | 9 +++++++++ .../models/inline_query_result_cached_photo.dart | 9 +++++++++ .../models/inline_query_result_cached_video.dart | 10 ++++++++++ lib/src/telegram/models/inline_query_result_gif.dart | 9 +++++++++ .../telegram/models/inline_query_result_mpeg4_gif.dart | 9 +++++++++ lib/src/telegram/models/inline_query_result_photo.dart | 9 +++++++++ lib/src/telegram/models/inline_query_result_video.dart | 9 +++++++++ lib/src/telegram/models/input_media_animation.dart | 5 +++++ lib/src/telegram/models/input_media_photo.dart | 5 +++++ lib/src/telegram/models/input_media_video.dart | 5 +++++ lib/src/telegram/models/message.dart | 10 ++++++++-- lib/src/televerse/raw_api.dart | 10 ++++++++++ 13 files changed, 106 insertions(+), 2 deletions(-) diff --git a/lib/src/telegram/models/inline_query_result_cached_gif.dart b/lib/src/telegram/models/inline_query_result_cached_gif.dart index 7ba33850..9e54554f 100644 --- a/lib/src/telegram/models/inline_query_result_cached_gif.dart +++ b/lib/src/telegram/models/inline_query_result_cached_gif.dart @@ -32,6 +32,9 @@ class InlineQueryResultCachedGif implements InlineQueryResult { /// Optional. Content of the message to be sent instead of the GIF animation final InputMessageContent? inputMessageContent; + /// Optional. True, if the caption must be shown above the message media + final bool? showCaptionAboveMedia; + /// Constructs an [InlineQueryResultCachedGif] object const InlineQueryResultCachedGif({ required this.gifFileId, @@ -42,6 +45,7 @@ class InlineQueryResultCachedGif implements InlineQueryResult { this.captionEntities, this.replyMarkup, this.inputMessageContent, + this.showCaptionAboveMedia, }); /// Converts an [InlineQueryResultCachedGif] object to a JSON map @@ -57,6 +61,7 @@ class InlineQueryResultCachedGif implements InlineQueryResult { 'caption_entities': captionEntities?.map((e) => e.toJson()).toList(), 'reply_markup': replyMarkup?.toJson(), 'input_message_content': inputMessageContent?.toJson(), + 'show_caption_above_media': showCaptionAboveMedia, }..removeWhere(_nullFilter); } @@ -83,6 +88,7 @@ class InlineQueryResultCachedGif implements InlineQueryResult { : InputMessageContent.fromJson( json['input_message_content'] as Map, ), + showCaptionAboveMedia: json['show_caption_above_media'], ); } @@ -96,6 +102,7 @@ class InlineQueryResultCachedGif implements InlineQueryResult { List? captionEntities, InlineKeyboardMarkup? replyMarkup, InputMessageContent? inputMessageContent, + bool? showCaptionAboveMedia, }) { return InlineQueryResultCachedGif( id: id ?? this.id, @@ -106,6 +113,8 @@ class InlineQueryResultCachedGif implements InlineQueryResult { captionEntities: captionEntities ?? this.captionEntities, replyMarkup: replyMarkup ?? this.replyMarkup, inputMessageContent: inputMessageContent ?? this.inputMessageContent, + showCaptionAboveMedia: + showCaptionAboveMedia ?? this.showCaptionAboveMedia, ); } } diff --git a/lib/src/telegram/models/inline_query_result_cached_mpeg4_gif.dart b/lib/src/telegram/models/inline_query_result_cached_mpeg4_gif.dart index b5420b06..1038db45 100644 --- a/lib/src/telegram/models/inline_query_result_cached_mpeg4_gif.dart +++ b/lib/src/telegram/models/inline_query_result_cached_mpeg4_gif.dart @@ -32,6 +32,9 @@ class InlineQueryResultCachedMpeg4Gif implements InlineQueryResult { /// Optional. Content of the message to be sent instead of the video animation final InputMessageContent? inputMessageContent; + /// Optional. True, if the caption must be shown above the message media + final bool? showCaptionAboveMedia; + /// Constructs an [InlineQueryResultCachedMpeg4Gif] object const InlineQueryResultCachedMpeg4Gif({ required this.mpeg4FileId, @@ -42,6 +45,7 @@ class InlineQueryResultCachedMpeg4Gif implements InlineQueryResult { this.captionEntities, this.replyMarkup, this.inputMessageContent, + this.showCaptionAboveMedia, }); /// Converts an [InlineQueryResultCachedMpeg4Gif] object to a JSON map @@ -57,6 +61,7 @@ class InlineQueryResultCachedMpeg4Gif implements InlineQueryResult { 'reply_markup': replyMarkup?.toJson(), 'input_message_content': inputMessageContent?.toJson(), 'id': id, + 'show_caption_above_media': showCaptionAboveMedia, }..removeWhere(_nullFilter); } @@ -83,6 +88,7 @@ class InlineQueryResultCachedMpeg4Gif implements InlineQueryResult { : InputMessageContent.fromJson( json['input_message_content'] as Map, ), + showCaptionAboveMedia: json['show_caption_above_media'], ); } @@ -96,6 +102,7 @@ class InlineQueryResultCachedMpeg4Gif implements InlineQueryResult { List? captionEntities, InlineKeyboardMarkup? replyMarkup, InputMessageContent? inputMessageContent, + bool? showCaptionAboveMedia, }) { return InlineQueryResultCachedMpeg4Gif( id: id ?? this.id, @@ -106,6 +113,8 @@ class InlineQueryResultCachedMpeg4Gif implements InlineQueryResult { captionEntities: captionEntities ?? this.captionEntities, replyMarkup: replyMarkup ?? this.replyMarkup, inputMessageContent: inputMessageContent ?? this.inputMessageContent, + showCaptionAboveMedia: + showCaptionAboveMedia ?? this.showCaptionAboveMedia, ); } } diff --git a/lib/src/telegram/models/inline_query_result_cached_photo.dart b/lib/src/telegram/models/inline_query_result_cached_photo.dart index 44e52e68..9c5677f3 100644 --- a/lib/src/telegram/models/inline_query_result_cached_photo.dart +++ b/lib/src/telegram/models/inline_query_result_cached_photo.dart @@ -35,6 +35,9 @@ class InlineQueryResultCachedPhoto implements InlineQueryResult { /// Optional. Content of the message to be sent instead of the photo final InputMessageContent? inputMessageContent; + /// Optional. True, if the caption must be shown above the message media + final bool? showCaptionAboveMedia; + /// Constructs an [InlineQueryResultCachedPhoto] object const InlineQueryResultCachedPhoto({ required this.photoFileId, @@ -46,6 +49,7 @@ class InlineQueryResultCachedPhoto implements InlineQueryResult { this.captionEntities, this.replyMarkup, this.inputMessageContent, + this.showCaptionAboveMedia, }); /// Converts an [InlineQueryResultCachedPhoto] object to a JSON map @@ -62,6 +66,7 @@ class InlineQueryResultCachedPhoto implements InlineQueryResult { 'reply_markup': replyMarkup?.toJson(), 'input_message_content': inputMessageContent?.toJson(), 'id': id, + 'show_caption_above_media': showCaptionAboveMedia, }..removeWhere(_nullFilter); } @@ -91,6 +96,7 @@ class InlineQueryResultCachedPhoto implements InlineQueryResult { : InputMessageContent.fromJson( json['input_message_content'] as Map, ), + showCaptionAboveMedia: json['show_caption_above_media'], ); } @@ -105,6 +111,7 @@ class InlineQueryResultCachedPhoto implements InlineQueryResult { List? captionEntities, InlineKeyboardMarkup? replyMarkup, InputMessageContent? inputMessageContent, + bool? showCaptionAboveMedia, }) { return InlineQueryResultCachedPhoto( id: id ?? this.id, @@ -116,6 +123,8 @@ class InlineQueryResultCachedPhoto implements InlineQueryResult { captionEntities: captionEntities ?? this.captionEntities, replyMarkup: replyMarkup ?? this.replyMarkup, inputMessageContent: inputMessageContent ?? this.inputMessageContent, + showCaptionAboveMedia: + showCaptionAboveMedia ?? this.showCaptionAboveMedia, ); } } diff --git a/lib/src/telegram/models/inline_query_result_cached_video.dart b/lib/src/telegram/models/inline_query_result_cached_video.dart index b8be1a3c..bca2dfac 100644 --- a/lib/src/telegram/models/inline_query_result_cached_video.dart +++ b/lib/src/telegram/models/inline_query_result_cached_video.dart @@ -35,6 +35,10 @@ class InlineQueryResultCachedVideo implements InlineQueryResult { /// Optional. Content of the message to be sent instead of the video final InputMessageContent? inputMessageContent; + /// Optional. True, if the caption must be shown above the message media + + final bool? showCaptionAboveMedia; + /// Constructs an [InlineQueryResultCachedVideo] object const InlineQueryResultCachedVideo({ required this.videoFileId, @@ -46,6 +50,7 @@ class InlineQueryResultCachedVideo implements InlineQueryResult { this.captionEntities, this.replyMarkup, this.inputMessageContent, + this.showCaptionAboveMedia, }); /// Converts an [InlineQueryResultCachedVideo] object to a JSON map @@ -62,6 +67,7 @@ class InlineQueryResultCachedVideo implements InlineQueryResult { 'reply_markup': replyMarkup?.toJson(), 'input_message_content': inputMessageContent?.toJson(), 'id': id, + 'show_caption_above_media': showCaptionAboveMedia, }..removeWhere(_nullFilter); } @@ -89,6 +95,7 @@ class InlineQueryResultCachedVideo implements InlineQueryResult { : InputMessageContent.fromJson( json['input_message_content'] as Map, ), + showCaptionAboveMedia: json['show_caption_above_media'], ); } @@ -103,6 +110,7 @@ class InlineQueryResultCachedVideo implements InlineQueryResult { List? captionEntities, InlineKeyboardMarkup? replyMarkup, InputMessageContent? inputMessageContent, + bool? showCaptionAboveMedia, }) { return InlineQueryResultCachedVideo( id: id ?? this.id, @@ -114,6 +122,8 @@ class InlineQueryResultCachedVideo implements InlineQueryResult { captionEntities: captionEntities ?? this.captionEntities, replyMarkup: replyMarkup ?? this.replyMarkup, inputMessageContent: inputMessageContent ?? this.inputMessageContent, + showCaptionAboveMedia: + showCaptionAboveMedia ?? this.showCaptionAboveMedia, ); } } diff --git a/lib/src/telegram/models/inline_query_result_gif.dart b/lib/src/telegram/models/inline_query_result_gif.dart index 0ba58cb3..ce85f258 100644 --- a/lib/src/telegram/models/inline_query_result_gif.dart +++ b/lib/src/telegram/models/inline_query_result_gif.dart @@ -47,6 +47,9 @@ class InlineQueryResultGif implements InlineQueryResult { /// Optional. Content of the message to be sent instead of the GIF animation final InputMessageContent? inputMessageContent; + /// Optional. True, if the caption must be shown above the message media + final bool? showCaptionAboveMedia; + /// Constructs an [InlineQueryResultGif] object const InlineQueryResultGif({ required this.gifUrl, @@ -62,6 +65,7 @@ class InlineQueryResultGif implements InlineQueryResult { this.captionEntities, this.replyMarkup, this.inputMessageContent, + this.showCaptionAboveMedia, }); /// Converts an [InlineQueryResultGif] object to a JSON map @@ -82,6 +86,7 @@ class InlineQueryResultGif implements InlineQueryResult { 'caption_entities': captionEntities, 'reply_markup': replyMarkup, 'input_message_content': inputMessageContent, + 'show_caption_above_media': showCaptionAboveMedia, }..removeWhere(_nullFilter); } @@ -109,6 +114,7 @@ class InlineQueryResultGif implements InlineQueryResult { inputMessageContent: json['input_message_content'] != null ? InputMessageContent.fromJson(json['input_message_content']) : null, + showCaptionAboveMedia: json['show_caption_above_media'], ); } @@ -127,6 +133,7 @@ class InlineQueryResultGif implements InlineQueryResult { List? captionEntities, InlineKeyboardMarkup? replyMarkup, InputMessageContent? inputMessageContent, + bool? showCaptionAboveMedia, }) { return InlineQueryResultGif( id: id ?? this.id, @@ -142,6 +149,8 @@ class InlineQueryResultGif implements InlineQueryResult { captionEntities: captionEntities ?? this.captionEntities, replyMarkup: replyMarkup ?? this.replyMarkup, inputMessageContent: inputMessageContent ?? this.inputMessageContent, + showCaptionAboveMedia: + showCaptionAboveMedia ?? this.showCaptionAboveMedia, ); } } diff --git a/lib/src/telegram/models/inline_query_result_mpeg4_gif.dart b/lib/src/telegram/models/inline_query_result_mpeg4_gif.dart index d12aacb1..2bfbac0d 100644 --- a/lib/src/telegram/models/inline_query_result_mpeg4_gif.dart +++ b/lib/src/telegram/models/inline_query_result_mpeg4_gif.dart @@ -47,6 +47,9 @@ class InlineQueryResultMpeg4Gif implements InlineQueryResult { /// Optional. Content of the message to be sent instead of the video animation final InputMessageContent? inputMessageContent; + /// Optional. True, if the caption must be shown above the message media + final bool? showCaptionAboveMedia; + /// Constructs an [InlineQueryResultMpeg4Gif] object const InlineQueryResultMpeg4Gif({ required this.mpeg4Url, @@ -62,6 +65,7 @@ class InlineQueryResultMpeg4Gif implements InlineQueryResult { this.captionEntities, this.replyMarkup, this.inputMessageContent, + this.showCaptionAboveMedia, }); /// Converts an [InlineQueryResultMpeg4Gif] object to a JSON object @@ -82,6 +86,7 @@ class InlineQueryResultMpeg4Gif implements InlineQueryResult { 'caption_entities': captionEntities?.map((e) => e.toJson()).toList(), 'reply_markup': replyMarkup?.toJson(), 'input_message_content': inputMessageContent?.toJson(), + 'show_caption_above_media': showCaptionAboveMedia, }..removeWhere(_nullFilter); } @@ -113,6 +118,7 @@ class InlineQueryResultMpeg4Gif implements InlineQueryResult { : InputMessageContent.fromJson( json['input_message_content'] as Map, ), + showCaptionAboveMedia: json['show_caption_above_media'], ); } @@ -131,6 +137,7 @@ class InlineQueryResultMpeg4Gif implements InlineQueryResult { List? captionEntities, InlineKeyboardMarkup? replyMarkup, InputMessageContent? inputMessageContent, + bool? showCaptionAboveMedia, }) { return InlineQueryResultMpeg4Gif( id: id ?? this.id, @@ -146,6 +153,8 @@ class InlineQueryResultMpeg4Gif implements InlineQueryResult { captionEntities: captionEntities ?? this.captionEntities, replyMarkup: replyMarkup ?? this.replyMarkup, inputMessageContent: inputMessageContent ?? this.inputMessageContent, + showCaptionAboveMedia: + showCaptionAboveMedia ?? this.showCaptionAboveMedia, ); } } diff --git a/lib/src/telegram/models/inline_query_result_photo.dart b/lib/src/telegram/models/inline_query_result_photo.dart index 8fcc4a20..d25b3a31 100644 --- a/lib/src/telegram/models/inline_query_result_photo.dart +++ b/lib/src/telegram/models/inline_query_result_photo.dart @@ -44,6 +44,9 @@ class InlineQueryResultPhoto implements InlineQueryResult { /// Optional. Content of the message to be sent instead of the photo final InputMessageContent? inputMessageContent; + /// Optional. True, if the caption must be shown above the message media + final bool? showCaptionAboveMedia; + /// Constructs an [InlineQueryResultPhoto] object const InlineQueryResultPhoto({ required this.photoUrl, @@ -58,6 +61,7 @@ class InlineQueryResultPhoto implements InlineQueryResult { this.captionEntities, this.replyMarkup, this.inputMessageContent, + this.showCaptionAboveMedia, }); /// Converts an [InlineQueryResultPhoto] object to a JSON object @@ -77,6 +81,7 @@ class InlineQueryResultPhoto implements InlineQueryResult { 'reply_markup': replyMarkup?.toJson(), 'input_message_content': inputMessageContent?.toJson(), 'id': id, + 'show_caption_above_media': showCaptionAboveMedia, }..removeWhere(_nullFilter); } @@ -107,6 +112,7 @@ class InlineQueryResultPhoto implements InlineQueryResult { : InputMessageContent.fromJson( json['input_message_content'] as Map, ), + showCaptionAboveMedia: json['show_caption_above_media'], ); } @@ -124,6 +130,7 @@ class InlineQueryResultPhoto implements InlineQueryResult { List? captionEntities, InlineKeyboardMarkup? replyMarkup, InputMessageContent? inputMessageContent, + bool? showCaptionAboveMedia, }) { return InlineQueryResultPhoto( id: id ?? this.id, @@ -138,6 +145,8 @@ class InlineQueryResultPhoto implements InlineQueryResult { captionEntities: captionEntities ?? this.captionEntities, replyMarkup: replyMarkup ?? this.replyMarkup, inputMessageContent: inputMessageContent ?? this.inputMessageContent, + showCaptionAboveMedia: + showCaptionAboveMedia ?? this.showCaptionAboveMedia, ); } } diff --git a/lib/src/telegram/models/inline_query_result_video.dart b/lib/src/telegram/models/inline_query_result_video.dart index 034d32fb..7fd38dd3 100644 --- a/lib/src/telegram/models/inline_query_result_video.dart +++ b/lib/src/telegram/models/inline_query_result_video.dart @@ -52,6 +52,9 @@ class InlineQueryResultVideo implements InlineQueryResult { /// Optional. Content of the message to be sent instead of the video. This field is required if InlineQueryResultVideo is used to send an HTML-page as a result (e.g., a YouTube video). final InputMessageContent? inputMessageContent; + /// Optional. True, if the caption must be shown above the message media + final bool? showCaptionAboveMedia; + /// Converts [InlineQueryResultVideo] object to a JSON object @override Map toJson() { @@ -71,6 +74,7 @@ class InlineQueryResultVideo implements InlineQueryResult { 'reply_markup': replyMarkup?.toJson(), 'input_message_content': inputMessageContent?.toJson(), 'id': id, + 'show_caption_above_media': showCaptionAboveMedia, }..removeWhere(_nullFilter); } @@ -90,6 +94,7 @@ class InlineQueryResultVideo implements InlineQueryResult { this.description, this.replyMarkup, this.inputMessageContent, + this.showCaptionAboveMedia, }); /// Constructs an [InlineQueryResultVideo] from JSON object @@ -112,6 +117,7 @@ class InlineQueryResultVideo implements InlineQueryResult { replyMarkup: InlineKeyboardMarkup.fromJson(json['reply_markup']), inputMessageContent: InputMessageContent.fromJson(json['input_message_content']), + showCaptionAboveMedia: json['show_caption_above_media'], ); } @@ -131,6 +137,7 @@ class InlineQueryResultVideo implements InlineQueryResult { String? description, InlineKeyboardMarkup? replyMarkup, InputMessageContent? inputMessageContent, + bool? showCaptionAboveMedia, }) { return InlineQueryResultVideo( id: id ?? this.id, @@ -147,6 +154,8 @@ class InlineQueryResultVideo implements InlineQueryResult { description: description ?? this.description, replyMarkup: replyMarkup ?? this.replyMarkup, inputMessageContent: inputMessageContent ?? this.inputMessageContent, + showCaptionAboveMedia: + showCaptionAboveMedia ?? this.showCaptionAboveMedia, ); } } diff --git a/lib/src/telegram/models/input_media_animation.dart b/lib/src/telegram/models/input_media_animation.dart index c2a26ce9..0d224835 100644 --- a/lib/src/telegram/models/input_media_animation.dart +++ b/lib/src/telegram/models/input_media_animation.dart @@ -30,6 +30,9 @@ class InputMediaAnimation extends InputMedia { /// Optional. Pass True if the animation needs to be covered with a spoiler animation final bool? hasSpoiler; + /// Optional. True, if the caption must be shown above the message media + final bool? showCaptionAboveMedia; + /// Constructs an [InputMediaAnimation] object const InputMediaAnimation({ required super.media, @@ -41,6 +44,7 @@ class InputMediaAnimation extends InputMedia { this.height, this.duration, this.hasSpoiler, + this.showCaptionAboveMedia, }); /// Converts an [InputMediaAnimation] object to a JSON object @@ -57,6 +61,7 @@ class InputMediaAnimation extends InputMedia { 'height': height, 'duration': duration, 'has_spoiler': hasSpoiler, + 'show_caption_above_media': showCaptionAboveMedia, }..removeWhere(_nullFilter); } } diff --git a/lib/src/telegram/models/input_media_photo.dart b/lib/src/telegram/models/input_media_photo.dart index 5a1cd89a..d7f97047 100644 --- a/lib/src/telegram/models/input_media_photo.dart +++ b/lib/src/telegram/models/input_media_photo.dart @@ -18,6 +18,9 @@ class InputMediaPhoto extends InputMedia { /// Optional. Pass True if the photo needs to be covered with a spoiler animation final bool? hasSpoiler; + /// Optional. True, if the caption must be shown above the message media + final bool? showCaptionAboveMedia; + /// Constructs an [InputMediaPhoto] object const InputMediaPhoto({ required super.media, @@ -25,6 +28,7 @@ class InputMediaPhoto extends InputMedia { this.parseMode, this.captionEntities, this.hasSpoiler, + this.showCaptionAboveMedia, }); /// Converts an [InputMediaPhoto] object to a JSON object @@ -37,6 +41,7 @@ class InputMediaPhoto extends InputMedia { 'parse_mode': parseMode?.value, 'caption_entities': captionEntities, 'has_spoiler': hasSpoiler, + 'show_caption_above_media': showCaptionAboveMedia, }..removeWhere(_nullFilter); } } diff --git a/lib/src/telegram/models/input_media_video.dart b/lib/src/telegram/models/input_media_video.dart index c4ab0015..b61c0d06 100644 --- a/lib/src/telegram/models/input_media_video.dart +++ b/lib/src/telegram/models/input_media_video.dart @@ -33,6 +33,9 @@ class InputMediaVideo extends InputMedia { /// Optional. Pass True if the video needs to be covered with a spoiler animation final bool? hasSpoiler; + /// Optional. True, if the caption must be shown above the message media + final bool? showCaptionAboveMedia; + /// Constructs an [InputMediaVideo] object const InputMediaVideo({ required super.media, @@ -45,6 +48,7 @@ class InputMediaVideo extends InputMedia { this.duration, this.supportsStreaming, this.hasSpoiler, + this.showCaptionAboveMedia, }); /// Converts an [InputMediaVideo] object to a JSON object @@ -62,6 +66,7 @@ class InputMediaVideo extends InputMedia { 'duration': duration, 'supports_streaming': supportsStreaming, 'has_spoiler': hasSpoiler, + 'show_caption_above_media': showCaptionAboveMedia, }..removeWhere(_nullFilter); } } diff --git a/lib/src/telegram/models/message.dart b/lib/src/telegram/models/message.dart index f3b6231b..90579822 100644 --- a/lib/src/telegram/models/message.dart +++ b/lib/src/telegram/models/message.dart @@ -251,11 +251,14 @@ class Message implements MaybeInaccessibleMessage, WithUser { /// Optional. Service message: chat background set final ChatBackground? chatBackgroundSet; + // (Since Bot API 7.4) + /// Optional. Unique identifier of the message effect added to the message - /// - /// (Since Bot API 7.4) final String? effectId; + /// Optional. True, if the caption must be shown above the message media + final bool? showCaptionAboveMedia; + /// Creates a Message object. const Message({ this.from, @@ -340,6 +343,7 @@ class Message implements MaybeInaccessibleMessage, WithUser { this.isFromOffline, this.chatBackgroundSet, this.effectId, + this.showCaptionAboveMedia, }); /// Creates a [Message] object from json map. @@ -525,6 +529,7 @@ class Message implements MaybeInaccessibleMessage, WithUser { ? ChatBackground.fromJson(json["chat_background_set"]) : null, effectId: json["effect_id"], + showCaptionAboveMedia: json["show_caption_above_media"], ); } @@ -615,6 +620,7 @@ class Message implements MaybeInaccessibleMessage, WithUser { 'is_from_offline': isFromOffline, 'chat_background_set': chatBackgroundSet?.toJson(), 'effect_id': effectId, + 'show_caption_above_media': showCaptionAboveMedia, }..removeWhere(_nullFilter); } diff --git a/lib/src/televerse/raw_api.dart b/lib/src/televerse/raw_api.dart index 056045ff..74f97799 100644 --- a/lib/src/televerse/raw_api.dart +++ b/lib/src/televerse/raw_api.dart @@ -400,6 +400,7 @@ class RawAPI { ReplyParameters? replyParameters, String? businessConnectionId, String? messageEffectId, + bool? showCaptionAboveMedia, }) async { Map params = { "chat_id": chatId.id, @@ -414,6 +415,7 @@ class RawAPI { "reply_parameters": replyParameters?.toJson(), "business_connection_id": businessConnectionId, "message_effect_id": messageEffectId, + "show_caption_above_media": showCaptionAboveMedia, }; const field = "photo"; Map response; @@ -574,6 +576,7 @@ class RawAPI { ReplyParameters? replyParameters, String? businessConnectionId, String? messageEffectId, + bool? showCaptionAboveMedia, }) async { Map params = { "chat_id": chatId.id, @@ -592,6 +595,7 @@ class RawAPI { "reply_parameters": replyParameters?.toJson(), "business_connection_id": businessConnectionId, "message_effect_id": messageEffectId, + "show_caption_above_media": showCaptionAboveMedia, }; final field = "video"; Map response; @@ -634,6 +638,7 @@ class RawAPI { ReplyParameters? replyParameters, String? businessConnectionId, String? messageEffectId, + bool? showCaptionAboveMedia, }) async { Map params = { "chat_id": chatId.id, @@ -651,6 +656,7 @@ class RawAPI { "reply_parameters": replyParameters?.toJson(), "business_connection_id": businessConnectionId, "message_effect_id": messageEffectId, + "show_caption_above_media": showCaptionAboveMedia, }; const field = "animation"; Map response; @@ -2310,6 +2316,7 @@ class RawAPI { ParseMode? parseMode, List? captionEntities, InlineKeyboardMarkup? replyMarkup, + bool? showCaptionAboveMedia, }) async { Map params = { "chat_id": chatId.id, @@ -2318,6 +2325,7 @@ class RawAPI { "parse_mode": parseMode?.value, "caption_entities": captionEntities?.map((e) => e.toJson()).toList(), "reply_markup": replyMarkup?.toJson(), + "show_caption_above_media": showCaptionAboveMedia, }; Map response = await _httpClient.postURI( _buildUri(APIMethod.editMessageCaption), @@ -3582,6 +3590,7 @@ class RawAPI { bool? disableNotification, bool? protectContent, bool? removeCaption, + bool? showCaptionAboveMedia, }) async { Map params = { "chat_id": chatId.id, @@ -3591,6 +3600,7 @@ class RawAPI { "disable_notification": disableNotification, "protect_content": protectContent, "remove_caption": removeCaption, + "show_caption_above_media": showCaptionAboveMedia, }; List response = await _httpClient.postURI( From 56de9461ea0dd2880ec9094f32b0c512a3530f78 Mon Sep 17 00:00:00 2001 From: Sreelal TS Date: Fri, 31 May 2024 16:57:32 +0530 Subject: [PATCH 07/11] =?UTF-8?q?=F0=9F=A6=86=20Expandable=20Blockquotes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/src/types/message_entity_type.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/src/types/message_entity_type.dart b/lib/src/types/message_entity_type.dart index 195547c9..ddbff4f7 100644 --- a/lib/src/types/message_entity_type.dart +++ b/lib/src/types/message_entity_type.dart @@ -72,6 +72,9 @@ enum MessageEntityType { /// Block quotation blockquote("blockquote"), + + /// Expandable Block Quote + expandableBlockquote("expandable_blockquote"), ; /// The value of this enum. From b4f3d2e52c91d5c3f3c33c8af12eb1b8b4ef6c0c Mon Sep 17 00:00:00 2001 From: Sreelal TS Date: Fri, 31 May 2024 17:08:59 +0530 Subject: [PATCH 08/11] =?UTF-8?q?=F0=9F=8D=BD=EF=B8=8F=20Finishing=20touch?= =?UTF-8?q?es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/src/televerse/extensions/message_ext.dart | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/lib/src/televerse/extensions/message_ext.dart b/lib/src/televerse/extensions/message_ext.dart index 908975de..9a170ff8 100644 --- a/lib/src/televerse/extensions/message_ext.dart +++ b/lib/src/televerse/extensions/message_ext.dart @@ -22,14 +22,23 @@ extension MessageExtension on Message { /// Returns the text where the given [MessageEntityType] is found String? getEntityText(MessageEntityType type) { - if (entities == null || entities!.isEmpty) return null; - if ((text ?? caption) == null) return null; - if (entities?.any((element) => element.type == type) != true) return null; - final entity = (entities ?? captionEntities) - ?.firstWhere((element) => element.type == type); - if (entity == null) return null; - String entxt = - text!.substring(entity.offset, entity.offset + entity.length); + final ents = entities ?? captionEntities; + final msgTxt = text ?? caption; + + // If entities property is null or is empty just return null + if (ents == null || ents.isEmpty) return null; + if (msgTxt == null) return null; + + if (ents.any((e) => e.type == type) != true) return null; + + final entity = ents.firstWhere( + (element) => element.type == type, + ); + + String entxt = msgTxt.substring( + entity.offset, + entity.offset + entity.length, + ); switch (type) { case MessageEntityType.mention: @@ -57,6 +66,7 @@ extension MessageExtension on Message { case MessageEntityType.pre: case MessageEntityType.textLink: case MessageEntityType.blockquote: + case MessageEntityType.expandableBlockquote: break; case MessageEntityType.customEmoji: entxt = entity.customEmojiId!; From d4295386ee050d92ec8fc105fd5ff7d3fbae78c5 Mon Sep 17 00:00:00 2001 From: Sreelal TS Date: Fri, 31 May 2024 17:16:51 +0530 Subject: [PATCH 09/11] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20Version=20Update?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 5 +++++ README.md | 10 +++++----- pubspec.yaml | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 05e393e2..34ad81e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# 1.17.0 + +- 🤖 Bot API 7.4 (May 28, 2024) +- Refactors and formatting improvements + # 1.16.0 - 🤖 Bot API 7.3 (May 6, 2024) diff --git a/README.md b/README.md index be74525c..8b4eff40 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![Pub Version](https://img.shields.io/pub/v/televerse?color=blue&logo=blue)](https://pub.dev/packages/televerse) ![GitHub](https://img.shields.io/github/license/HeySreelal/televerse?color=green) - ![](https://shields.io/badge/Latest-Bot%20API%207.3-blue) + ![](https://shields.io/badge/Latest-Bot%20API%207.4-blue) @@ -13,15 +13,15 @@ --- -🤖 `Bot API version: Bot API 7.3 (May 6, 2024)` +🤖 `Bot API version: Bot API 7.4 (May 28, 2024)` Televerse is a powerful, easy-to-use, and highly customizable Telegram bot framework built with Dart programming language. It provides a complete and well-structured API that enables developers to create and deploy complex Telegram bots with ease. Televerse provides a total of 0 dynamic types on its public interface, making it easy for developers to write strictly typed code. -## 🔥 Bot API 7.3 (May 6, 2024) +## 🔥 Bot API 7.4 (May 28, 2024) -In a nutshell, the updates include, InlineKeyboardMarkup support for business messages, infinite editability for live locations. Support for new poll features and to chat background changes service messages. +In a nutshell, the updates include new Payment system with [Telegram Stars](https://t.me/BotNews/90), support for message effects and expandable blockquotes. -Checkout [changelog](https://core.telegram.org/bots/api-changelog#may-6-2024) for more details! 🚀 +Checkout [changelog](https://core.telegram.org/bots/api#may-28-2024) for more details! 🚀
diff --git a/pubspec.yaml b/pubspec.yaml index d7f46489..99fbe256 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.3! -version: 1.16.0 +version: 1.17.0 homepage: https://github.com/HeySreelal/televerse topics: - telegram From 526494d10865d02655895ca78f33c382dd330c16 Mon Sep 17 00:00:00 2001 From: Sreelal TS Date: Fri, 31 May 2024 17:17:41 +0530 Subject: [PATCH 10/11] =?UTF-8?q?=F0=9F=94=BC=20Dependency=20upgrade?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 99fbe256..3c6ee2fd 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,5 +16,5 @@ dependencies: dio: ^5.4.0 dev_dependencies: - lints: ^3.0.0 + lints: ^4.0.0 test: ^1.25.0 From 3d0480c39018dd22d2fdbcb91b618ffa4ea694a8 Mon Sep 17 00:00:00 2001 From: Sreelal TS Date: Fri, 31 May 2024 17:27:26 +0530 Subject: [PATCH 11/11] =?UTF-8?q?=F0=9F=94=A5=20Context=20upgrades?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/src/televerse/context/context.dart | 49 ++++++++++++++++++++++++-- lib/src/televerse/raw_api.dart | 4 +++ 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/lib/src/televerse/context/context.dart b/lib/src/televerse/context/context.dart index 5060a263..ac773409 100644 --- a/lib/src/televerse/context/context.dart +++ b/lib/src/televerse/context/context.dart @@ -220,6 +220,7 @@ class Context { ReplyParameters? replyParameters, ReplyMarkup? replyMarkup, String? businessConnectionId, + String? messageEffectId, }) async { _verifyInfo([_chatId], APIMethod.sendMessage); return api.sendMessage( @@ -234,6 +235,7 @@ class Context { replyParameters: replyParameters, replyMarkup: replyMarkup, businessConnectionId: businessConnectionId, + messageEffectId: messageEffectId, ); } @@ -258,6 +260,8 @@ class Context { ReplyParameters? replyParameters, ReplyMarkup? replyMarkup, String? businessConnectionId, + String? messageEffectId, + bool? showCaptionAboveMedia, }) async { _verifyInfo([_chatId], APIMethod.sendPhoto); return api.sendPhoto( @@ -272,6 +276,8 @@ class Context { replyParameters: replyParameters, replyMarkup: replyMarkup, businessConnectionId: businessConnectionId, + messageEffectId: messageEffectId, + showCaptionAboveMedia: showCaptionAboveMedia, ); } @@ -294,6 +300,7 @@ class Context { ReplyParameters? replyParameters, ReplyMarkup? replyMarkup, String? businessConnectionId, + String? messageEffectId, }) async { _verifyInfo([_chatId], APIMethod.sendAudio); return api.sendAudio( @@ -312,6 +319,7 @@ class Context { replyParameters: replyParameters, replyMarkup: replyMarkup, businessConnectionId: businessConnectionId, + messageEffectId: messageEffectId, ); } @@ -332,6 +340,7 @@ class Context { ReplyParameters? replyParameters, ReplyMarkup? replyMarkup, String? businessConnectionId, + String? messageEffectId, }) async { _verifyInfo([_chatId], APIMethod.sendDocument); return api.sendDocument( @@ -348,6 +357,7 @@ class Context { replyParameters: replyParameters, replyMarkup: replyMarkup, businessConnectionId: businessConnectionId, + messageEffectId: messageEffectId, ); } @@ -372,6 +382,8 @@ class Context { ReplyParameters? replyParameters, ReplyMarkup? replyMarkup, String? businessConnectionId, + String? messageEffectId, + bool? showCaptionAboveMedia, }) async { _verifyInfo([_chatId], APIMethod.sendVideo); return api.sendVideo( @@ -392,6 +404,8 @@ class Context { replyParameters: replyParameters, replyMarkup: replyMarkup, businessConnectionId: businessConnectionId, + messageEffectId: messageEffectId, + showCaptionAboveMedia: showCaptionAboveMedia, ); } @@ -410,6 +424,7 @@ class Context { ReplyParameters? replyParameters, ReplyMarkup? replyMarkup, String? businessConnectionId, + String? messageEffectId, }) async { _verifyInfo([_chatId], APIMethod.sendVideoNote); return api.sendVideoNote( @@ -424,6 +439,7 @@ class Context { replyParameters: replyParameters, replyMarkup: replyMarkup, businessConnectionId: businessConnectionId, + messageEffectId: messageEffectId, ); } @@ -443,6 +459,7 @@ class Context { ReplyParameters? replyParameters, ReplyMarkup? replyMarkup, String? businessConnectionId, + String? messageEffectId, }) async { _verifyInfo([_chatId], APIMethod.sendVoice); return api.sendVoice( @@ -458,6 +475,7 @@ class Context { replyParameters: replyParameters, replyMarkup: replyMarkup, businessConnectionId: businessConnectionId, + messageEffectId: messageEffectId, ); } @@ -472,6 +490,7 @@ class Context { bool? protectContent, ReplyParameters? replyParameters, String? businessConnectionId, + String? messageEffectId, }) async { _verifyInfo([_chatId], APIMethod.sendMediaGroup); return api.sendMediaGroup( @@ -482,6 +501,7 @@ class Context { protectContent: protectContent, replyParameters: replyParameters, businessConnectionId: businessConnectionId, + messageEffectId: messageEffectId, ); } @@ -501,6 +521,7 @@ class Context { ReplyParameters? replyParameters, ReplyMarkup? replyMarkup, String? businessConnectionId, + String? messageEffectId, }) async { _verifyInfo([_chatId], APIMethod.sendLocation); return api.sendLocation( @@ -517,6 +538,7 @@ class Context { replyParameters: replyParameters, replyMarkup: replyMarkup, businessConnectionId: businessConnectionId, + messageEffectId: messageEffectId, ); } @@ -538,6 +560,7 @@ class Context { ReplyParameters? replyParameters, ReplyMarkup? replyMarkup, String? businessConnectionId, + String? messageEffectId, }) async { _verifyInfo([_chatId], APIMethod.sendVenue); return api.sendVenue( @@ -556,6 +579,7 @@ class Context { replyParameters: replyParameters, replyMarkup: replyMarkup, businessConnectionId: businessConnectionId, + messageEffectId: messageEffectId, ); } @@ -573,6 +597,7 @@ class Context { ReplyParameters? replyParameters, ReplyMarkup? replyMarkup, String? businessConnectionId, + String? messageEffectId, }) async { _verifyInfo([_chatId], APIMethod.sendContact); return api.sendContact( @@ -587,6 +612,7 @@ class Context { replyParameters: replyParameters, replyMarkup: replyMarkup, businessConnectionId: businessConnectionId, + messageEffectId: messageEffectId, ); } @@ -612,6 +638,7 @@ class Context { ReplyParameters? replyParameters, ReplyMarkup? replyMarkup, String? businessConnectionId, + String? messageEffectId, }) async { return api.sendPoll( id, @@ -633,6 +660,7 @@ class Context { replyParameters: replyParameters, replyMarkup: replyMarkup, businessConnectionId: businessConnectionId, + messageEffectId: messageEffectId, ); } @@ -647,6 +675,7 @@ class Context { ReplyParameters? replyParameters, ReplyMarkup? replyMarkup, String? businessConnectionId, + String? messageEffectId, }) async { _verifyInfo([_chatId], APIMethod.sendDice); return api.sendDice( @@ -658,6 +687,7 @@ class Context { replyParameters: replyParameters, replyMarkup: replyMarkup, businessConnectionId: businessConnectionId, + messageEffectId: messageEffectId, ); } @@ -689,6 +719,7 @@ class Context { ReplyParameters? replyParameters, ReplyMarkup? replyMarkup, String? businessConnectionId, + String? messageEffectId, }) async { _verifyInfo([_chatId], APIMethod.sendGame); return api.sendGame( @@ -700,6 +731,7 @@ class Context { replyParameters: replyParameters, replyMarkup: replyMarkup, businessConnectionId: businessConnectionId, + messageEffectId: messageEffectId, ); } @@ -722,6 +754,8 @@ class Context { ReplyParameters? replyParameters, ReplyMarkup? replyMarkup, String? businessConnectionId, + String? messageEffectId, + bool? showCaptionAboveMedia, }) async { _verifyInfo([_chatId], APIMethod.sendAnimation); return api.sendAnimation( @@ -741,6 +775,8 @@ class Context { replyParameters: replyParameters, replyMarkup: replyMarkup, businessConnectionId: businessConnectionId, + messageEffectId: messageEffectId, + showCaptionAboveMedia: showCaptionAboveMedia, ); } @@ -755,6 +791,7 @@ class Context { ReplyParameters? replyParameters, InlineKeyboardMarkup? replyMarkup, String? businessConnectionId, + String? messageEffectId, }) async { _verifyInfo([_chatId], APIMethod.sendSticker); return api.sendSticker( @@ -766,6 +803,7 @@ class Context { replyParameters: replyParameters, replyMarkup: replyMarkup, businessConnectionId: businessConnectionId, + messageEffectId: messageEffectId, ); } @@ -1133,6 +1171,7 @@ class Context { bool? protectContent, ReplyMarkup? replyMarkup, ReplyParameters? replyParameters, + bool? showCaptionAboveMedia, }) async { _verifyInfo([_chatId, _msgId], APIMethod.copyMessage); return api.copyMessage( @@ -1147,6 +1186,7 @@ class Context { protectContent: protectContent, replyMarkup: replyMarkup, replyParameters: replyParameters, + showCaptionAboveMedia: showCaptionAboveMedia, ); } @@ -1681,6 +1721,7 @@ class Context { ParseMode? parseMode, List? captionEntities, InlineKeyboardMarkup? replyMarkup, + bool? showCaptionAboveMedia, }) async { if (_isInline()) { await api.editInlineMessageCaption( @@ -1689,6 +1730,7 @@ class Context { parseMode: parseMode, captionEntities: captionEntities, replyMarkup: replyMarkup, + showCaptionAboveMedia: showCaptionAboveMedia, ); } else { _verifyInfo([_chatId, _msgId], APIMethod.editMessageCaption); @@ -1699,6 +1741,7 @@ class Context { parseMode: parseMode, captionEntities: captionEntities, replyMarkup: replyMarkup, + showCaptionAboveMedia: showCaptionAboveMedia, ); } return true; @@ -1789,7 +1832,7 @@ class Context { required String title, required String description, required String payload, - required String providerToken, + String? providerToken, required String currency, required List prices, int? messageThreadId, @@ -1812,6 +1855,7 @@ class Context { bool? protectContent, InlineKeyboardMarkup? replyMarkup, ReplyParameters? replyParameters, + String? messageEffectId, }) async { _verifyInfo([_chatId], APIMethod.sendInvoice); return api.sendInvoice( @@ -1842,6 +1886,7 @@ class Context { protectContent: protectContent, replyMarkup: replyMarkup, replyParameters: replyParameters, + messageEffectId: messageEffectId, ); } @@ -1850,7 +1895,7 @@ class Context { required String title, required String description, required String payload, - required String providerToken, + String? providerToken, required String currency, required List prices, int? maxTipAmount = 0, diff --git a/lib/src/televerse/raw_api.dart b/lib/src/televerse/raw_api.dart index 74f97799..b7eb59c4 100644 --- a/lib/src/televerse/raw_api.dart +++ b/lib/src/televerse/raw_api.dart @@ -365,6 +365,7 @@ class RawAPI { bool? protectContent, ReplyMarkup? replyMarkup, ReplyParameters? replyParameters, + bool? showCaptionAboveMedia, }) async { Map params = { "chat_id": chatId.id, @@ -378,6 +379,7 @@ class RawAPI { "protect_content": protectContent, "reply_markup": replyMarkup?.toJson(), "reply_parameters": replyParameters?.toJson(), + "show_caption_above_media": showCaptionAboveMedia, }; Uri uri = _buildUri(APIMethod.copyMessage); @@ -2348,6 +2350,7 @@ class RawAPI { ParseMode? parseMode, List? captionEntities, InlineKeyboardMarkup? replyMarkup, + bool? showCaptionAboveMedia, }) async { Map params = { "inline_message_id": inlineMessageId, @@ -2355,6 +2358,7 @@ class RawAPI { "parse_mode": parseMode?.value, "caption_entities": captionEntities?.map((e) => e.toJson()).toList(), "reply_markup": replyMarkup?.toJson(), + "show_caption_above_media": showCaptionAboveMedia, }; bool response = await _httpClient.postURI( _buildUri(APIMethod.editMessageCaption),