mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2026-06-21 10:45:05 +00:00
Compare commits
17 Commits
c9be5041b8
...
31.1.0
| Author | SHA1 | Date | |
|---|---|---|---|
| 9f9d890831 | |||
| da662603b0 | |||
| 2dd91f47d7 | |||
| 8eb8e5ee1f | |||
| b533bab95f | |||
| 4f97327d29 | |||
| b17d7a868a | |||
| df695ceadb | |||
| ac511d0aed | |||
| 65cd359002 | |||
| 8d7005be80 | |||
| a20368ee51 | |||
| 744149a674 | |||
| 410183e315 | |||
| 9776a2474a | |||
| aebc571307 | |||
| 26c11d9d6b |
75
CHANGELOG.md
75
CHANGELOG.md
@@ -1,14 +1,87 @@
|
|||||||
# TelegramBotAPI changelog
|
# TelegramBotAPI changelog
|
||||||
|
|
||||||
|
## 31.1.0
|
||||||
|
|
||||||
|
**THIS UPDATE CONTAINS ADDING SUPPORT OF [Telegram Bots API 9.5](https://core.telegram.org/bots/api-changelog#march-1-2026)**
|
||||||
|
|
||||||
|
* `Core`:
|
||||||
|
* Added `UserTag` value class and `senderTag` field to messages
|
||||||
|
* Added `SetChatMemberTag` request and `UserTag` support in `PromoteChatMember` and `ChatPermissions`
|
||||||
|
* Added `DateTimeTextSource` for `tg://time` links support
|
||||||
|
* Added `DateTimeFormatPart` and `TgDateTimeFormatBuilder` for building date-time format strings
|
||||||
|
* Added `UnitFromBooleanSerializer`
|
||||||
|
* `API`:
|
||||||
|
* Added `setChatMemberTag` extensions
|
||||||
|
* `Utils`:
|
||||||
|
* Added `dateTime` and `dateTimeln` extensions to `EntitiesBuilder`
|
||||||
|
* Added `dateTimeMarkdown`, `dateTimeMarkdownV2`, and `dateTimeHTML` string formatting extensions
|
||||||
|
* Regenerated class casts extensions
|
||||||
|
* `WebApps`:
|
||||||
|
* Added `iconCustomEmojiId` support to `BottomButton` and `BottomButtonParams`
|
||||||
|
|
||||||
|
## 31.0.1
|
||||||
|
|
||||||
|
* `Core`:
|
||||||
|
* In `StarTransaction` property `nanostarAmount` become nullable
|
||||||
|
|
||||||
## 31.0.0
|
## 31.0.0
|
||||||
|
|
||||||
|
**THIS UPDATE CONTAINS ADDING SUPPORT OF [Telegram Bots API 9.3](https://core.telegram.org/bots/api-changelog#december-31-2025)**
|
||||||
|
|
||||||
|
**THIS UPDATE CONTAINS ADDING SUPPORT OF [Telegram Bots API 9.4](https://core.telegram.org/bots/api-changelog#february-9-2026)**
|
||||||
|
|
||||||
|
**THIS UPDATE CONTAINS BREAKING CHANGES**
|
||||||
|
|
||||||
|
* `Version`:
|
||||||
|
* `MicroUtils`: `0.26.8` -> `0.26.9`
|
||||||
* `Core`:
|
* `Core`:
|
||||||
* **THIS IS BREAKING CHANGE** All media files with sizes changed type of `fileSize` field from `Long` to `FileSize` (value class)
|
* **THIS IS BREAKING CHANGE** All media files with sizes changed type of `fileSize` field from `Long` to `FileSize` (value class)
|
||||||
* **THIS IS BREAKING CHANGE** Class `GiftSentOrReceived` have been renamed to `GiftSentOrReceivedEvent` to clarify naming
|
* **THIS IS BREAKING CHANGE** Class `GiftSentOrReceived` have been renamed to `GiftSentOrReceivedEvent` to clarify naming
|
||||||
|
* **THIS IS BREAKING CHANGE** New interface `OwnedGift` have been created
|
||||||
|
* **THIS IS BREAKING CHANGE** `OwnedGifts` have changed its generic type to `OwnedGift`
|
||||||
* **THIS IS BREAKING CHANGE** For `CheclistTask` have been made several changes:
|
* **THIS IS BREAKING CHANGE** For `CheclistTask` have been made several changes:
|
||||||
* `ChecklistTask.Done` -> `ChecklistTask.Completed`
|
* `ChecklistTask.Done` -> `ChecklistTask.Completed`
|
||||||
* `ChecklistTask.Undone` -> `ChecklistTask.Uncompleted`
|
* `ChecklistTask.Undone` -> `ChecklistTask.Uncompleted`
|
||||||
* Added several inheritors of `ChecklistTask.Completed` - for completed by chat, by user or just completed tasks
|
* Added several inheritors of `ChecklistTask.Completed` - for completed by chat, by user or just completed tasks
|
||||||
|
* **THIS IS BREAKING CHANGE** `PrivateChat.id` type changed from `UserId` to `IdChatIdentifier`
|
||||||
|
* **THIS IS BREAKING CHANGE** `ForumChat` no longer extends `SupergroupChat`; new `SupergroupForumChat` interface created for supergroup forums
|
||||||
|
* **THIS IS BREAKING CHANGE** Added `PrivateForumChat` and `PrivateUserChat` interfaces to support private forums
|
||||||
|
* Added support of private forums (`ExtendedPrivateForumChatImpl`, `PrivateForumContentMessage`, `PrivateForumEventMessage`)
|
||||||
|
* Added `ChatOwnerChanged` and `ChatOwnerLeft` chat events
|
||||||
|
* Added `SetMyProfilePhoto` and `RemoveMyProfilePhoto` requests
|
||||||
|
* Added `GetUserProfileAudios` request and `UserProfileAudios` type
|
||||||
|
* Added `GetChatGifts` and `GetUserGifts` requests
|
||||||
|
* Added `RepostStory` request
|
||||||
|
* Added `SendMessageDraft` request with `DraftId` and `DraftIdAllocator`
|
||||||
|
* Added `KeyboardButtonStyle` support and `iconCustomEmojiId` field to keyboard buttons
|
||||||
|
* Added `style` and `iconCustomEmojiId` fields to `InlineKeyboardButton`
|
||||||
|
* Added `VideoCodec` and `VideoQuality` types
|
||||||
|
* Added `Rarity`, `GiftBackground`, `UniqueGiftName`, and `UniqueGiftColors` types for gifts
|
||||||
|
* Added new fields to `Gift.Regular`: `personalTotalCount`, `personalRemainingCount`, `isPremium`, `hasColors`, `background`, `uniqueGiftVariantCount`
|
||||||
|
* Added `isBurned` field support in `GiftSentOrReceivedEvent`
|
||||||
|
* Added `UserRating` type and `rating` field to `ExtendedPrivateChat`
|
||||||
|
* Added `Level` and `Rating` value classes
|
||||||
|
* Added `uniqueGiftColors` field to extended chats (channel, group, private)
|
||||||
|
* Added `paidMessageStarCount` field to `ExtendedGroupChat` and `ExtendedPrivateChat`
|
||||||
|
* Added `firstProfileAudio` field to `ExtendedPrivateChat`
|
||||||
|
* Added `purchased_paid_media` to updates list
|
||||||
|
* Added `effectId` support in `CopyMessage` and `ForwardMessage`
|
||||||
|
* Added `WithOptionalPaidMessageStarCount` interface
|
||||||
|
* Fixed serialization of `SimpleKeyboardButton`
|
||||||
|
* Fixed support of `paidMessageStarCount`
|
||||||
|
* `API`:
|
||||||
|
* Added extensions for `SetMyProfilePhoto`, `RemoveMyProfilePhoto`, `GetUserProfileAudios`
|
||||||
|
* Added extensions for `GetChatGifts` and `GetUserGifts`
|
||||||
|
* Added extensions for `RepostStory`
|
||||||
|
* Added extensions for `SendMessageDraft`
|
||||||
|
* Added `effectId` parameter to `copyMessage` and `forwardMessage` extensions
|
||||||
|
* Added `GetBusinessAccountGifts` extensions improvements
|
||||||
|
* `BehaviourBuilder`:
|
||||||
|
* Updated event triggers for new chat events (`ChatOwnerChanged`, `ChatOwnerLeft`, private forum events)
|
||||||
|
* Updated expectations for new event types
|
||||||
|
* `Utils`:
|
||||||
|
* Regenerated class casts extensions
|
||||||
|
* Updated `InlineKeyboardBuilder` and `ReplyKeyboardBuilder` with `style` and `iconCustomEmojiId` support
|
||||||
|
|
||||||
## 30.0.2
|
## 30.0.2
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# TelegramBotAPI [](https://central.sonatype.com/artifact/dev.inmo/tgbotapi) [](https://core.telegram.org/bots/api-changelog#august-15-2025)
|
# TelegramBotAPI [](https://central.sonatype.com/artifact/dev.inmo/tgbotapi) [](https://core.telegram.org/bots/api-changelog#march-1-2026)
|
||||||
|
|
||||||
| Docs | [](https://tgbotapi.inmo.dev/index.html) [](https://docs.inmo.dev/tgbotapi/index.html) |
|
| Docs | [](https://tgbotapi.inmo.dev/index.html) [](https://docs.inmo.dev/tgbotapi/index.html) |
|
||||||
|:----------------------:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
|
|:----------------------:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
|
||||||
|
|||||||
@@ -6,4 +6,4 @@ kotlin.incremental=true
|
|||||||
kotlin.incremental.js=true
|
kotlin.incremental.js=true
|
||||||
|
|
||||||
library_group=dev.inmo
|
library_group=dev.inmo
|
||||||
library_version=31.0.0
|
library_version=31.1.0
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ github-release-plugin = "2.5.2"
|
|||||||
dokka = "2.0.0"
|
dokka = "2.0.0"
|
||||||
|
|
||||||
validator = "0.18.1"
|
validator = "0.18.1"
|
||||||
nmcp = "1.2.0"
|
nmcp = "1.4.4"
|
||||||
|
|
||||||
[libraries]
|
[libraries]
|
||||||
|
|
||||||
|
|||||||
@@ -707,25 +707,25 @@ public final class dev/inmo/tgbotapi/extensions/api/chat/members/PromoteChannelA
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final class dev/inmo/tgbotapi/extensions/api/chat/members/PromoteChatAdministratorKt {
|
public final class dev/inmo/tgbotapi/extensions/api/chat/members/PromoteChatAdministratorKt {
|
||||||
public static final fun promoteChatAdministrator (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/ChatIdentifier;Ldev/inmo/tgbotapi/types/IdChatIdentifier;Ldev/inmo/tgbotapi/types/TelegramDate;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
public static final fun promoteChatAdministrator (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/ChatIdentifier;Ldev/inmo/tgbotapi/types/IdChatIdentifier;Ldev/inmo/tgbotapi/types/TelegramDate;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||||
public static final fun promoteChatAdministrator (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/IdChatIdentifier;Ldev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/TelegramDate;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
public static final fun promoteChatAdministrator (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/IdChatIdentifier;Ldev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/TelegramDate;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||||
public static final fun promoteChatAdministrator (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/PublicChat;Ldev/inmo/tgbotapi/types/IdChatIdentifier;Ldev/inmo/tgbotapi/types/TelegramDate;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
public static final fun promoteChatAdministrator (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/PublicChat;Ldev/inmo/tgbotapi/types/IdChatIdentifier;Ldev/inmo/tgbotapi/types/TelegramDate;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||||
public static final fun promoteChatAdministrator (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/PublicChat;Ldev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/TelegramDate;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
public static final fun promoteChatAdministrator (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/PublicChat;Ldev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/TelegramDate;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||||
public static synthetic fun promoteChatAdministrator$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/ChatIdentifier;Ldev/inmo/tgbotapi/types/IdChatIdentifier;Ldev/inmo/tgbotapi/types/TelegramDate;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
public static synthetic fun promoteChatAdministrator$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/ChatIdentifier;Ldev/inmo/tgbotapi/types/IdChatIdentifier;Ldev/inmo/tgbotapi/types/TelegramDate;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||||
public static synthetic fun promoteChatAdministrator$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/IdChatIdentifier;Ldev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/TelegramDate;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
public static synthetic fun promoteChatAdministrator$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/IdChatIdentifier;Ldev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/TelegramDate;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||||
public static synthetic fun promoteChatAdministrator$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/PublicChat;Ldev/inmo/tgbotapi/types/IdChatIdentifier;Ldev/inmo/tgbotapi/types/TelegramDate;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
public static synthetic fun promoteChatAdministrator$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/PublicChat;Ldev/inmo/tgbotapi/types/IdChatIdentifier;Ldev/inmo/tgbotapi/types/TelegramDate;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||||
public static synthetic fun promoteChatAdministrator$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/PublicChat;Ldev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/TelegramDate;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
public static synthetic fun promoteChatAdministrator$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/PublicChat;Ldev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/TelegramDate;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final class dev/inmo/tgbotapi/extensions/api/chat/members/PromoteChatMemberKt {
|
public final class dev/inmo/tgbotapi/extensions/api/chat/members/PromoteChatMemberKt {
|
||||||
public static final fun promoteChatMember (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/ChatIdentifier;Ldev/inmo/tgbotapi/types/IdChatIdentifier;Ldev/inmo/tgbotapi/types/TelegramDate;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
public static final fun promoteChatMember (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/ChatIdentifier;Ldev/inmo/tgbotapi/types/IdChatIdentifier;Ldev/inmo/tgbotapi/types/TelegramDate;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||||
public static final fun promoteChatMember (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/IdChatIdentifier;Ldev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/TelegramDate;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
public static final fun promoteChatMember (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/IdChatIdentifier;Ldev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/TelegramDate;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||||
public static final fun promoteChatMember (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/PublicChat;Ldev/inmo/tgbotapi/types/IdChatIdentifier;Ldev/inmo/tgbotapi/types/TelegramDate;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
public static final fun promoteChatMember (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/PublicChat;Ldev/inmo/tgbotapi/types/IdChatIdentifier;Ldev/inmo/tgbotapi/types/TelegramDate;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||||
public static final fun promoteChatMember (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/PublicChat;Ldev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/TelegramDate;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
public static final fun promoteChatMember (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/PublicChat;Ldev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/TelegramDate;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||||
public static synthetic fun promoteChatMember$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/ChatIdentifier;Ldev/inmo/tgbotapi/types/IdChatIdentifier;Ldev/inmo/tgbotapi/types/TelegramDate;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
public static synthetic fun promoteChatMember$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/ChatIdentifier;Ldev/inmo/tgbotapi/types/IdChatIdentifier;Ldev/inmo/tgbotapi/types/TelegramDate;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||||
public static synthetic fun promoteChatMember$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/IdChatIdentifier;Ldev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/TelegramDate;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
public static synthetic fun promoteChatMember$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/IdChatIdentifier;Ldev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/TelegramDate;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||||
public static synthetic fun promoteChatMember$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/PublicChat;Ldev/inmo/tgbotapi/types/IdChatIdentifier;Ldev/inmo/tgbotapi/types/TelegramDate;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
public static synthetic fun promoteChatMember$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/PublicChat;Ldev/inmo/tgbotapi/types/IdChatIdentifier;Ldev/inmo/tgbotapi/types/TelegramDate;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||||
public static synthetic fun promoteChatMember$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/PublicChat;Ldev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/TelegramDate;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
public static synthetic fun promoteChatMember$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/PublicChat;Ldev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/TelegramDate;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final class dev/inmo/tgbotapi/extensions/api/chat/members/PromoteSupergroupAdministratorKt {
|
public final class dev/inmo/tgbotapi/extensions/api/chat/members/PromoteSupergroupAdministratorKt {
|
||||||
@@ -757,6 +757,17 @@ public final class dev/inmo/tgbotapi/extensions/api/chat/members/SetChatAdminist
|
|||||||
public static final fun setChatAdministratorCustomTitle (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/PublicChat;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
public static final fun setChatAdministratorCustomTitle (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/PublicChat;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final class dev/inmo/tgbotapi/extensions/api/chat/members/SetChatMemberTagKt {
|
||||||
|
public static final fun setChatMemberTag-IPSxYbI (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/ChatIdentifier;Ldev/inmo/tgbotapi/types/IdChatIdentifier;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||||
|
public static final fun setChatMemberTag-IPSxYbI (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/ChatIdentifier;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||||
|
public static final fun setChatMemberTag-IPSxYbI (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/PublicChat;Ldev/inmo/tgbotapi/types/IdChatIdentifier;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||||
|
public static final fun setChatMemberTag-IPSxYbI (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/PublicChat;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||||
|
public static synthetic fun setChatMemberTag-IPSxYbI$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/ChatIdentifier;Ldev/inmo/tgbotapi/types/IdChatIdentifier;Ljava/lang/String;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||||
|
public static synthetic fun setChatMemberTag-IPSxYbI$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/ChatIdentifier;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/String;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||||
|
public static synthetic fun setChatMemberTag-IPSxYbI$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/PublicChat;Ldev/inmo/tgbotapi/types/IdChatIdentifier;Ljava/lang/String;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||||
|
public static synthetic fun setChatMemberTag-IPSxYbI$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/PublicChat;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/String;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||||
|
}
|
||||||
|
|
||||||
public final class dev/inmo/tgbotapi/extensions/api/chat/members/UnbanChatMemberKt {
|
public final class dev/inmo/tgbotapi/extensions/api/chat/members/UnbanChatMemberKt {
|
||||||
public static final fun unbanChatMember (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/ChatIdentifier;Ldev/inmo/tgbotapi/types/IdChatIdentifier;Ljava/lang/Boolean;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
public static final fun unbanChatMember (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/ChatIdentifier;Ldev/inmo/tgbotapi/types/IdChatIdentifier;Ljava/lang/Boolean;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||||
public static final fun unbanChatMember (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/IdChatIdentifier;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/Boolean;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
public static final fun unbanChatMember (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/IdChatIdentifier;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/Boolean;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import dev.inmo.tgbotapi.requests.business_connection.GetBusinessAccountGifts
|
|||||||
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
|
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
|
||||||
import dev.inmo.tgbotapi.types.OwnedGifts
|
import dev.inmo.tgbotapi.types.OwnedGifts
|
||||||
import dev.inmo.tgbotapi.types.gifts.GiftSentOrReceivedEvent
|
import dev.inmo.tgbotapi.types.gifts.GiftSentOrReceivedEvent
|
||||||
|
import dev.inmo.tgbotapi.types.gifts.OwnedGift
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.flow.flow
|
import kotlinx.coroutines.flow.flow
|
||||||
import kotlin.runCatching
|
import kotlin.runCatching
|
||||||
@@ -21,7 +22,7 @@ public suspend fun TelegramBot.getBusinessAccountGifts(
|
|||||||
sortByPrice: Boolean = false,
|
sortByPrice: Boolean = false,
|
||||||
offset: String? = null,
|
offset: String? = null,
|
||||||
limit: Int? = null
|
limit: Int? = null
|
||||||
): OwnedGifts<GiftSentOrReceivedEvent.ReceivedInBusinessAccount> = execute(
|
): OwnedGifts<OwnedGift.OwnedByBusinessAccount> = execute(
|
||||||
GetBusinessAccountGifts(
|
GetBusinessAccountGifts(
|
||||||
businessConnectionId,
|
businessConnectionId,
|
||||||
excludeUnsaved,
|
excludeUnsaved,
|
||||||
@@ -71,7 +72,7 @@ public fun TelegramBot.getBusinessAccountGiftsFlow(
|
|||||||
initialOffset: String? = null,
|
initialOffset: String? = null,
|
||||||
limit: Int? = null,
|
limit: Int? = null,
|
||||||
onErrorContinueChecker: suspend (Throwable?) -> Boolean = { false }
|
onErrorContinueChecker: suspend (Throwable?) -> Boolean = { false }
|
||||||
): Flow<OwnedGifts<GiftSentOrReceivedEvent.ReceivedInBusinessAccount>> = flow {
|
): Flow<OwnedGifts<OwnedGift.OwnedByBusinessAccount>> = flow {
|
||||||
var currentOffset = initialOffset
|
var currentOffset = initialOffset
|
||||||
do {
|
do {
|
||||||
val response = runCatching {
|
val response = runCatching {
|
||||||
|
|||||||
@@ -21,19 +21,21 @@ public suspend fun TelegramBot.promoteChatAdministrator(
|
|||||||
canPromoteMembers: Boolean? = null,
|
canPromoteMembers: Boolean? = null,
|
||||||
canManageVideoChats: Boolean? = null,
|
canManageVideoChats: Boolean? = null,
|
||||||
canManageChat: Boolean? = null,
|
canManageChat: Boolean? = null,
|
||||||
|
canManageTags: Boolean? = null,
|
||||||
): Boolean = execute(
|
): Boolean = execute(
|
||||||
PromoteChatMember(
|
PromoteChatMember(
|
||||||
chatId,
|
chatId = chatId,
|
||||||
userId,
|
userId = userId,
|
||||||
untilDate,
|
untilDate = untilDate,
|
||||||
isAnonymous,
|
isAnonymous = isAnonymous,
|
||||||
canChangeInfo,
|
canChangeInfo = canChangeInfo,
|
||||||
canDeleteMessages,
|
canDeleteMessages = canDeleteMessages,
|
||||||
canInviteUsers,
|
canInviteUsers = canInviteUsers,
|
||||||
canRestrictMembers,
|
canRestrictMembers = canRestrictMembers,
|
||||||
canPromoteMembers,
|
canPromoteMembers = canPromoteMembers,
|
||||||
canManageVideoChats,
|
canManageVideoChats = canManageVideoChats,
|
||||||
canManageChat
|
canManageChat = canManageChat,
|
||||||
|
canManageTags = canManageTags
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -49,18 +51,20 @@ public suspend fun TelegramBot.promoteChatAdministrator(
|
|||||||
canPromoteMembers: Boolean? = null,
|
canPromoteMembers: Boolean? = null,
|
||||||
canManageVideoChats: Boolean? = null,
|
canManageVideoChats: Boolean? = null,
|
||||||
canManageChat: Boolean? = null,
|
canManageChat: Boolean? = null,
|
||||||
|
canManageTags: Boolean? = null,
|
||||||
): Boolean = promoteChatAdministrator(
|
): Boolean = promoteChatAdministrator(
|
||||||
chat.id,
|
chatId = chat.id,
|
||||||
userId,
|
userId = userId,
|
||||||
untilDate,
|
untilDate = untilDate,
|
||||||
isAnonymous,
|
isAnonymous = isAnonymous,
|
||||||
canChangeInfo,
|
canChangeInfo = canChangeInfo,
|
||||||
canDeleteMessages,
|
canDeleteMessages = canDeleteMessages,
|
||||||
canInviteUsers,
|
canInviteUsers = canInviteUsers,
|
||||||
canRestrictMembers,
|
canRestrictMembers = canRestrictMembers,
|
||||||
canPromoteMembers,
|
canPromoteMembers = canPromoteMembers,
|
||||||
canManageVideoChats,
|
canManageVideoChats = canManageVideoChats,
|
||||||
canManageChat
|
canManageChat = canManageChat,
|
||||||
|
canManageTags = canManageTags
|
||||||
)
|
)
|
||||||
|
|
||||||
public suspend fun TelegramBot.promoteChatAdministrator(
|
public suspend fun TelegramBot.promoteChatAdministrator(
|
||||||
@@ -75,18 +79,20 @@ public suspend fun TelegramBot.promoteChatAdministrator(
|
|||||||
canPromoteMembers: Boolean? = null,
|
canPromoteMembers: Boolean? = null,
|
||||||
canManageVideoChats: Boolean? = null,
|
canManageVideoChats: Boolean? = null,
|
||||||
canManageChat: Boolean? = null,
|
canManageChat: Boolean? = null,
|
||||||
|
canManageTags: Boolean? = null,
|
||||||
): Boolean = promoteChatAdministrator(
|
): Boolean = promoteChatAdministrator(
|
||||||
chatId,
|
chatId = chatId,
|
||||||
user.id,
|
userId = user.id,
|
||||||
untilDate,
|
untilDate = untilDate,
|
||||||
isAnonymous,
|
isAnonymous = isAnonymous,
|
||||||
canChangeInfo,
|
canChangeInfo = canChangeInfo,
|
||||||
canDeleteMessages,
|
canDeleteMessages = canDeleteMessages,
|
||||||
canInviteUsers,
|
canInviteUsers = canInviteUsers,
|
||||||
canRestrictMembers,
|
canRestrictMembers = canRestrictMembers,
|
||||||
canPromoteMembers,
|
canPromoteMembers = canPromoteMembers,
|
||||||
canManageVideoChats,
|
canManageVideoChats = canManageVideoChats,
|
||||||
canManageChat
|
canManageChat = canManageChat,
|
||||||
|
canManageTags = canManageTags
|
||||||
)
|
)
|
||||||
|
|
||||||
public suspend fun TelegramBot.promoteChatAdministrator(
|
public suspend fun TelegramBot.promoteChatAdministrator(
|
||||||
@@ -101,16 +107,18 @@ public suspend fun TelegramBot.promoteChatAdministrator(
|
|||||||
canPromoteMembers: Boolean? = null,
|
canPromoteMembers: Boolean? = null,
|
||||||
canManageVideoChats: Boolean? = null,
|
canManageVideoChats: Boolean? = null,
|
||||||
canManageChat: Boolean? = null,
|
canManageChat: Boolean? = null,
|
||||||
|
canManageTags: Boolean? = null,
|
||||||
): Boolean = promoteChatAdministrator(
|
): Boolean = promoteChatAdministrator(
|
||||||
chat.id,
|
chatId = chat.id,
|
||||||
user.id,
|
userId = user.id,
|
||||||
untilDate,
|
untilDate = untilDate,
|
||||||
isAnonymous,
|
isAnonymous = isAnonymous,
|
||||||
canChangeInfo,
|
canChangeInfo = canChangeInfo,
|
||||||
canDeleteMessages,
|
canDeleteMessages = canDeleteMessages,
|
||||||
canInviteUsers,
|
canInviteUsers = canInviteUsers,
|
||||||
canRestrictMembers,
|
canRestrictMembers = canRestrictMembers,
|
||||||
canPromoteMembers,
|
canPromoteMembers = canPromoteMembers,
|
||||||
canManageVideoChats,
|
canManageVideoChats = canManageVideoChats,
|
||||||
canManageChat
|
canManageChat = canManageChat,
|
||||||
|
canManageTags = canManageTags
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -27,7 +27,8 @@ public suspend fun TelegramBot.promoteChatMember(
|
|||||||
canPostStories: Boolean? = null,
|
canPostStories: Boolean? = null,
|
||||||
canEditStories: Boolean? = null,
|
canEditStories: Boolean? = null,
|
||||||
canDeleteStories: Boolean? = null,
|
canDeleteStories: Boolean? = null,
|
||||||
canManageDirectMessages: Boolean? = null
|
canManageDirectMessages: Boolean? = null,
|
||||||
|
canManageTags: Boolean? = null
|
||||||
): Boolean = execute(
|
): Boolean = execute(
|
||||||
PromoteChatMember(
|
PromoteChatMember(
|
||||||
chatId = chatId,
|
chatId = chatId,
|
||||||
@@ -49,6 +50,7 @@ public suspend fun TelegramBot.promoteChatMember(
|
|||||||
canEditStories = canEditStories,
|
canEditStories = canEditStories,
|
||||||
canDeleteStories = canDeleteStories,
|
canDeleteStories = canDeleteStories,
|
||||||
canManageDirectMessages = canManageDirectMessages,
|
canManageDirectMessages = canManageDirectMessages,
|
||||||
|
canManageTags = canManageTags,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -72,7 +74,8 @@ public suspend fun TelegramBot.promoteChatMember(
|
|||||||
canPostStories: Boolean? = null,
|
canPostStories: Boolean? = null,
|
||||||
canEditStories: Boolean? = null,
|
canEditStories: Boolean? = null,
|
||||||
canDeleteStories: Boolean? = null,
|
canDeleteStories: Boolean? = null,
|
||||||
canManageDirectMessages: Boolean? = null
|
canManageDirectMessages: Boolean? = null,
|
||||||
|
canManageTags: Boolean? = null
|
||||||
): Boolean = promoteChatMember(
|
): Boolean = promoteChatMember(
|
||||||
chat.id,
|
chat.id,
|
||||||
userId,
|
userId,
|
||||||
@@ -93,6 +96,7 @@ public suspend fun TelegramBot.promoteChatMember(
|
|||||||
canEditStories = canEditStories,
|
canEditStories = canEditStories,
|
||||||
canDeleteStories = canDeleteStories,
|
canDeleteStories = canDeleteStories,
|
||||||
canManageDirectMessages = canManageDirectMessages,
|
canManageDirectMessages = canManageDirectMessages,
|
||||||
|
canManageTags = canManageTags,
|
||||||
)
|
)
|
||||||
|
|
||||||
@Warning("This method is too common. Use it with caution")
|
@Warning("This method is too common. Use it with caution")
|
||||||
@@ -115,7 +119,8 @@ public suspend fun TelegramBot.promoteChatMember(
|
|||||||
canPostStories: Boolean? = null,
|
canPostStories: Boolean? = null,
|
||||||
canEditStories: Boolean? = null,
|
canEditStories: Boolean? = null,
|
||||||
canDeleteStories: Boolean? = null,
|
canDeleteStories: Boolean? = null,
|
||||||
canManageDirectMessages: Boolean? = null
|
canManageDirectMessages: Boolean? = null,
|
||||||
|
canManageTags: Boolean? = null
|
||||||
): Boolean = promoteChatMember(
|
): Boolean = promoteChatMember(
|
||||||
chatId,
|
chatId,
|
||||||
user.id,
|
user.id,
|
||||||
@@ -136,6 +141,7 @@ public suspend fun TelegramBot.promoteChatMember(
|
|||||||
canEditStories = canEditStories,
|
canEditStories = canEditStories,
|
||||||
canDeleteStories = canDeleteStories,
|
canDeleteStories = canDeleteStories,
|
||||||
canManageDirectMessages = canManageDirectMessages,
|
canManageDirectMessages = canManageDirectMessages,
|
||||||
|
canManageTags = canManageTags,
|
||||||
)
|
)
|
||||||
|
|
||||||
@Warning("This method is too common. Use it with caution")
|
@Warning("This method is too common. Use it with caution")
|
||||||
@@ -158,7 +164,8 @@ public suspend fun TelegramBot.promoteChatMember(
|
|||||||
canPostStories: Boolean? = null,
|
canPostStories: Boolean? = null,
|
||||||
canEditStories: Boolean? = null,
|
canEditStories: Boolean? = null,
|
||||||
canDeleteStories: Boolean? = null,
|
canDeleteStories: Boolean? = null,
|
||||||
canManageDirectMessages: Boolean? = null
|
canManageDirectMessages: Boolean? = null,
|
||||||
|
canManageTags: Boolean? = null
|
||||||
): Boolean = promoteChatMember(
|
): Boolean = promoteChatMember(
|
||||||
chat.id,
|
chat.id,
|
||||||
user.id,
|
user.id,
|
||||||
@@ -179,4 +186,5 @@ public suspend fun TelegramBot.promoteChatMember(
|
|||||||
canEditStories = canEditStories,
|
canEditStories = canEditStories,
|
||||||
canDeleteStories = canDeleteStories,
|
canDeleteStories = canDeleteStories,
|
||||||
canManageDirectMessages = canManageDirectMessages,
|
canManageDirectMessages = canManageDirectMessages,
|
||||||
|
canManageTags = canManageTags,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.api.chat.members
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
|
import dev.inmo.tgbotapi.requests.chat.members.SetChatMemberTag
|
||||||
|
import dev.inmo.tgbotapi.types.*
|
||||||
|
import dev.inmo.tgbotapi.types.chat.PublicChat
|
||||||
|
import dev.inmo.tgbotapi.types.chat.User
|
||||||
|
|
||||||
|
public suspend fun TelegramBot.setChatMemberTag(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
userId: UserId,
|
||||||
|
tag: UserTag? = null
|
||||||
|
): Unit = execute(SetChatMemberTag(chatId, userId, tag))
|
||||||
|
|
||||||
|
public suspend fun TelegramBot.setChatMemberTag(
|
||||||
|
chat: PublicChat,
|
||||||
|
userId: UserId,
|
||||||
|
tag: UserTag? = null
|
||||||
|
): Unit = setChatMemberTag(chat.id, userId, tag)
|
||||||
|
|
||||||
|
public suspend fun TelegramBot.setChatMemberTag(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
user: User,
|
||||||
|
tag: UserTag? = null
|
||||||
|
): Unit = setChatMemberTag(chatId, user.id, tag)
|
||||||
|
|
||||||
|
public suspend fun TelegramBot.setChatMemberTag(
|
||||||
|
chat: PublicChat,
|
||||||
|
user: User,
|
||||||
|
tag: UserTag? = null
|
||||||
|
): Unit = setChatMemberTag(chat.id, user.id, tag)
|
||||||
@@ -5,6 +5,7 @@ import dev.inmo.tgbotapi.requests.gifts.GetChatGifts
|
|||||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||||
import dev.inmo.tgbotapi.types.OwnedGifts
|
import dev.inmo.tgbotapi.types.OwnedGifts
|
||||||
import dev.inmo.tgbotapi.types.gifts.GiftSentOrReceivedEvent
|
import dev.inmo.tgbotapi.types.gifts.GiftSentOrReceivedEvent
|
||||||
|
import dev.inmo.tgbotapi.types.gifts.OwnedGift
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.flow.flow
|
import kotlinx.coroutines.flow.flow
|
||||||
|
|
||||||
@@ -20,7 +21,7 @@ public suspend fun TelegramBot.getChatGifts(
|
|||||||
sortByPrice: Boolean = false,
|
sortByPrice: Boolean = false,
|
||||||
offset: String? = null,
|
offset: String? = null,
|
||||||
limit: Int? = null
|
limit: Int? = null
|
||||||
): OwnedGifts<GiftSentOrReceivedEvent> = execute(
|
): OwnedGifts<OwnedGift.Common> = execute(
|
||||||
GetChatGifts(
|
GetChatGifts(
|
||||||
chatId,
|
chatId,
|
||||||
excludeUnsaved,
|
excludeUnsaved,
|
||||||
@@ -49,7 +50,7 @@ public fun TelegramBot.getChatGiftsFlow(
|
|||||||
initialOffset: String? = null,
|
initialOffset: String? = null,
|
||||||
limit: Int? = null,
|
limit: Int? = null,
|
||||||
onErrorContinueChecker: suspend (Throwable?) -> Boolean = { false }
|
onErrorContinueChecker: suspend (Throwable?) -> Boolean = { false }
|
||||||
): Flow<OwnedGifts<GiftSentOrReceivedEvent>> = flow {
|
): Flow<OwnedGifts<OwnedGift.Common>> = flow {
|
||||||
var currentOffset = initialOffset
|
var currentOffset = initialOffset
|
||||||
do {
|
do {
|
||||||
val response = runCatching {
|
val response = runCatching {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import dev.inmo.tgbotapi.requests.gifts.GetUserGifts
|
|||||||
import dev.inmo.tgbotapi.types.OwnedGifts
|
import dev.inmo.tgbotapi.types.OwnedGifts
|
||||||
import dev.inmo.tgbotapi.types.UserId
|
import dev.inmo.tgbotapi.types.UserId
|
||||||
import dev.inmo.tgbotapi.types.gifts.GiftSentOrReceivedEvent
|
import dev.inmo.tgbotapi.types.gifts.GiftSentOrReceivedEvent
|
||||||
|
import dev.inmo.tgbotapi.types.gifts.OwnedGift
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.flow.flow
|
import kotlinx.coroutines.flow.flow
|
||||||
|
|
||||||
@@ -18,7 +19,7 @@ public suspend fun TelegramBot.getUserGifts(
|
|||||||
sortByPrice: Boolean = false,
|
sortByPrice: Boolean = false,
|
||||||
offset: String? = null,
|
offset: String? = null,
|
||||||
limit: Int? = null
|
limit: Int? = null
|
||||||
): OwnedGifts<GiftSentOrReceivedEvent> = execute(
|
): OwnedGifts<OwnedGift.Common> = execute(
|
||||||
GetUserGifts(
|
GetUserGifts(
|
||||||
userId,
|
userId,
|
||||||
excludeUnlimited,
|
excludeUnlimited,
|
||||||
@@ -43,7 +44,7 @@ public fun TelegramBot.getUserGiftsFlow(
|
|||||||
initialOffset: String? = null,
|
initialOffset: String? = null,
|
||||||
limit: Int? = null,
|
limit: Int? = null,
|
||||||
onErrorContinueChecker: suspend (Throwable?) -> Boolean = { false }
|
onErrorContinueChecker: suspend (Throwable?) -> Boolean = { false }
|
||||||
): Flow<OwnedGifts<GiftSentOrReceivedEvent>> = flow {
|
): Flow<OwnedGifts<OwnedGift.Common>> = flow {
|
||||||
var currentOffset = initialOffset
|
var currentOffset = initialOffset
|
||||||
do {
|
do {
|
||||||
val response = runCatching {
|
val response = runCatching {
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,7 @@
|
|||||||
|
package dev.inmo.tgbotapi.abstracts
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.types.UserTag
|
||||||
|
|
||||||
|
interface OptionallyTagged {
|
||||||
|
val tag: UserTag?
|
||||||
|
}
|
||||||
@@ -16,6 +16,7 @@ import io.ktor.client.request.*
|
|||||||
import io.ktor.client.statement.bodyAsText
|
import io.ktor.client.statement.bodyAsText
|
||||||
import io.ktor.http.ContentType
|
import io.ktor.http.ContentType
|
||||||
import io.ktor.http.content.*
|
import io.ktor.http.content.*
|
||||||
|
import kotlinx.serialization.builtins.serializer
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
import kotlin.collections.set
|
import kotlin.collections.set
|
||||||
|
|
||||||
|
|||||||
@@ -16,10 +16,12 @@ import dev.inmo.tgbotapi.types.sortByPriceField
|
|||||||
import dev.inmo.tgbotapi.types.offsetField
|
import dev.inmo.tgbotapi.types.offsetField
|
||||||
import dev.inmo.tgbotapi.types.limitField
|
import dev.inmo.tgbotapi.types.limitField
|
||||||
import dev.inmo.tgbotapi.types.gifts.GiftSentOrReceivedEvent
|
import dev.inmo.tgbotapi.types.gifts.GiftSentOrReceivedEvent
|
||||||
|
import dev.inmo.tgbotapi.types.gifts.OwnedGift
|
||||||
import kotlinx.serialization.DeserializationStrategy
|
import kotlinx.serialization.DeserializationStrategy
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import kotlinx.serialization.SerializationStrategy
|
import kotlinx.serialization.SerializationStrategy
|
||||||
|
import kotlinx.serialization.builtins.serializer
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class GetBusinessAccountGifts(
|
data class GetBusinessAccountGifts(
|
||||||
@@ -45,16 +47,16 @@ data class GetBusinessAccountGifts(
|
|||||||
val offset: String? = null,
|
val offset: String? = null,
|
||||||
@SerialName(limitField)
|
@SerialName(limitField)
|
||||||
val limit: Int? = null,
|
val limit: Int? = null,
|
||||||
) : BusinessRequest.Simple<OwnedGifts<GiftSentOrReceivedEvent.ReceivedInBusinessAccount>> {
|
) : BusinessRequest.Simple<OwnedGifts<OwnedGift.OwnedByBusinessAccount>> {
|
||||||
override fun method(): String = "getBusinessAccountGifts"
|
override fun method(): String = "getBusinessAccountGifts"
|
||||||
|
|
||||||
override val resultDeserializer: DeserializationStrategy<OwnedGifts<GiftSentOrReceivedEvent.ReceivedInBusinessAccount>>
|
override val resultDeserializer: DeserializationStrategy<OwnedGifts<OwnedGift.OwnedByBusinessAccount>>
|
||||||
get() = Companion.resultSerializer
|
get() = Companion.resultSerializer
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@Warning("This API can be changed without any warranties of backward compatibility")
|
@Warning("This API can be changed without any warranties of backward compatibility")
|
||||||
val resultSerializer = OwnedGifts.serializer(GiftSentOrReceivedEvent.ReceivedInBusinessAccount.serializer())
|
val resultSerializer = OwnedGifts.serializer(OwnedGift.OwnedByBusinessAccount.serializer())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -49,6 +49,8 @@ data class PromoteChatMember(
|
|||||||
private val canDeleteStories: Boolean? = null,
|
private val canDeleteStories: Boolean? = null,
|
||||||
@SerialName(canManageDirectMessagesField)
|
@SerialName(canManageDirectMessagesField)
|
||||||
private val canManageDirectMessages: Boolean? = null,
|
private val canManageDirectMessages: Boolean? = null,
|
||||||
|
@SerialName(canManageTagsField)
|
||||||
|
private val canManageTags: Boolean? = null,
|
||||||
) : ChatMemberRequest<Boolean>, UntilDate {
|
) : ChatMemberRequest<Boolean>, UntilDate {
|
||||||
override fun method(): String = "promoteChatMember"
|
override fun method(): String = "promoteChatMember"
|
||||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
@@ -69,6 +71,7 @@ fun PromoteChatMember(
|
|||||||
canPromoteMembers: Boolean? = null,
|
canPromoteMembers: Boolean? = null,
|
||||||
canManageVideoChats: Boolean? = null,
|
canManageVideoChats: Boolean? = null,
|
||||||
canManageChat: Boolean? = null,
|
canManageChat: Boolean? = null,
|
||||||
|
canManageTags: Boolean? = null,
|
||||||
) = PromoteChatMember(
|
) = PromoteChatMember(
|
||||||
chatId = chatId,
|
chatId = chatId,
|
||||||
userId = userId,
|
userId = userId,
|
||||||
@@ -84,6 +87,7 @@ fun PromoteChatMember(
|
|||||||
canPromoteMembers = canPromoteMembers,
|
canPromoteMembers = canPromoteMembers,
|
||||||
canManageVideoChats = canManageVideoChats,
|
canManageVideoChats = canManageVideoChats,
|
||||||
canManageChat = canManageChat,
|
canManageChat = canManageChat,
|
||||||
|
canManageTags = canManageTags,
|
||||||
canManageTopics = null,
|
canManageTopics = null,
|
||||||
canPostStories = null,
|
canPostStories = null,
|
||||||
canEditStories = null,
|
canEditStories = null,
|
||||||
@@ -144,6 +148,7 @@ fun PromoteSupergroupAdministrator(
|
|||||||
canManageVideoChats: Boolean? = null,
|
canManageVideoChats: Boolean? = null,
|
||||||
canManageChat: Boolean? = null,
|
canManageChat: Boolean? = null,
|
||||||
canManageTopics: Boolean? = null,
|
canManageTopics: Boolean? = null,
|
||||||
|
canManageTags: Boolean? = null,
|
||||||
) = PromoteChatMember(
|
) = PromoteChatMember(
|
||||||
chatId = chatId,
|
chatId = chatId,
|
||||||
userId = userId,
|
userId = userId,
|
||||||
@@ -160,6 +165,7 @@ fun PromoteSupergroupAdministrator(
|
|||||||
canManageVideoChats = canManageVideoChats,
|
canManageVideoChats = canManageVideoChats,
|
||||||
canManageChat = canManageChat,
|
canManageChat = canManageChat,
|
||||||
canManageTopics = canManageTopics,
|
canManageTopics = canManageTopics,
|
||||||
|
canManageTags = canManageTags,
|
||||||
canPostStories = null,
|
canPostStories = null,
|
||||||
canEditStories = null,
|
canEditStories = null,
|
||||||
canDeleteStories = null
|
canDeleteStories = null
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package dev.inmo.tgbotapi.requests.chat.members
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.requests.chat.abstracts.ChatMemberRequest
|
||||||
|
import dev.inmo.tgbotapi.types.*
|
||||||
|
import dev.inmo.tgbotapi.utils.serializers.UnitFromBooleanSerializer
|
||||||
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class SetChatMemberTag(
|
||||||
|
@SerialName(chatIdField)
|
||||||
|
override val chatId: ChatIdentifier,
|
||||||
|
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||||
|
@SerialName(userIdField)
|
||||||
|
override val userId: UserId,
|
||||||
|
@SerialName(tagField)
|
||||||
|
val tag: UserTag? = null
|
||||||
|
) : ChatMemberRequest<Unit> {
|
||||||
|
override fun method(): String = "setChatMemberTag"
|
||||||
|
override val resultDeserializer: DeserializationStrategy<Unit>
|
||||||
|
get() = UnitFromBooleanSerializer
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
|
}
|
||||||
@@ -15,6 +15,7 @@ import dev.inmo.tgbotapi.types.excludeFromBlockchainField
|
|||||||
import dev.inmo.tgbotapi.types.excludeUniqueField
|
import dev.inmo.tgbotapi.types.excludeUniqueField
|
||||||
import dev.inmo.tgbotapi.types.sortByPriceField
|
import dev.inmo.tgbotapi.types.sortByPriceField
|
||||||
import dev.inmo.tgbotapi.types.gifts.GiftSentOrReceivedEvent
|
import dev.inmo.tgbotapi.types.gifts.GiftSentOrReceivedEvent
|
||||||
|
import dev.inmo.tgbotapi.types.gifts.OwnedGift
|
||||||
import dev.inmo.tgbotapi.types.limitField
|
import dev.inmo.tgbotapi.types.limitField
|
||||||
import dev.inmo.tgbotapi.types.offsetField
|
import dev.inmo.tgbotapi.types.offsetField
|
||||||
import kotlinx.serialization.DeserializationStrategy
|
import kotlinx.serialization.DeserializationStrategy
|
||||||
@@ -46,16 +47,16 @@ data class GetChatGifts(
|
|||||||
val offset: String? = null,
|
val offset: String? = null,
|
||||||
@SerialName(limitField)
|
@SerialName(limitField)
|
||||||
val limit: Int? = null,
|
val limit: Int? = null,
|
||||||
) : SimpleRequest<OwnedGifts<GiftSentOrReceivedEvent>>, ChatRequest {
|
) : SimpleRequest<OwnedGifts<OwnedGift.Common>>, ChatRequest {
|
||||||
override fun method(): String = "getChatGifts"
|
override fun method(): String = "getChatGifts"
|
||||||
|
|
||||||
override val resultDeserializer: DeserializationStrategy<OwnedGifts<GiftSentOrReceivedEvent>>
|
override val resultDeserializer: DeserializationStrategy<OwnedGifts<OwnedGift.Common>>
|
||||||
get() = Companion.resultSerializer
|
get() = Companion.resultSerializer
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@Warning("This API can be changed without any warranties of backward compatibility")
|
@Warning("This API can be changed without any warranties of backward compatibility")
|
||||||
val resultSerializer = OwnedGifts.serializer(GiftSentOrReceivedEvent.serializer())
|
val resultSerializer = OwnedGifts.serializer(OwnedGift.Common.serializer())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import dev.inmo.tgbotapi.types.excludeFromBlockchainField
|
|||||||
import dev.inmo.tgbotapi.types.excludeUniqueField
|
import dev.inmo.tgbotapi.types.excludeUniqueField
|
||||||
import dev.inmo.tgbotapi.types.sortByPriceField
|
import dev.inmo.tgbotapi.types.sortByPriceField
|
||||||
import dev.inmo.tgbotapi.types.gifts.GiftSentOrReceivedEvent
|
import dev.inmo.tgbotapi.types.gifts.GiftSentOrReceivedEvent
|
||||||
|
import dev.inmo.tgbotapi.types.gifts.OwnedGift
|
||||||
import dev.inmo.tgbotapi.types.limitField
|
import dev.inmo.tgbotapi.types.limitField
|
||||||
import dev.inmo.tgbotapi.types.offsetField
|
import dev.inmo.tgbotapi.types.offsetField
|
||||||
import dev.inmo.tgbotapi.types.userIdField
|
import dev.inmo.tgbotapi.types.userIdField
|
||||||
@@ -40,16 +41,16 @@ data class GetUserGifts(
|
|||||||
val offset: String? = null,
|
val offset: String? = null,
|
||||||
@SerialName(limitField)
|
@SerialName(limitField)
|
||||||
val limit: Int? = null,
|
val limit: Int? = null,
|
||||||
) : SimpleRequest<OwnedGifts<GiftSentOrReceivedEvent>> {
|
) : SimpleRequest<OwnedGifts<OwnedGift.Common>> {
|
||||||
override fun method(): String = "getUserGifts"
|
override fun method(): String = "getUserGifts"
|
||||||
|
|
||||||
override val resultDeserializer: DeserializationStrategy<OwnedGifts<GiftSentOrReceivedEvent>>
|
override val resultDeserializer: DeserializationStrategy<OwnedGifts<OwnedGift.Common>>
|
||||||
get() = Companion.resultSerializer
|
get() = Companion.resultSerializer
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@Warning("This API can be changed without any warranties of backward compatibility")
|
@Warning("This API can be changed without any warranties of backward compatibility")
|
||||||
val resultSerializer = OwnedGifts.serializer(GiftSentOrReceivedEvent.serializer())
|
val resultSerializer = OwnedGifts.serializer(OwnedGift.Common.serializer())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ val livePeriodLimit = 60 .. LiveLocation.INDEFINITE_LIVE_PERIOD
|
|||||||
val inlineQueryAnswerResultsLimit = 0 .. 50
|
val inlineQueryAnswerResultsLimit = 0 .. 50
|
||||||
|
|
||||||
val customTitleLength = 0 .. 16
|
val customTitleLength = 0 .. 16
|
||||||
|
val memberTagLength = 0 .. 16
|
||||||
|
|
||||||
val dartsCubeAndBowlingDiceResultLimit = 1 .. 6
|
val dartsCubeAndBowlingDiceResultLimit = 1 .. 6
|
||||||
val basketballAndFootballDiceResultLimit = 1 .. 5
|
val basketballAndFootballDiceResultLimit = 1 .. 5
|
||||||
@@ -272,10 +273,12 @@ const val correctOptionIdField = "correct_option_id"
|
|||||||
const val allowsMultipleAnswersField = "allows_multiple_answers"
|
const val allowsMultipleAnswersField = "allows_multiple_answers"
|
||||||
const val isAnonymousField = "is_anonymous"
|
const val isAnonymousField = "is_anonymous"
|
||||||
const val canManageTopicsField = "can_manage_topics"
|
const val canManageTopicsField = "can_manage_topics"
|
||||||
|
const val canEditTagField = "can_edit_tag"
|
||||||
const val canPostStoriesField = "can_post_stories"
|
const val canPostStoriesField = "can_post_stories"
|
||||||
const val canEditStoriesField = "can_edit_stories"
|
const val canEditStoriesField = "can_edit_stories"
|
||||||
const val canDeleteStoriesField = "can_delete_stories"
|
const val canDeleteStoriesField = "can_delete_stories"
|
||||||
const val canManageDirectMessagesField = "can_manage_direct_messages"
|
const val canManageDirectMessagesField = "can_manage_direct_messages"
|
||||||
|
const val canManageTagsField = "can_manage_tags"
|
||||||
const val captionEntitiesField = "caption_entities"
|
const val captionEntitiesField = "caption_entities"
|
||||||
const val hasSpoilerField = "has_spoiler"
|
const val hasSpoilerField = "has_spoiler"
|
||||||
const val showCaptionAboveMediaField = "show_caption_above_media"
|
const val showCaptionAboveMediaField = "show_caption_above_media"
|
||||||
@@ -488,6 +491,7 @@ const val headingField = "heading"
|
|||||||
const val fromField = "from"
|
const val fromField = "from"
|
||||||
const val userChatIdField = "user_chat_id"
|
const val userChatIdField = "user_chat_id"
|
||||||
const val userField = "user"
|
const val userField = "user"
|
||||||
|
const val tagField = "tag"
|
||||||
const val newOwnerField = "new_owner"
|
const val newOwnerField = "new_owner"
|
||||||
const val dateField = "date"
|
const val dateField = "date"
|
||||||
const val reactionsField = "reactions"
|
const val reactionsField = "reactions"
|
||||||
@@ -666,6 +670,7 @@ const val mainFrameTimestampField = "main_frame_timestamp"
|
|||||||
|
|
||||||
const val firstProfileAudioField = "first_profile_audio"
|
const val firstProfileAudioField = "first_profile_audio"
|
||||||
const val paidMessageStarCountField = "paid_message_star_count"
|
const val paidMessageStarCountField = "paid_message_star_count"
|
||||||
|
const val senderTagField = "sender_tag"
|
||||||
const val countField = "count"
|
const val countField = "count"
|
||||||
const val ratingField = "rating"
|
const val ratingField = "rating"
|
||||||
const val uniqueGiftColorsField = "unique_gift_colors"
|
const val uniqueGiftColorsField = "unique_gift_colors"
|
||||||
@@ -759,7 +764,9 @@ const val personalRemainingCountField = "personal_remaining_count"
|
|||||||
const val hasColorsField = "has_colors"
|
const val hasColorsField = "has_colors"
|
||||||
const val uniqueGiftVariantCountField = "unique_gift_variant_count"
|
const val uniqueGiftVariantCountField = "unique_gift_variant_count"
|
||||||
const val uniqueGiftNumberField = "unique_gift_number"
|
const val uniqueGiftNumberField = "unique_gift_number"
|
||||||
|
const val isSavedField = "is_saved"
|
||||||
const val isUpgradeSeparateField = "is_upgrade_separate"
|
const val isUpgradeSeparateField = "is_upgrade_separate"
|
||||||
|
const val canBeTransferredField = "can_be_transferred"
|
||||||
const val isFromBlockchainField = "is_from_blockchain"
|
const val isFromBlockchainField = "is_from_blockchain"
|
||||||
|
|
||||||
const val centerColorField = "center_color"
|
const val centerColorField = "center_color"
|
||||||
|
|||||||
@@ -0,0 +1,113 @@
|
|||||||
|
package dev.inmo.tgbotapi.types
|
||||||
|
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Common interface for parts of date time format. Used for [dev.inmo.tgbotapi.types.message.textsources.DateTimeTextSource]
|
||||||
|
*
|
||||||
|
* @see TgDateTimeFormatBuilder
|
||||||
|
* @see buildDateTimeFormat
|
||||||
|
*/
|
||||||
|
@Serializable
|
||||||
|
sealed interface DateTimeFormatPart {
|
||||||
|
/**
|
||||||
|
* Character that represents this part in the format string. Used by [TgDateTimeFormatBuilder.build]
|
||||||
|
*/
|
||||||
|
val controlCharacter: String
|
||||||
|
/**
|
||||||
|
* Represents relative time format (e.g. "2 hours ago"). Control character: "r"
|
||||||
|
*/
|
||||||
|
@Serializable
|
||||||
|
data object Relative : DateTimeFormatPart { override val controlCharacter: String get() = "r" }
|
||||||
|
/**
|
||||||
|
* Represents day of the week format (e.g. "Monday"). Control character: "w"
|
||||||
|
*/
|
||||||
|
@Serializable
|
||||||
|
data object WeekDay : DateTimeFormatPart { override val controlCharacter: String get() = "w" }
|
||||||
|
/**
|
||||||
|
* Group for date-related format parts
|
||||||
|
*/
|
||||||
|
@Serializable
|
||||||
|
sealed interface Date : DateTimeFormatPart {
|
||||||
|
/**
|
||||||
|
* Represents short date format (e.g. "01.01.2023"). Control character: "d"
|
||||||
|
*/
|
||||||
|
@Serializable
|
||||||
|
data object Short : Date { override val controlCharacter: String get() = "d" }
|
||||||
|
/**
|
||||||
|
* Represents long date format (e.g. "January 1, 2023"). Control character: "D"
|
||||||
|
*/
|
||||||
|
@Serializable
|
||||||
|
data object Long : Date { override val controlCharacter: String get() = "D" }
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Group for time-related format parts
|
||||||
|
*/
|
||||||
|
@Serializable
|
||||||
|
sealed interface Time : DateTimeFormatPart {
|
||||||
|
/**
|
||||||
|
* Represents short time format (e.g. "12:00"). Control character: "t"
|
||||||
|
*/
|
||||||
|
@Serializable
|
||||||
|
data object Short : Time { override val controlCharacter: String get() = "t" }
|
||||||
|
/**
|
||||||
|
* Represents long time format (e.g. "12:00:00"). Control character: "T"
|
||||||
|
*/
|
||||||
|
@Serializable
|
||||||
|
data object Long : Time { override val controlCharacter: String get() = "T" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builder for date time format string. Use [buildDateTimeFormat] for convenience
|
||||||
|
*/
|
||||||
|
class TgDateTimeFormatBuilder {
|
||||||
|
private val parts = mutableSetOf<DateTimeFormatPart>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds [DateTimeFormatPart.Relative] to the format
|
||||||
|
*/
|
||||||
|
fun relative() = apply { parts.add(DateTimeFormatPart.Relative) }
|
||||||
|
/**
|
||||||
|
* Adds [DateTimeFormatPart.WeekDay] to the format
|
||||||
|
*/
|
||||||
|
fun weekDay() = apply { parts.add(DateTimeFormatPart.WeekDay) }
|
||||||
|
/**
|
||||||
|
* Adds [DateTimeFormatPart.Date.Short] to the format. Removes any other [DateTimeFormatPart.Date] parts
|
||||||
|
*/
|
||||||
|
fun dateShort() = apply {
|
||||||
|
parts.removeAll { it is DateTimeFormatPart.Date }
|
||||||
|
parts.add(DateTimeFormatPart.Date.Short)
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Adds [DateTimeFormatPart.Time.Short] to the format. Removes any other [DateTimeFormatPart.Time] parts
|
||||||
|
*/
|
||||||
|
fun timeShort() = apply {
|
||||||
|
parts.removeAll { it is DateTimeFormatPart.Time }
|
||||||
|
parts.add(DateTimeFormatPart.Time.Short)
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Adds [DateTimeFormatPart.Date.Long] to the format. Removes any other [DateTimeFormatPart.Date] parts
|
||||||
|
*/
|
||||||
|
fun dateLong() = apply {
|
||||||
|
parts.removeAll { it is DateTimeFormatPart.Date }
|
||||||
|
parts.add(DateTimeFormatPart.Date.Long)
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Adds [DateTimeFormatPart.Time.Long] to the format. Removes any other [DateTimeFormatPart.Time] parts
|
||||||
|
*/
|
||||||
|
fun timeLong() = apply {
|
||||||
|
parts.removeAll { it is DateTimeFormatPart.Time }
|
||||||
|
parts.add(DateTimeFormatPart.Time.Long)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Joins all added parts into a single format string
|
||||||
|
*/
|
||||||
|
fun build() = parts.joinToString("")
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convenient way to build date time format string
|
||||||
|
*/
|
||||||
|
fun buildDateTimeFormat(block: TgDateTimeFormatBuilder.() -> Unit): String = TgDateTimeFormatBuilder().apply(block).build()
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
package dev.inmo.tgbotapi.types
|
package dev.inmo.tgbotapi.types
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.types.gifts.GiftSentOrReceivedEvent
|
import dev.inmo.tgbotapi.types.gifts.OwnedGift
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class OwnedGifts<GiftType: GiftSentOrReceivedEvent>(
|
data class OwnedGifts<GiftType: OwnedGift>(
|
||||||
@SerialName(totalCountField)
|
@SerialName(totalCountField)
|
||||||
val totalCount: Int,
|
val totalCount: Int,
|
||||||
@SerialName(giftsField)
|
@SerialName(giftsField)
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package dev.inmo.tgbotapi.types
|
||||||
|
|
||||||
|
import dev.inmo.kslog.common.w
|
||||||
|
import dev.inmo.tgbotapi.utils.DefaultKTgBotAPIKSLog
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
import kotlin.jvm.JvmInline
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
@JvmInline
|
||||||
|
value class UserTag(val string: String) {
|
||||||
|
init {
|
||||||
|
if (string.length !in memberTagLength) {
|
||||||
|
DefaultKTgBotAPIKSLog.w("UserTag", "Tag length must be in range $memberTagLength, but was ${string.length} ($string)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -33,6 +33,7 @@ interface ChatPermissions {
|
|||||||
val canChangeInfo: Boolean?
|
val canChangeInfo: Boolean?
|
||||||
val canInviteUsers: Boolean?
|
val canInviteUsers: Boolean?
|
||||||
val canPinMessages: Boolean?
|
val canPinMessages: Boolean?
|
||||||
|
val canEditTag: Boolean?
|
||||||
@Transient
|
@Transient
|
||||||
val isGranular
|
val isGranular
|
||||||
get() = canSendAudios != null ||
|
get() = canSendAudios != null ||
|
||||||
@@ -73,7 +74,9 @@ interface ChatPermissions {
|
|||||||
@SerialName(canInviteUsersField)
|
@SerialName(canInviteUsersField)
|
||||||
override val canInviteUsers: Boolean? = null,
|
override val canInviteUsers: Boolean? = null,
|
||||||
@SerialName(canPinMessagesField)
|
@SerialName(canPinMessagesField)
|
||||||
override val canPinMessages: Boolean? = null
|
override val canPinMessages: Boolean? = null,
|
||||||
|
@SerialName(canEditTagField)
|
||||||
|
override val canEditTag: Boolean = false,
|
||||||
) : ChatPermissions {
|
) : ChatPermissions {
|
||||||
@Transient
|
@Transient
|
||||||
override val isGranular: Boolean
|
override val isGranular: Boolean
|
||||||
@@ -93,7 +96,9 @@ interface ChatPermissions {
|
|||||||
@SerialName(canInviteUsersField)
|
@SerialName(canInviteUsersField)
|
||||||
override val canInviteUsers: Boolean? = null,
|
override val canInviteUsers: Boolean? = null,
|
||||||
@SerialName(canPinMessagesField)
|
@SerialName(canPinMessagesField)
|
||||||
override val canPinMessages: Boolean? = null
|
override val canPinMessages: Boolean? = null,
|
||||||
|
@SerialName(canEditTagField)
|
||||||
|
override val canEditTag: Boolean = false,
|
||||||
) : ChatPermissions {
|
) : ChatPermissions {
|
||||||
@Transient
|
@Transient
|
||||||
override val isGranular: Boolean
|
override val isGranular: Boolean
|
||||||
|
|||||||
@@ -48,6 +48,8 @@ data class AdministratorChatMemberImpl(
|
|||||||
override val canDeleteStories: Boolean = false,
|
override val canDeleteStories: Boolean = false,
|
||||||
@SerialName(canManageDirectMessagesField)
|
@SerialName(canManageDirectMessagesField)
|
||||||
override val canManageDirectMessages: Boolean = false,
|
override val canManageDirectMessages: Boolean = false,
|
||||||
|
@SerialName(canManageTagsField)
|
||||||
|
override val canManageTags: Boolean = false,
|
||||||
) : AdministratorChatMember {
|
) : AdministratorChatMember {
|
||||||
@SerialName(statusField)
|
@SerialName(statusField)
|
||||||
@Required
|
@Required
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ sealed interface ChatAdministratorRights : SpecialChatAdministratorRights {
|
|||||||
val canEditStories: Boolean
|
val canEditStories: Boolean
|
||||||
val canDeleteStories: Boolean
|
val canDeleteStories: Boolean
|
||||||
val canManageDirectMessages: Boolean
|
val canManageDirectMessages: Boolean
|
||||||
|
val canManageTags: Boolean
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
operator fun invoke(
|
operator fun invoke(
|
||||||
|
|||||||
@@ -38,4 +38,6 @@ data class ChatCommonAdministratorRights(
|
|||||||
override val canDeleteStories: Boolean = false,
|
override val canDeleteStories: Boolean = false,
|
||||||
@SerialName(canManageDirectMessagesField)
|
@SerialName(canManageDirectMessagesField)
|
||||||
override val canManageDirectMessages: Boolean = false,
|
override val canManageDirectMessages: Boolean = false,
|
||||||
|
@SerialName(canManageTagsField)
|
||||||
|
override val canManageTags: Boolean = false,
|
||||||
) : ChatAdministratorRights
|
) : ChatAdministratorRights
|
||||||
|
|||||||
@@ -13,7 +13,9 @@ data class KickedChatMember(
|
|||||||
@SerialName(userField)
|
@SerialName(userField)
|
||||||
override val user: PreviewUser,
|
override val user: PreviewUser,
|
||||||
@SerialName(untilDateField)
|
@SerialName(untilDateField)
|
||||||
override val untilDate: TelegramDate? = null
|
override val untilDate: TelegramDate? = null,
|
||||||
|
@SerialName(tagField)
|
||||||
|
override val tag: UserTag? = null,
|
||||||
) : RestrictedChatMember {
|
) : RestrictedChatMember {
|
||||||
@SerialName(statusField)
|
@SerialName(statusField)
|
||||||
@Required
|
@Required
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
package dev.inmo.tgbotapi.types.chat.member
|
package dev.inmo.tgbotapi.types.chat.member
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.abstracts.OptionallyTagged
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||||
@Serializable(ChatMemberSerializer::class)
|
@Serializable(ChatMemberSerializer::class)
|
||||||
sealed interface MemberChatMember : ChatMember
|
sealed interface MemberChatMember : ChatMember, OptionallyTagged
|
||||||
|
|||||||
@@ -10,7 +10,9 @@ import kotlinx.serialization.*
|
|||||||
data class MemberChatMemberImpl(
|
data class MemberChatMemberImpl(
|
||||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||||
@SerialName(userField)
|
@SerialName(userField)
|
||||||
override val user: PreviewUser
|
override val user: PreviewUser,
|
||||||
|
@SerialName(tagField)
|
||||||
|
override val tag: UserTag? = null
|
||||||
) : MemberChatMember {
|
) : MemberChatMember {
|
||||||
@SerialName(statusField)
|
@SerialName(statusField)
|
||||||
@Required
|
@Required
|
||||||
|
|||||||
@@ -48,6 +48,8 @@ data class OwnerChatMember(
|
|||||||
override val canDeleteStories: Boolean = true
|
override val canDeleteStories: Boolean = true
|
||||||
@Transient
|
@Transient
|
||||||
override val canManageDirectMessages: Boolean = true
|
override val canManageDirectMessages: Boolean = true
|
||||||
|
@Transient
|
||||||
|
override val canManageTags: Boolean = true
|
||||||
|
|
||||||
@SerialName(statusField)
|
@SerialName(statusField)
|
||||||
@Required
|
@Required
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package dev.inmo.tgbotapi.types.chat.member
|
package dev.inmo.tgbotapi.types.chat.member
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.abstracts.OptionallyTagged
|
||||||
import dev.inmo.tgbotapi.abstracts.types.UntilDate
|
import dev.inmo.tgbotapi.abstracts.types.UntilDate
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.chat.PreviewUser
|
import dev.inmo.tgbotapi.types.chat.PreviewUser
|
||||||
@@ -8,7 +9,7 @@ import kotlinx.serialization.Serializable
|
|||||||
|
|
||||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||||
@Serializable(ChatMemberSerializer::class)
|
@Serializable(ChatMemberSerializer::class)
|
||||||
sealed interface RestrictedChatMember : ChatMember, UntilDate {
|
sealed interface RestrictedChatMember : ChatMember, UntilDate, OptionallyTagged {
|
||||||
companion object {
|
companion object {
|
||||||
// backward compatibility fun
|
// backward compatibility fun
|
||||||
@Deprecated(
|
@Deprecated(
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ package dev.inmo.tgbotapi.types.chat.member
|
|||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.chat.ChatPermissions
|
import dev.inmo.tgbotapi.types.chat.ChatPermissions
|
||||||
import dev.inmo.tgbotapi.types.chat.PreviewUser
|
import dev.inmo.tgbotapi.types.chat.PreviewUser
|
||||||
import dev.inmo.tgbotapi.types.chat.User
|
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -48,7 +47,11 @@ data class RestrictedMemberChatMember(
|
|||||||
@SerialName(canPinMessagesField)
|
@SerialName(canPinMessagesField)
|
||||||
override val canPinMessages: Boolean = false,
|
override val canPinMessages: Boolean = false,
|
||||||
@SerialName(canManageTopicsField)
|
@SerialName(canManageTopicsField)
|
||||||
override val canManageTopics: Boolean = false
|
override val canManageTopics: Boolean = false,
|
||||||
|
@SerialName(canEditTagField)
|
||||||
|
override val canEditTag: Boolean = false,
|
||||||
|
@SerialName(tagField)
|
||||||
|
override val tag: UserTag? = null,
|
||||||
) : RestrictedChatMember, SpecialRightsChatMember, MemberChatMember, ChatPermissions {
|
) : RestrictedChatMember, SpecialRightsChatMember, MemberChatMember, ChatPermissions {
|
||||||
@SerialName(statusField)
|
@SerialName(statusField)
|
||||||
@Required
|
@Required
|
||||||
|
|||||||
@@ -13,7 +13,9 @@ data class SubscriptionMemberChatMemberImpl(
|
|||||||
override val user: PreviewUser,
|
override val user: PreviewUser,
|
||||||
@SerialName(untilDateField)
|
@SerialName(untilDateField)
|
||||||
@Serializable(TelegramDateSerializer::class)
|
@Serializable(TelegramDateSerializer::class)
|
||||||
override val untilDate: TelegramDate
|
override val untilDate: TelegramDate,
|
||||||
|
@SerialName(tagField)
|
||||||
|
override val tag: UserTag? = null
|
||||||
) : SubscriptionMemberChatMember {
|
) : SubscriptionMemberChatMember {
|
||||||
@SerialName(statusField)
|
@SerialName(statusField)
|
||||||
@Required
|
@Required
|
||||||
|
|||||||
@@ -0,0 +1,348 @@
|
|||||||
|
package dev.inmo.tgbotapi.types.gifts
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.abstracts.TextedInput
|
||||||
|
import dev.inmo.tgbotapi.types.*
|
||||||
|
import dev.inmo.tgbotapi.types.chat.PreviewUser
|
||||||
|
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.CommonEvent
|
||||||
|
import dev.inmo.tgbotapi.types.message.RawMessageEntities
|
||||||
|
import dev.inmo.tgbotapi.types.message.asTextSources
|
||||||
|
import dev.inmo.tgbotapi.types.message.textsources.TextSource
|
||||||
|
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
||||||
|
import dev.inmo.tgbotapi.types.message.toRawMessageEntities
|
||||||
|
import dev.inmo.tgbotapi.types.payments.abstracts.Currency
|
||||||
|
import kotlinx.serialization.KSerializer
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
import kotlinx.serialization.Transient
|
||||||
|
import kotlinx.serialization.builtins.serializer
|
||||||
|
import kotlinx.serialization.descriptors.SerialDescriptor
|
||||||
|
import kotlinx.serialization.encoding.Decoder
|
||||||
|
import kotlinx.serialization.encoding.Encoder
|
||||||
|
import kotlinx.serialization.json.JsonDecoder
|
||||||
|
import kotlinx.serialization.json.JsonElement
|
||||||
|
import kotlinx.serialization.json.jsonObject
|
||||||
|
import kotlinx.serialization.json.jsonPrimitive
|
||||||
|
import kotlin.jvm.JvmInline
|
||||||
|
import kotlin.jvm.JvmName
|
||||||
|
|
||||||
|
@Serializable(OwnedGift.Companion::class)
|
||||||
|
sealed interface OwnedGift {
|
||||||
|
val gift: Gift
|
||||||
|
val sendDate: TelegramDate
|
||||||
|
val ownedGiftId: GiftId?
|
||||||
|
val senderUser: PreviewUser?
|
||||||
|
val isSaved: Boolean
|
||||||
|
|
||||||
|
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||||
|
@Serializable(OwnedGift.Companion::class)
|
||||||
|
sealed interface OwnedByBusinessAccount : OwnedGift {
|
||||||
|
override val ownedGiftId: GiftId
|
||||||
|
}
|
||||||
|
|
||||||
|
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||||
|
@Serializable(OwnedGift.Companion::class)
|
||||||
|
sealed interface Common : OwnedGift {
|
||||||
|
override val ownedGiftId: GiftId?
|
||||||
|
get() = null
|
||||||
|
}
|
||||||
|
|
||||||
|
@Serializable(Regular.Companion::class)
|
||||||
|
sealed interface Regular : OwnedGift, TextedInput {
|
||||||
|
override val gift: Gift.Regular
|
||||||
|
val isPrivate: Boolean
|
||||||
|
val canBeUpgraded: Boolean
|
||||||
|
val wasRefunded: Boolean
|
||||||
|
val convertStarCount: Int?
|
||||||
|
val prepaidUpgradeStarCount: Int?
|
||||||
|
val isUpgradeSeparate: Boolean
|
||||||
|
val uniqueGiftNumber: Int?
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class Common(
|
||||||
|
@SerialName(giftField)
|
||||||
|
override val gift: Gift.Regular,
|
||||||
|
@SerialName(sendDateField)
|
||||||
|
override val sendDate: TelegramDate,
|
||||||
|
@SerialName(senderUserField)
|
||||||
|
override val senderUser: PreviewUser? = null,
|
||||||
|
@SerialName(textField)
|
||||||
|
override val text: String? = null,
|
||||||
|
@SerialName(entitiesField)
|
||||||
|
private val entities: RawMessageEntities? = null,
|
||||||
|
@SerialName(isPrivateField)
|
||||||
|
override val isPrivate: Boolean = false,
|
||||||
|
@SerialName(isSavedField)
|
||||||
|
override val isSaved: Boolean = false,
|
||||||
|
@SerialName(canBeUpgradedField)
|
||||||
|
override val canBeUpgraded: Boolean = false,
|
||||||
|
@SerialName(wasRefundedField)
|
||||||
|
override val wasRefunded: Boolean = false,
|
||||||
|
@SerialName(convertStarCountField)
|
||||||
|
override val convertStarCount: Int? = null,
|
||||||
|
@SerialName(prepaidUpgradeStarCountField)
|
||||||
|
override val prepaidUpgradeStarCount: Int? = null,
|
||||||
|
@SerialName(isUpgradeSeparateField)
|
||||||
|
override val isUpgradeSeparate: Boolean = false,
|
||||||
|
@SerialName(uniqueGiftNumberField)
|
||||||
|
override val uniqueGiftNumber: Int? = null
|
||||||
|
) : Regular, OwnedGift.Common {
|
||||||
|
override val textSources: List<TextSource> by lazy {
|
||||||
|
entities ?.asTextSources(text ?: return@lazy emptyList()) ?: emptyList()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class OwnedByBusinessAccount(
|
||||||
|
@SerialName(giftField)
|
||||||
|
override val gift: Gift.Regular,
|
||||||
|
@SerialName(sendDateField)
|
||||||
|
override val sendDate: TelegramDate,
|
||||||
|
@SerialName(ownedGiftIdField)
|
||||||
|
override val ownedGiftId: GiftId,
|
||||||
|
@SerialName(senderUserField)
|
||||||
|
override val senderUser: PreviewUser? = null,
|
||||||
|
@SerialName(textField)
|
||||||
|
override val text: String? = null,
|
||||||
|
@SerialName(entitiesField)
|
||||||
|
private val entities: RawMessageEntities? = null,
|
||||||
|
@SerialName(isPrivateField)
|
||||||
|
override val isPrivate: Boolean = false,
|
||||||
|
@SerialName(isSavedField)
|
||||||
|
override val isSaved: Boolean = false,
|
||||||
|
@SerialName(canBeUpgradedField)
|
||||||
|
override val canBeUpgraded: Boolean = false,
|
||||||
|
@SerialName(wasRefundedField)
|
||||||
|
override val wasRefunded: Boolean = false,
|
||||||
|
@SerialName(convertStarCountField)
|
||||||
|
override val convertStarCount: Int? = null,
|
||||||
|
@SerialName(prepaidUpgradeStarCountField)
|
||||||
|
override val prepaidUpgradeStarCount: Int? = null,
|
||||||
|
@SerialName(isUpgradeSeparateField)
|
||||||
|
override val isUpgradeSeparate: Boolean = false,
|
||||||
|
@SerialName(uniqueGiftNumberField)
|
||||||
|
override val uniqueGiftNumber: Int? = null
|
||||||
|
) : Regular, OwnedGift.OwnedByBusinessAccount {
|
||||||
|
override val textSources: List<TextSource> by lazy {
|
||||||
|
entities ?.asTextSources(text ?: return@lazy emptyList()) ?: emptyList()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object : KSerializer<OwnedGift.Regular> {
|
||||||
|
@Serializable
|
||||||
|
private data class Surrogate(
|
||||||
|
@SerialName(giftField)
|
||||||
|
val gift: Gift.Regular,
|
||||||
|
@SerialName(ownedGiftIdField)
|
||||||
|
val ownedGiftId: GiftId? = null,
|
||||||
|
@SerialName(senderUserField)
|
||||||
|
val senderUser: PreviewUser? = null,
|
||||||
|
@SerialName(sendDateField)
|
||||||
|
val sendDate: TelegramDate,
|
||||||
|
@SerialName(textField)
|
||||||
|
val text: String? = null,
|
||||||
|
@SerialName(entitiesField)
|
||||||
|
val entities: RawMessageEntities? = null,
|
||||||
|
@SerialName(isPrivateField)
|
||||||
|
val isPrivate: Boolean = false,
|
||||||
|
@SerialName(isSavedField)
|
||||||
|
val isSaved: Boolean = false,
|
||||||
|
@SerialName(canBeUpgradedField)
|
||||||
|
val canBeUpgraded: Boolean = false,
|
||||||
|
@SerialName(wasRefundedField)
|
||||||
|
val wasRefunded: Boolean = false,
|
||||||
|
@SerialName(convertStarCountField)
|
||||||
|
val convertStarCount: Int? = null,
|
||||||
|
@SerialName(prepaidUpgradeStarCountField)
|
||||||
|
val prepaidUpgradeStarCount: Int? = null,
|
||||||
|
@SerialName(isUpgradeSeparateField)
|
||||||
|
val isUpgradeSeparate: Boolean = false,
|
||||||
|
@SerialName(uniqueGiftNumberField)
|
||||||
|
val uniqueGiftNumber: Int? = null
|
||||||
|
)
|
||||||
|
|
||||||
|
override val descriptor: SerialDescriptor
|
||||||
|
get() = Surrogate.serializer().descriptor
|
||||||
|
|
||||||
|
override fun serialize(encoder: Encoder, value: Regular) {
|
||||||
|
when (value) {
|
||||||
|
is Common -> Common.serializer().serialize(encoder, value)
|
||||||
|
is OwnedByBusinessAccount -> OwnedByBusinessAccount.serializer().serialize(encoder, value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun deserialize(decoder: Decoder): Regular {
|
||||||
|
val surrogate = Surrogate.serializer().deserialize(decoder)
|
||||||
|
|
||||||
|
return when {
|
||||||
|
surrogate.ownedGiftId == null -> {
|
||||||
|
Common(
|
||||||
|
gift = surrogate.gift,
|
||||||
|
sendDate = surrogate.sendDate,
|
||||||
|
senderUser = surrogate.senderUser,
|
||||||
|
text = surrogate.text,
|
||||||
|
entities = surrogate.entities,
|
||||||
|
isPrivate = surrogate.isPrivate,
|
||||||
|
isSaved = surrogate.isSaved,
|
||||||
|
canBeUpgraded = surrogate.canBeUpgraded,
|
||||||
|
wasRefunded = surrogate.wasRefunded,
|
||||||
|
convertStarCount = surrogate.convertStarCount,
|
||||||
|
prepaidUpgradeStarCount = surrogate.prepaidUpgradeStarCount,
|
||||||
|
isUpgradeSeparate = surrogate.isUpgradeSeparate,
|
||||||
|
uniqueGiftNumber = surrogate.uniqueGiftNumber
|
||||||
|
)
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
OwnedByBusinessAccount(
|
||||||
|
gift = surrogate.gift,
|
||||||
|
sendDate = surrogate.sendDate,
|
||||||
|
ownedGiftId = surrogate.ownedGiftId,
|
||||||
|
senderUser = surrogate.senderUser,
|
||||||
|
text = surrogate.text,
|
||||||
|
entities = surrogate.entities,
|
||||||
|
isPrivate = surrogate.isPrivate,
|
||||||
|
isSaved = surrogate.isSaved,
|
||||||
|
canBeUpgraded = surrogate.canBeUpgraded,
|
||||||
|
wasRefunded = surrogate.wasRefunded,
|
||||||
|
convertStarCount = surrogate.convertStarCount,
|
||||||
|
prepaidUpgradeStarCount = surrogate.prepaidUpgradeStarCount,
|
||||||
|
isUpgradeSeparate = surrogate.isUpgradeSeparate,
|
||||||
|
uniqueGiftNumber = surrogate.uniqueGiftNumber
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Serializable(Unique.Companion::class)
|
||||||
|
sealed interface Unique : OwnedGift {
|
||||||
|
override val gift: Gift.Unique
|
||||||
|
val canBeTransferred: Boolean
|
||||||
|
val transferStarCount: Int?
|
||||||
|
val nextTransferDate: TelegramDate?
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class Common(
|
||||||
|
@SerialName(giftField)
|
||||||
|
override val gift: Gift.Unique,
|
||||||
|
@SerialName(sendDateField)
|
||||||
|
override val sendDate: TelegramDate,
|
||||||
|
@SerialName(senderUserField)
|
||||||
|
override val senderUser: PreviewUser? = null,
|
||||||
|
@SerialName(isSavedField)
|
||||||
|
override val isSaved: Boolean = false,
|
||||||
|
@SerialName(canBeTransferredField)
|
||||||
|
override val canBeTransferred: Boolean = false,
|
||||||
|
@SerialName(transferStarCountField)
|
||||||
|
override val transferStarCount: Int? = null,
|
||||||
|
@SerialName(nextTransferDateField)
|
||||||
|
override val nextTransferDate: TelegramDate? = null
|
||||||
|
) : Unique, OwnedGift.Common
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class OwnedByBusinessAccount(
|
||||||
|
@SerialName(giftField)
|
||||||
|
override val gift: Gift.Unique,
|
||||||
|
@SerialName(sendDateField)
|
||||||
|
override val sendDate: TelegramDate,
|
||||||
|
@SerialName(ownedGiftIdField)
|
||||||
|
override val ownedGiftId: GiftId,
|
||||||
|
@SerialName(senderUserField)
|
||||||
|
override val senderUser: PreviewUser? = null,
|
||||||
|
@SerialName(isSavedField)
|
||||||
|
override val isSaved: Boolean = false,
|
||||||
|
@SerialName(canBeTransferredField)
|
||||||
|
override val canBeTransferred: Boolean = false,
|
||||||
|
@SerialName(transferStarCountField)
|
||||||
|
override val transferStarCount: Int? = null,
|
||||||
|
@SerialName(nextTransferDateField)
|
||||||
|
override val nextTransferDate: TelegramDate? = null
|
||||||
|
) : Unique, OwnedGift.OwnedByBusinessAccount
|
||||||
|
|
||||||
|
companion object : KSerializer<OwnedGift.Unique> {
|
||||||
|
@Serializable
|
||||||
|
private data class Surrogate(
|
||||||
|
@SerialName(giftField)
|
||||||
|
val gift: Gift.Unique,
|
||||||
|
@SerialName(ownedGiftIdField)
|
||||||
|
val ownedGiftId: GiftId? = null,
|
||||||
|
@SerialName(senderUserField)
|
||||||
|
val senderUser: PreviewUser? = null,
|
||||||
|
@SerialName(sendDateField)
|
||||||
|
val sendDate: TelegramDate,
|
||||||
|
@SerialName(isSavedField)
|
||||||
|
val isSaved: Boolean = false,
|
||||||
|
@SerialName(canBeTransferredField)
|
||||||
|
val canBeTransferred: Boolean = false,
|
||||||
|
@SerialName(transferStarCountField)
|
||||||
|
val transferStarCount: Int? = null,
|
||||||
|
@SerialName(nextTransferDateField)
|
||||||
|
val nextTransferDate: TelegramDate? = null
|
||||||
|
)
|
||||||
|
|
||||||
|
override val descriptor: SerialDescriptor
|
||||||
|
get() = Surrogate.serializer().descriptor
|
||||||
|
|
||||||
|
override fun serialize(encoder: Encoder, value: Unique) {
|
||||||
|
when (value) {
|
||||||
|
is Common -> Common.serializer().serialize(encoder, value)
|
||||||
|
is OwnedByBusinessAccount -> OwnedByBusinessAccount.serializer().serialize(encoder, value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun deserialize(decoder: Decoder): Unique {
|
||||||
|
val surrogate = Surrogate.serializer().deserialize(decoder)
|
||||||
|
|
||||||
|
return when {
|
||||||
|
surrogate.ownedGiftId == null -> {
|
||||||
|
Common(
|
||||||
|
gift = surrogate.gift,
|
||||||
|
sendDate = surrogate.sendDate,
|
||||||
|
senderUser = surrogate.senderUser,
|
||||||
|
isSaved = surrogate.isSaved,
|
||||||
|
canBeTransferred = surrogate.canBeTransferred,
|
||||||
|
transferStarCount = surrogate.transferStarCount,
|
||||||
|
nextTransferDate = surrogate.nextTransferDate
|
||||||
|
)
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
OwnedByBusinessAccount(
|
||||||
|
gift = surrogate.gift,
|
||||||
|
sendDate = surrogate.sendDate,
|
||||||
|
ownedGiftId = surrogate.ownedGiftId,
|
||||||
|
senderUser = surrogate.senderUser,
|
||||||
|
isSaved = surrogate.isSaved,
|
||||||
|
canBeTransferred = surrogate.canBeTransferred,
|
||||||
|
transferStarCount = surrogate.transferStarCount,
|
||||||
|
nextTransferDate = surrogate.nextTransferDate
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object : KSerializer<OwnedGift> {
|
||||||
|
override val descriptor: SerialDescriptor
|
||||||
|
get() = JsonElement.serializer().descriptor
|
||||||
|
|
||||||
|
override fun serialize(encoder: Encoder, value: OwnedGift) {
|
||||||
|
when (value) {
|
||||||
|
is Regular -> Regular.serialize(encoder, value)
|
||||||
|
is Unique -> Unique.serialize(encoder, value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun deserialize(decoder: Decoder): OwnedGift {
|
||||||
|
val json = (decoder as JsonDecoder)
|
||||||
|
val element = json.decodeJsonElement()
|
||||||
|
val type = element.jsonObject[typeField] ?.jsonPrimitive ?.content
|
||||||
|
|
||||||
|
return when (type) {
|
||||||
|
"regular" -> json.json.decodeFromJsonElement(Regular, element)
|
||||||
|
"unique" -> json.json.decodeFromJsonElement(Unique, element)
|
||||||
|
else -> error("Unknown OwnedGift type: $type")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,5 +19,5 @@ data class UniqueGiftModel(
|
|||||||
@SerialName(rarityPerMilleField)
|
@SerialName(rarityPerMilleField)
|
||||||
val rarityPerMille: Int,
|
val rarityPerMille: Int,
|
||||||
@SerialName(rarityField)
|
@SerialName(rarityField)
|
||||||
val rarity: Rarity
|
val rarity: Rarity? = null
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -185,6 +185,8 @@ data class CommonGroupContentMessageImpl<T : MessageContent>(
|
|||||||
override val fromOffline: Boolean,
|
override val fromOffline: Boolean,
|
||||||
@SerialName(paidMessageStarCountField)
|
@SerialName(paidMessageStarCountField)
|
||||||
override val cost: Int? = null,
|
override val cost: Int? = null,
|
||||||
|
@SerialName(senderTagField)
|
||||||
|
override val senderTag: UserTag? = null,
|
||||||
) : CommonGroupContentMessage<T> {
|
) : CommonGroupContentMessage<T> {
|
||||||
constructor(
|
constructor(
|
||||||
chat: PreviewGroupChat,
|
chat: PreviewGroupChat,
|
||||||
@@ -463,6 +465,8 @@ data class CommonForumContentMessageImpl<T : MessageContent>(
|
|||||||
override val fromOffline: Boolean,
|
override val fromOffline: Boolean,
|
||||||
@SerialName(paidMessageStarCountField)
|
@SerialName(paidMessageStarCountField)
|
||||||
override val cost: Int? = null,
|
override val cost: Int? = null,
|
||||||
|
@SerialName(senderTagField)
|
||||||
|
override val senderTag: UserTag? = null,
|
||||||
) : CommonForumContentMessage<T> {
|
) : CommonForumContentMessage<T> {
|
||||||
constructor(
|
constructor(
|
||||||
chat: PreviewForumChat,
|
chat: PreviewForumChat,
|
||||||
@@ -520,6 +524,8 @@ data class CommonChannelDirectMessagesContentMessageImpl<T : MessageContent>(
|
|||||||
override val fromOffline: Boolean,
|
override val fromOffline: Boolean,
|
||||||
@SerialName(paidMessageStarCountField)
|
@SerialName(paidMessageStarCountField)
|
||||||
override val cost: Int? = null,
|
override val cost: Int? = null,
|
||||||
|
@SerialName(senderTagField)
|
||||||
|
override val senderTag: UserTag? = null
|
||||||
) : CommonChannelDirectMessagesContentMessage<T> {
|
) : CommonChannelDirectMessagesContentMessage<T> {
|
||||||
constructor(
|
constructor(
|
||||||
chat: PreviewChannelDirectMessagesChat,
|
chat: PreviewChannelDirectMessagesChat,
|
||||||
@@ -577,7 +583,9 @@ data class CommonSuggestedChannelDirectMessagesContentMessageImpl<T : MessageCon
|
|||||||
override val fromOffline: Boolean,
|
override val fromOffline: Boolean,
|
||||||
override val suggestedPostInfo: SuggestedPostInfo,
|
override val suggestedPostInfo: SuggestedPostInfo,
|
||||||
@SerialName(paidMessageStarCountField)
|
@SerialName(paidMessageStarCountField)
|
||||||
override val cost: Int? = null
|
override val cost: Int? = null,
|
||||||
|
@SerialName(senderTagField)
|
||||||
|
override val senderTag: UserTag? = null
|
||||||
) : CommonSuggestedChannelDirectMessagesContentMessage<T> {
|
) : CommonSuggestedChannelDirectMessagesContentMessage<T> {
|
||||||
constructor(
|
constructor(
|
||||||
chat: PreviewChannelDirectMessagesChat,
|
chat: PreviewChannelDirectMessagesChat,
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ internal data class RawMessage(
|
|||||||
private val direct_messages_topic: DirectMessagesTopic? = null,
|
private val direct_messages_topic: DirectMessagesTopic? = null,
|
||||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||||
private val from: PreviewUser? = null,
|
private val from: PreviewUser? = null,
|
||||||
|
private val sender_tag: UserTag? = null,
|
||||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||||
private val sender_chat: PreviewPublicChat? = null,
|
private val sender_chat: PreviewPublicChat? = null,
|
||||||
private val forward_origin: MessageOrigin? = null,
|
private val forward_origin: MessageOrigin? = null,
|
||||||
@@ -476,6 +477,7 @@ internal data class RawMessage(
|
|||||||
senderBoostsCount = sender_boost_count,
|
senderBoostsCount = sender_boost_count,
|
||||||
fromOffline = is_from_offline,
|
fromOffline = is_from_offline,
|
||||||
cost = paid_star_count,
|
cost = paid_star_count,
|
||||||
|
senderTag = sender_tag,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -519,6 +521,7 @@ internal data class RawMessage(
|
|||||||
fromOffline = is_from_offline,
|
fromOffline = is_from_offline,
|
||||||
suggestedPostInfo = suggested_post_info,
|
suggestedPostInfo = suggested_post_info,
|
||||||
cost = paid_star_count,
|
cost = paid_star_count,
|
||||||
|
senderTag = sender_tag,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -625,6 +628,7 @@ internal data class RawMessage(
|
|||||||
senderBoostsCount = sender_boost_count,
|
senderBoostsCount = sender_boost_count,
|
||||||
fromOffline = is_from_offline,
|
fromOffline = is_from_offline,
|
||||||
cost = paid_star_count,
|
cost = paid_star_count,
|
||||||
|
senderTag = sender_tag,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -698,6 +702,7 @@ internal data class RawMessage(
|
|||||||
senderBoostsCount = sender_boost_count,
|
senderBoostsCount = sender_boost_count,
|
||||||
fromOffline = is_from_offline,
|
fromOffline = is_from_offline,
|
||||||
cost = paid_star_count,
|
cost = paid_star_count,
|
||||||
|
senderTag = sender_tag
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -773,6 +778,7 @@ internal data class RawMessage(
|
|||||||
senderBoostsCount = sender_boost_count,
|
senderBoostsCount = sender_boost_count,
|
||||||
fromOffline = is_from_offline,
|
fromOffline = is_from_offline,
|
||||||
cost = paid_star_count,
|
cost = paid_star_count,
|
||||||
|
senderTag = sender_tag,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package dev.inmo.tgbotapi.types.message
|
|||||||
|
|
||||||
import dev.inmo.micro_utils.common.Warning
|
import dev.inmo.micro_utils.common.Warning
|
||||||
import dev.inmo.tgbotapi.types.CustomEmojiId
|
import dev.inmo.tgbotapi.types.CustomEmojiId
|
||||||
|
import dev.inmo.tgbotapi.types.UnixTimeStamp
|
||||||
import dev.inmo.tgbotapi.types.chat.User
|
import dev.inmo.tgbotapi.types.chat.User
|
||||||
import dev.inmo.tgbotapi.types.message.textsources.*
|
import dev.inmo.tgbotapi.types.message.textsources.*
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
@@ -15,7 +16,9 @@ data class RawMessageEntity(
|
|||||||
val url: String? = null,
|
val url: String? = null,
|
||||||
val user: User? = null,
|
val user: User? = null,
|
||||||
val language: String? = null,
|
val language: String? = null,
|
||||||
val custom_emoji_id: CustomEmojiId? = null
|
val custom_emoji_id: CustomEmojiId? = null,
|
||||||
|
val unix_time: UnixTimeStamp? = null,
|
||||||
|
val date_time_format: String? = null
|
||||||
) {
|
) {
|
||||||
internal val range by lazy {
|
internal val range by lazy {
|
||||||
offset until (offset + length)
|
offset until (offset + length)
|
||||||
@@ -43,6 +46,7 @@ data class RawMessageEntity(
|
|||||||
"code" -> 2
|
"code" -> 2
|
||||||
"pre" -> 2
|
"pre" -> 2
|
||||||
"text_link" -> 2
|
"text_link" -> 2
|
||||||
|
"date_time" -> 2
|
||||||
else -> 2
|
else -> 2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -75,6 +79,11 @@ fun RawMessageEntity.asTextSource(
|
|||||||
sourceSubstring,
|
sourceSubstring,
|
||||||
url ?: throw IllegalStateException("URL must not be null for text link")
|
url ?: throw IllegalStateException("URL must not be null for text link")
|
||||||
)
|
)
|
||||||
|
"date_time" -> DateTimeTextSource(
|
||||||
|
sourceSubstring,
|
||||||
|
unix_time ?: throw IllegalStateException("Unix time must not be null for date_time"),
|
||||||
|
date_time_format
|
||||||
|
)
|
||||||
"text_mention" -> TextMentionTextSource(
|
"text_mention" -> TextMentionTextSource(
|
||||||
sourceSubstring,
|
sourceSubstring,
|
||||||
user ?: throw IllegalStateException("User must not be null for text mention"),
|
user ?: throw IllegalStateException("User must not be null for text mention"),
|
||||||
@@ -200,6 +209,7 @@ fun TextSource.toRawMessageEntities(offset: Int = 0): List<RawMessageEntity> {
|
|||||||
is StrikethroughTextSource -> RawMessageEntity("strikethrough", offset, length)
|
is StrikethroughTextSource -> RawMessageEntity("strikethrough", offset, length)
|
||||||
is SpoilerTextSource -> RawMessageEntity("spoiler", offset, length)
|
is SpoilerTextSource -> RawMessageEntity("spoiler", offset, length)
|
||||||
is CustomEmojiTextSource -> RawMessageEntity("custom_emoji", offset, length, custom_emoji_id = customEmojiId)
|
is CustomEmojiTextSource -> RawMessageEntity("custom_emoji", offset, length, custom_emoji_id = customEmojiId)
|
||||||
|
is DateTimeTextSource -> RawMessageEntity("date_time", offset, length, unix_time = unixTimeStamp, date_time_format = dateTimeFormat)
|
||||||
is RegularTextSource -> null
|
is RegularTextSource -> null
|
||||||
}
|
}
|
||||||
) + if (this is MultilevelTextSource) {
|
) + if (this is MultilevelTextSource) {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package dev.inmo.tgbotapi.types.message.abstracts
|
package dev.inmo.tgbotapi.types.message.abstracts
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.requests.chat.forum.CreateForumTopic
|
|
||||||
import dev.inmo.tgbotapi.types.DirectMessageThreadId
|
import dev.inmo.tgbotapi.types.DirectMessageThreadId
|
||||||
import dev.inmo.tgbotapi.types.MessageThreadId
|
import dev.inmo.tgbotapi.types.MessageThreadId
|
||||||
|
import dev.inmo.tgbotapi.types.UserTag
|
||||||
import dev.inmo.tgbotapi.types.chat.*
|
import dev.inmo.tgbotapi.types.chat.*
|
||||||
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicCreated
|
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicCreated
|
||||||
import dev.inmo.tgbotapi.types.message.ChatEvents.suggested.SuggestedPostInfo
|
import dev.inmo.tgbotapi.types.message.ChatEvents.suggested.SuggestedPostInfo
|
||||||
@@ -14,6 +14,7 @@ sealed interface GroupContentMessage<T : MessageContent> : PublicContentMessage<
|
|||||||
|
|
||||||
sealed interface PotentiallyFromUserGroupContentMessage<T : MessageContent> : GroupContentMessage<T> {
|
sealed interface PotentiallyFromUserGroupContentMessage<T : MessageContent> : GroupContentMessage<T> {
|
||||||
val senderBoostsCount: Int?
|
val senderBoostsCount: Int?
|
||||||
|
val senderTag: UserTag?
|
||||||
}
|
}
|
||||||
|
|
||||||
sealed interface ForumContentMessage<T : MessageContent> : GroupContentMessage<T>, PossiblyTopicMessage {
|
sealed interface ForumContentMessage<T : MessageContent> : GroupContentMessage<T>, PossiblyTopicMessage {
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package dev.inmo.tgbotapi.types.message.textsources
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.types.UnixTimeStamp
|
||||||
|
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||||
|
import dev.inmo.tgbotapi.utils.internal.*
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see linkTextSource
|
||||||
|
*/
|
||||||
|
@Serializable
|
||||||
|
data class DateTimeTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
|
||||||
|
override val source: String,
|
||||||
|
val unixTimeStamp: UnixTimeStamp,
|
||||||
|
val dateTimeFormat: String?
|
||||||
|
) : TextSource {
|
||||||
|
override val markdown: String by lazy { source.dateTimeMarkdown(unixTimeStamp, dateTimeFormat) }
|
||||||
|
override val markdownV2: String by lazy { source.dateTimeMarkdownV2(unixTimeStamp, dateTimeFormat) }
|
||||||
|
override val html: String by lazy { source.dateTimeHTML(unixTimeStamp, dateTimeFormat) }
|
||||||
|
}
|
||||||
|
|
||||||
|
fun dateTimeTextSource(
|
||||||
|
text: String,
|
||||||
|
unixTimeStamp: UnixTimeStamp,
|
||||||
|
dateTimeFormat: String?
|
||||||
|
) = DateTimeTextSource(text, unixTimeStamp, dateTimeFormat)
|
||||||
@@ -28,6 +28,7 @@ object TextSourceSerializer : TypedSerializer<TextSource>(TextSource::class, emp
|
|||||||
"cashtag" to CashTagTextSource.serializer(),
|
"cashtag" to CashTagTextSource.serializer(),
|
||||||
"spoiler" to SpoilerTextSource.serializer(),
|
"spoiler" to SpoilerTextSource.serializer(),
|
||||||
"custom_emoji" to CustomEmojiTextSource.serializer(),
|
"custom_emoji" to CustomEmojiTextSource.serializer(),
|
||||||
|
"date_time" to DateTimeTextSource.serializer(),
|
||||||
"blockquote" to BlockquoteTextSource.serializer(),
|
"blockquote" to BlockquoteTextSource.serializer(),
|
||||||
"expandable_blockquote" to ExpandableBlockquoteTextSource.serializer(),
|
"expandable_blockquote" to ExpandableBlockquoteTextSource.serializer(),
|
||||||
).also {
|
).also {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import kotlinx.serialization.json.JsonElement
|
|||||||
@ClassCastsIncluded
|
@ClassCastsIncluded
|
||||||
sealed interface StarTransaction : Amounted {
|
sealed interface StarTransaction : Amounted {
|
||||||
val id: StarTransactionId
|
val id: StarTransactionId
|
||||||
val nanostarAmount: Int
|
val nanostarAmount: Int?
|
||||||
val date: TelegramDate
|
val date: TelegramDate
|
||||||
val partner: TransactionPartner
|
val partner: TransactionPartner
|
||||||
val source: TransactionPartner?
|
val source: TransactionPartner?
|
||||||
@@ -32,7 +32,7 @@ sealed interface StarTransaction : Amounted {
|
|||||||
@SerialName(amountField)
|
@SerialName(amountField)
|
||||||
override val amount: Long,
|
override val amount: Long,
|
||||||
@SerialName(nanostarAmountField)
|
@SerialName(nanostarAmountField)
|
||||||
override val nanostarAmount: Int,
|
override val nanostarAmount: Int?,
|
||||||
@SerialName(dateField)
|
@SerialName(dateField)
|
||||||
override val date: TelegramDate,
|
override val date: TelegramDate,
|
||||||
@SerialName(sourceField)
|
@SerialName(sourceField)
|
||||||
@@ -52,7 +52,7 @@ sealed interface StarTransaction : Amounted {
|
|||||||
@SerialName(amountField)
|
@SerialName(amountField)
|
||||||
override val amount: Long,
|
override val amount: Long,
|
||||||
@SerialName(nanostarAmountField)
|
@SerialName(nanostarAmountField)
|
||||||
override val nanostarAmount: Int,
|
override val nanostarAmount: Int?,
|
||||||
@SerialName(dateField)
|
@SerialName(dateField)
|
||||||
override val date: TelegramDate,
|
override val date: TelegramDate,
|
||||||
@SerialName(receiverField)
|
@SerialName(receiverField)
|
||||||
@@ -71,7 +71,7 @@ sealed interface StarTransaction : Amounted {
|
|||||||
override val id: StarTransactionId,
|
override val id: StarTransactionId,
|
||||||
override val amount: Long,
|
override val amount: Long,
|
||||||
@SerialName(nanostarAmountField)
|
@SerialName(nanostarAmountField)
|
||||||
override val nanostarAmount: Int,
|
override val nanostarAmount: Int?,
|
||||||
override val date: TelegramDate,
|
override val date: TelegramDate,
|
||||||
override val source: TransactionPartner?,
|
override val source: TransactionPartner?,
|
||||||
override val receiver: TransactionPartner?,
|
override val receiver: TransactionPartner?,
|
||||||
@@ -86,9 +86,9 @@ sealed interface StarTransaction : Amounted {
|
|||||||
private data class Surrogate(
|
private data class Surrogate(
|
||||||
val id: StarTransactionId,
|
val id: StarTransactionId,
|
||||||
val amount: Long,
|
val amount: Long,
|
||||||
@SerialName(nanostarAmountField)
|
|
||||||
val nanostarAmount: Int,
|
|
||||||
val date: TelegramDate,
|
val date: TelegramDate,
|
||||||
|
@SerialName(nanostarAmountField)
|
||||||
|
val nanostarAmount: Int? = null,
|
||||||
val source: TransactionPartner? = null,
|
val source: TransactionPartner? = null,
|
||||||
val receiver: TransactionPartner? = null,
|
val receiver: TransactionPartner? = null,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ package dev.inmo.tgbotapi.utils
|
|||||||
import dev.inmo.micro_utils.common.joinTo
|
import dev.inmo.micro_utils.common.joinTo
|
||||||
import dev.inmo.tgbotapi.types.BotCommand
|
import dev.inmo.tgbotapi.types.BotCommand
|
||||||
import dev.inmo.tgbotapi.types.CustomEmojiId
|
import dev.inmo.tgbotapi.types.CustomEmojiId
|
||||||
|
import dev.inmo.tgbotapi.types.UnixTimeStamp
|
||||||
import dev.inmo.tgbotapi.types.UserId
|
import dev.inmo.tgbotapi.types.UserId
|
||||||
import dev.inmo.tgbotapi.types.chat.User
|
import dev.inmo.tgbotapi.types.chat.User
|
||||||
import dev.inmo.tgbotapi.types.message.textsources.*
|
import dev.inmo.tgbotapi.types.message.textsources.*
|
||||||
@@ -654,6 +655,16 @@ inline fun EntitiesBuilder.link(url: String) = add(dev.inmo.tgbotapi.types.messa
|
|||||||
inline fun EntitiesBuilder.linkln(url: String) = link(url) + newLine
|
inline fun EntitiesBuilder.linkln(url: String) = link(url) + newLine
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add [DateTimeTextSource] using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.dateTimeTextSource]
|
||||||
|
*/
|
||||||
|
inline fun EntitiesBuilder.dateTime(text: String, unixTimeStamp: UnixTimeStamp, dateTimeFormat: String?) = add(dev.inmo.tgbotapi.types.message.textsources.dateTimeTextSource(text, unixTimeStamp, dateTimeFormat))
|
||||||
|
/**
|
||||||
|
* Version of [EntitiesBuilder.dateTime] with new line at the end
|
||||||
|
*/
|
||||||
|
inline fun EntitiesBuilder.dateTimeln(text: String, unixTimeStamp: UnixTimeStamp, dateTimeFormat: String?) = dateTime(text, unixTimeStamp, dateTimeFormat) + newLine
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add underline using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.underlineTextSource]
|
* Add underline using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.underlineTextSource]
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -99,6 +99,7 @@ fun <T : MediaGroupPartContent> List<PossiblySentViaBotCommonMessage<T>>.asMedia
|
|||||||
senderBoostsCount = sourceMessage.senderBoostsCount,
|
senderBoostsCount = sourceMessage.senderBoostsCount,
|
||||||
fromOffline = sourceMessage.fromOffline,
|
fromOffline = sourceMessage.fromOffline,
|
||||||
cost = sourceMessage.cost,
|
cost = sourceMessage.cost,
|
||||||
|
senderTag = sourceMessage.senderTag,
|
||||||
)
|
)
|
||||||
is ConnectedFromChannelGroupContentMessage -> ConnectedFromChannelGroupContentMessageImpl(
|
is ConnectedFromChannelGroupContentMessage -> ConnectedFromChannelGroupContentMessageImpl(
|
||||||
chat = sourceMessage.chat,
|
chat = sourceMessage.chat,
|
||||||
@@ -168,6 +169,7 @@ fun <T : MediaGroupPartContent> List<PossiblySentViaBotCommonMessage<T>>.asMedia
|
|||||||
senderBoostsCount = sourceMessage.senderBoostsCount,
|
senderBoostsCount = sourceMessage.senderBoostsCount,
|
||||||
fromOffline = sourceMessage.fromOffline,
|
fromOffline = sourceMessage.fromOffline,
|
||||||
cost = sourceMessage.cost,
|
cost = sourceMessage.cost,
|
||||||
|
senderTag = sourceMessage.senderTag,
|
||||||
)
|
)
|
||||||
is CommonChannelDirectMessagesContentMessage -> CommonChannelDirectMessagesContentMessageImpl(
|
is CommonChannelDirectMessagesContentMessage -> CommonChannelDirectMessagesContentMessageImpl(
|
||||||
chat = sourceMessage.chat,
|
chat = sourceMessage.chat,
|
||||||
@@ -186,6 +188,7 @@ fun <T : MediaGroupPartContent> List<PossiblySentViaBotCommonMessage<T>>.asMedia
|
|||||||
senderBoostsCount = sourceMessage.senderBoostsCount,
|
senderBoostsCount = sourceMessage.senderBoostsCount,
|
||||||
fromOffline = sourceMessage.fromOffline,
|
fromOffline = sourceMessage.fromOffline,
|
||||||
cost = sourceMessage.cost,
|
cost = sourceMessage.cost,
|
||||||
|
senderTag = sourceMessage.senderTag,
|
||||||
)
|
)
|
||||||
is FromChannelForumContentMessage -> FromChannelForumContentMessageImpl(
|
is FromChannelForumContentMessage -> FromChannelForumContentMessageImpl(
|
||||||
chat = sourceMessage.chat,
|
chat = sourceMessage.chat,
|
||||||
@@ -243,6 +246,7 @@ fun <T : MediaGroupPartContent> List<PossiblySentViaBotCommonMessage<T>>.asMedia
|
|||||||
fromOffline = sourceMessage.fromOffline,
|
fromOffline = sourceMessage.fromOffline,
|
||||||
suggestedPostInfo = sourceMessage.suggestedPostInfo,
|
suggestedPostInfo = sourceMessage.suggestedPostInfo,
|
||||||
cost = sourceMessage.cost,
|
cost = sourceMessage.cost,
|
||||||
|
senderTag = sourceMessage.senderTag,
|
||||||
)
|
)
|
||||||
is FromChannelSuggestedChannelDirectMessagesContentMessage<*> -> FromChannelSuggestedChannelDirectMessagesContentMessageImpl(
|
is FromChannelSuggestedChannelDirectMessagesContentMessage<*> -> FromChannelSuggestedChannelDirectMessagesContentMessageImpl(
|
||||||
chat = sourceMessage.chat,
|
chat = sourceMessage.chat,
|
||||||
|
|||||||
@@ -50,6 +50,10 @@ internal fun String.linkMarkdown(link: String): String = "[${toMarkdown()}](${li
|
|||||||
internal fun String.linkMarkdownV2(link: String): String = "[${escapeMarkdownV2Common()}](${link.escapeMarkdownV2Link()})"
|
internal fun String.linkMarkdownV2(link: String): String = "[${escapeMarkdownV2Common()}](${link.escapeMarkdownV2Link()})"
|
||||||
internal fun String.linkHTML(link: String): String = "<a href=\"$link\">${toHtml()}</a>"
|
internal fun String.linkHTML(link: String): String = "<a href=\"$link\">${toHtml()}</a>"
|
||||||
|
|
||||||
|
internal fun String.dateTimeMarkdown(unixTimeStamp: UnixTimeStamp, dateTimeFormat: String?): String = "}" } ?: ""})"
|
||||||
|
internal fun String.dateTimeMarkdownV2(unixTimeStamp: UnixTimeStamp, dateTimeFormat: String?): String = "}" } ?: ""})"
|
||||||
|
internal fun String.dateTimeHTML(unixTimeStamp: UnixTimeStamp, dateTimeFormat: String?): String = "<tg-time unix=\"$unixTimeStamp\"${dateTimeFormat?.let { " format=\"$dateTimeFormat\"" } ?: ""}>${toHtml()}</tg-time>"
|
||||||
|
|
||||||
internal fun String.boldMarkdown(): String = markdownDefault(markdownBoldControl)
|
internal fun String.boldMarkdown(): String = markdownDefault(markdownBoldControl)
|
||||||
|
|
||||||
internal fun String.blockquoteMarkdown(): String = regularMarkdown()
|
internal fun String.blockquoteMarkdown(): String = regularMarkdown()
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package dev.inmo.tgbotapi.utils.serializers
|
||||||
|
|
||||||
|
import kotlinx.serialization.KSerializer
|
||||||
|
import kotlinx.serialization.builtins.serializer
|
||||||
|
import kotlinx.serialization.descriptors.SerialDescriptor
|
||||||
|
import kotlinx.serialization.encoding.Decoder
|
||||||
|
import kotlinx.serialization.encoding.Encoder
|
||||||
|
|
||||||
|
object UnitFromBooleanSerializer : KSerializer<Unit> {
|
||||||
|
override val descriptor: SerialDescriptor
|
||||||
|
get() = Boolean.serializer().descriptor
|
||||||
|
|
||||||
|
override fun serialize(encoder: Encoder, value: Unit) {
|
||||||
|
encoder.encodeBoolean(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun deserialize(decoder: Decoder) {
|
||||||
|
return if (decoder.decodeBoolean()) {
|
||||||
|
Unit
|
||||||
|
} else {
|
||||||
|
throw IllegalStateException("Can't deserialize Unit from false")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,105 @@
|
|||||||
|
package dev.inmo.tgbotapi.types.message.textsources
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.types.message.RawMessageEntity
|
||||||
|
import dev.inmo.tgbotapi.types.message.asTextSources
|
||||||
|
import dev.inmo.tgbotapi.types.message.toRawMessageEntities
|
||||||
|
import dev.inmo.tgbotapi.utils.buildEntities
|
||||||
|
import dev.inmo.tgbotapi.utils.dateTime
|
||||||
|
import kotlin.test.*
|
||||||
|
|
||||||
|
class DateTimeTextSourceTests {
|
||||||
|
@Test
|
||||||
|
fun testDateTimeTextSourceFormatting() {
|
||||||
|
val unix = 1714560000L
|
||||||
|
val format = "r"
|
||||||
|
val text = "some date"
|
||||||
|
val source = DateTimeTextSource(text, unix, format)
|
||||||
|
|
||||||
|
assertEquals("", source.markdown)
|
||||||
|
assertEquals("", source.markdownV2)
|
||||||
|
assertEquals("<tg-time unix=\"$unix\" format=\"$format\">$text</tg-time>", source.html)
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
fun testDateTimeTextSourceFormattingWithoutFormat() {
|
||||||
|
val unix = 1714560000L
|
||||||
|
val format = null
|
||||||
|
val text = "some date"
|
||||||
|
val source = DateTimeTextSource(text, unix, format)
|
||||||
|
|
||||||
|
assertEquals("", source.markdown)
|
||||||
|
assertEquals("", source.markdownV2)
|
||||||
|
assertEquals("<tg-time unix=\"$unix\">$text</tg-time>", source.html)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testDateTimeTextSourceInRawMessageEntity() {
|
||||||
|
val sourceText = "date: 2024-05-01"
|
||||||
|
val unix = 1714560000L
|
||||||
|
val format = "wd"
|
||||||
|
val entities = listOf(
|
||||||
|
RawMessageEntity("date_time", 6, 10, unix_time = unix, date_time_format = format)
|
||||||
|
)
|
||||||
|
val textSources = entities.asTextSources(sourceText)
|
||||||
|
|
||||||
|
assertEquals(2, textSources.size)
|
||||||
|
assertTrue(textSources[0] is RegularTextSource)
|
||||||
|
assertTrue(textSources[1] is DateTimeTextSource)
|
||||||
|
|
||||||
|
val dateTimeSource = textSources[1] as DateTimeTextSource
|
||||||
|
assertEquals("2024-05-01", dateTimeSource.source)
|
||||||
|
assertEquals(unix, dateTimeSource.unixTimeStamp)
|
||||||
|
assertEquals(format, dateTimeSource.dateTimeFormat)
|
||||||
|
|
||||||
|
val backToEntities = dateTimeSource.toRawMessageEntities(6)
|
||||||
|
assertEquals(1, backToEntities.size)
|
||||||
|
val entity = backToEntities[0]
|
||||||
|
assertEquals("date_time", entity.type)
|
||||||
|
assertEquals(6, entity.offset)
|
||||||
|
assertEquals(10, entity.length)
|
||||||
|
assertEquals(unix, entity.unix_time)
|
||||||
|
assertEquals(format, entity.date_time_format)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testDateTimeTextSourceInRawMessageEntityWithNullFormat() {
|
||||||
|
val sourceText = "date: 2024-05-01"
|
||||||
|
val unix = 1714560000L
|
||||||
|
val format = null
|
||||||
|
val entities = listOf(
|
||||||
|
RawMessageEntity("date_time", 6, 10, unix_time = unix, date_time_format = format)
|
||||||
|
)
|
||||||
|
val textSources = entities.asTextSources(sourceText)
|
||||||
|
|
||||||
|
assertEquals(2, textSources.size)
|
||||||
|
assertTrue(textSources[0] is RegularTextSource)
|
||||||
|
assertTrue(textSources[1] is DateTimeTextSource)
|
||||||
|
|
||||||
|
val dateTimeSource = textSources[1] as DateTimeTextSource
|
||||||
|
assertEquals("2024-05-01", dateTimeSource.source)
|
||||||
|
assertEquals(unix, dateTimeSource.unixTimeStamp)
|
||||||
|
assertEquals(format, dateTimeSource.dateTimeFormat)
|
||||||
|
|
||||||
|
val backToEntities = dateTimeSource.toRawMessageEntities(6)
|
||||||
|
assertEquals(1, backToEntities.size)
|
||||||
|
val entity = backToEntities[0]
|
||||||
|
assertEquals("date_time", entity.type)
|
||||||
|
assertEquals(6, entity.offset)
|
||||||
|
assertEquals(10, entity.length)
|
||||||
|
assertEquals(unix, entity.unix_time)
|
||||||
|
assertEquals(format, entity.date_time_format)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testDateTimeInEntitiesBuilder() {
|
||||||
|
val unix = 1714560000L
|
||||||
|
val format = "D"
|
||||||
|
val sources = buildEntities {
|
||||||
|
dateTime("today", unix, format)
|
||||||
|
}
|
||||||
|
assertEquals(1, sources.size)
|
||||||
|
val source = sources[0] as DateTimeTextSource
|
||||||
|
assertEquals("today", source.source)
|
||||||
|
assertEquals(unix, source.unixTimeStamp)
|
||||||
|
assertEquals(format, source.dateTimeFormat)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -71,6 +71,7 @@ public final class dev/inmo/tgbotapi/extensions/utils/ClassCastsKt {
|
|||||||
public static final fun asCustomDiceAnimationType (Ldev/inmo/tgbotapi/types/dice/DiceAnimationType;)Ldev/inmo/tgbotapi/types/dice/CustomDiceAnimationType;
|
public static final fun asCustomDiceAnimationType (Ldev/inmo/tgbotapi/types/dice/DiceAnimationType;)Ldev/inmo/tgbotapi/types/dice/CustomDiceAnimationType;
|
||||||
public static final fun asDartsDiceAnimationType (Ldev/inmo/tgbotapi/types/dice/DiceAnimationType;)Ldev/inmo/tgbotapi/types/dice/DartsDiceAnimationType;
|
public static final fun asDartsDiceAnimationType (Ldev/inmo/tgbotapi/types/dice/DiceAnimationType;)Ldev/inmo/tgbotapi/types/dice/DartsDiceAnimationType;
|
||||||
public static final fun asDataCallbackQuery (Ldev/inmo/tgbotapi/types/queries/callback/CallbackQuery;)Ldev/inmo/tgbotapi/types/queries/callback/DataCallbackQuery;
|
public static final fun asDataCallbackQuery (Ldev/inmo/tgbotapi/types/queries/callback/CallbackQuery;)Ldev/inmo/tgbotapi/types/queries/callback/DataCallbackQuery;
|
||||||
|
public static final fun asDateTimeTextSource (Ldev/inmo/tgbotapi/types/message/textsources/TextSource;)Ldev/inmo/tgbotapi/types/message/textsources/DateTimeTextSource;
|
||||||
public static final fun asDeleteChatPhoto (Ldev/inmo/tgbotapi/types/message/ChatEvents/abstracts/ChatEvent;)Ldev/inmo/tgbotapi/types/message/ChatEvents/DeleteChatPhoto;
|
public static final fun asDeleteChatPhoto (Ldev/inmo/tgbotapi/types/message/ChatEvents/abstracts/ChatEvent;)Ldev/inmo/tgbotapi/types/message/ChatEvents/DeleteChatPhoto;
|
||||||
public static final fun asDescribedInlineQueryResult (Ldev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/InlineQueryResult;)Ldev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/DescribedInlineQueryResult;
|
public static final fun asDescribedInlineQueryResult (Ldev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/InlineQueryResult;)Ldev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/DescribedInlineQueryResult;
|
||||||
public static final fun asDiceContent (Ldev/inmo/tgbotapi/types/message/content/ResendableContent;)Ldev/inmo/tgbotapi/types/message/content/DiceContent;
|
public static final fun asDiceContent (Ldev/inmo/tgbotapi/types/message/content/ResendableContent;)Ldev/inmo/tgbotapi/types/message/content/DiceContent;
|
||||||
@@ -416,6 +417,7 @@ public final class dev/inmo/tgbotapi/extensions/utils/ClassCastsKt {
|
|||||||
public static final fun requireCustomDiceAnimationType (Ldev/inmo/tgbotapi/types/dice/DiceAnimationType;)Ldev/inmo/tgbotapi/types/dice/CustomDiceAnimationType;
|
public static final fun requireCustomDiceAnimationType (Ldev/inmo/tgbotapi/types/dice/DiceAnimationType;)Ldev/inmo/tgbotapi/types/dice/CustomDiceAnimationType;
|
||||||
public static final fun requireDartsDiceAnimationType (Ldev/inmo/tgbotapi/types/dice/DiceAnimationType;)Ldev/inmo/tgbotapi/types/dice/DartsDiceAnimationType;
|
public static final fun requireDartsDiceAnimationType (Ldev/inmo/tgbotapi/types/dice/DiceAnimationType;)Ldev/inmo/tgbotapi/types/dice/DartsDiceAnimationType;
|
||||||
public static final fun requireDataCallbackQuery (Ldev/inmo/tgbotapi/types/queries/callback/CallbackQuery;)Ldev/inmo/tgbotapi/types/queries/callback/DataCallbackQuery;
|
public static final fun requireDataCallbackQuery (Ldev/inmo/tgbotapi/types/queries/callback/CallbackQuery;)Ldev/inmo/tgbotapi/types/queries/callback/DataCallbackQuery;
|
||||||
|
public static final fun requireDateTimeTextSource (Ldev/inmo/tgbotapi/types/message/textsources/TextSource;)Ldev/inmo/tgbotapi/types/message/textsources/DateTimeTextSource;
|
||||||
public static final fun requireDeleteChatPhoto (Ldev/inmo/tgbotapi/types/message/ChatEvents/abstracts/ChatEvent;)Ldev/inmo/tgbotapi/types/message/ChatEvents/DeleteChatPhoto;
|
public static final fun requireDeleteChatPhoto (Ldev/inmo/tgbotapi/types/message/ChatEvents/abstracts/ChatEvent;)Ldev/inmo/tgbotapi/types/message/ChatEvents/DeleteChatPhoto;
|
||||||
public static final fun requireDescribedInlineQueryResult (Ldev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/InlineQueryResult;)Ldev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/DescribedInlineQueryResult;
|
public static final fun requireDescribedInlineQueryResult (Ldev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/InlineQueryResult;)Ldev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/DescribedInlineQueryResult;
|
||||||
public static final fun requireDiceContent (Ldev/inmo/tgbotapi/types/message/content/ResendableContent;)Ldev/inmo/tgbotapi/types/message/content/DiceContent;
|
public static final fun requireDiceContent (Ldev/inmo/tgbotapi/types/message/content/ResendableContent;)Ldev/inmo/tgbotapi/types/message/content/DiceContent;
|
||||||
@@ -761,6 +763,7 @@ public final class dev/inmo/tgbotapi/extensions/utils/ClassCastsKt {
|
|||||||
public static final fun whenCustomDiceAnimationType (Ldev/inmo/tgbotapi/types/dice/DiceAnimationType;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
|
public static final fun whenCustomDiceAnimationType (Ldev/inmo/tgbotapi/types/dice/DiceAnimationType;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
|
||||||
public static final fun whenDartsDiceAnimationType (Ldev/inmo/tgbotapi/types/dice/DiceAnimationType;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
|
public static final fun whenDartsDiceAnimationType (Ldev/inmo/tgbotapi/types/dice/DiceAnimationType;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
|
||||||
public static final fun whenDataCallbackQuery (Ldev/inmo/tgbotapi/types/queries/callback/CallbackQuery;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
|
public static final fun whenDataCallbackQuery (Ldev/inmo/tgbotapi/types/queries/callback/CallbackQuery;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
|
||||||
|
public static final fun whenDateTimeTextSource (Ldev/inmo/tgbotapi/types/message/textsources/TextSource;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
|
||||||
public static final fun whenDeleteChatPhoto (Ldev/inmo/tgbotapi/types/message/ChatEvents/abstracts/ChatEvent;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
|
public static final fun whenDeleteChatPhoto (Ldev/inmo/tgbotapi/types/message/ChatEvents/abstracts/ChatEvent;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
|
||||||
public static final fun whenDescribedInlineQueryResult (Ldev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/InlineQueryResult;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
|
public static final fun whenDescribedInlineQueryResult (Ldev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/InlineQueryResult;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
|
||||||
public static final fun whenDiceContent (Ldev/inmo/tgbotapi/types/message/content/ResendableContent;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
|
public static final fun whenDiceContent (Ldev/inmo/tgbotapi/types/message/content/ResendableContent;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
|
||||||
@@ -1337,6 +1340,8 @@ public final class dev/inmo/tgbotapi/extensions/utils/ClassCastsNewKt {
|
|||||||
public static final fun dartsDiceAnimationTypeOrThrow (Ldev/inmo/tgbotapi/types/dice/DiceAnimationType;)Ldev/inmo/tgbotapi/types/dice/DartsDiceAnimationType;
|
public static final fun dartsDiceAnimationTypeOrThrow (Ldev/inmo/tgbotapi/types/dice/DiceAnimationType;)Ldev/inmo/tgbotapi/types/dice/DartsDiceAnimationType;
|
||||||
public static final fun dataCallbackQueryOrNull (Ldev/inmo/tgbotapi/abstracts/OptionallyWithUser;)Ldev/inmo/tgbotapi/types/queries/callback/DataCallbackQuery;
|
public static final fun dataCallbackQueryOrNull (Ldev/inmo/tgbotapi/abstracts/OptionallyWithUser;)Ldev/inmo/tgbotapi/types/queries/callback/DataCallbackQuery;
|
||||||
public static final fun dataCallbackQueryOrThrow (Ldev/inmo/tgbotapi/abstracts/OptionallyWithUser;)Ldev/inmo/tgbotapi/types/queries/callback/DataCallbackQuery;
|
public static final fun dataCallbackQueryOrThrow (Ldev/inmo/tgbotapi/abstracts/OptionallyWithUser;)Ldev/inmo/tgbotapi/types/queries/callback/DataCallbackQuery;
|
||||||
|
public static final fun dateTimeTextSourceOrNull (Ldev/inmo/tgbotapi/types/message/textsources/TextSource;)Ldev/inmo/tgbotapi/types/message/textsources/DateTimeTextSource;
|
||||||
|
public static final fun dateTimeTextSourceOrThrow (Ldev/inmo/tgbotapi/types/message/textsources/TextSource;)Ldev/inmo/tgbotapi/types/message/textsources/DateTimeTextSource;
|
||||||
public static final fun deleteChatPhotoOrNull (Ldev/inmo/tgbotapi/types/message/ChatEvents/abstracts/ChatEvent;)Ldev/inmo/tgbotapi/types/message/ChatEvents/DeleteChatPhoto;
|
public static final fun deleteChatPhotoOrNull (Ldev/inmo/tgbotapi/types/message/ChatEvents/abstracts/ChatEvent;)Ldev/inmo/tgbotapi/types/message/ChatEvents/DeleteChatPhoto;
|
||||||
public static final fun deleteChatPhotoOrThrow (Ldev/inmo/tgbotapi/types/message/ChatEvents/abstracts/ChatEvent;)Ldev/inmo/tgbotapi/types/message/ChatEvents/DeleteChatPhoto;
|
public static final fun deleteChatPhotoOrThrow (Ldev/inmo/tgbotapi/types/message/ChatEvents/abstracts/ChatEvent;)Ldev/inmo/tgbotapi/types/message/ChatEvents/DeleteChatPhoto;
|
||||||
public static final fun deletedBusinessMessageUpdateOrNull (Ldev/inmo/tgbotapi/types/update/abstracts/Update;)Ldev/inmo/tgbotapi/types/update/DeletedBusinessMessageUpdate;
|
public static final fun deletedBusinessMessageUpdateOrNull (Ldev/inmo/tgbotapi/types/update/abstracts/Update;)Ldev/inmo/tgbotapi/types/update/DeletedBusinessMessageUpdate;
|
||||||
@@ -1710,6 +1715,7 @@ public final class dev/inmo/tgbotapi/extensions/utils/ClassCastsNewKt {
|
|||||||
public static final fun ifCustomEmojiVideoSticker (Ldev/inmo/tgbotapi/types/files/TelegramMediaFile;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
|
public static final fun ifCustomEmojiVideoSticker (Ldev/inmo/tgbotapi/types/files/TelegramMediaFile;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
|
||||||
public static final fun ifDartsDiceAnimationType (Ldev/inmo/tgbotapi/types/dice/DiceAnimationType;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
|
public static final fun ifDartsDiceAnimationType (Ldev/inmo/tgbotapi/types/dice/DiceAnimationType;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
|
||||||
public static final fun ifDataCallbackQuery (Ldev/inmo/tgbotapi/abstracts/OptionallyWithUser;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
|
public static final fun ifDataCallbackQuery (Ldev/inmo/tgbotapi/abstracts/OptionallyWithUser;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
|
||||||
|
public static final fun ifDateTimeTextSource (Ldev/inmo/tgbotapi/types/message/textsources/TextSource;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
|
||||||
public static final fun ifDeleteChatPhoto (Ldev/inmo/tgbotapi/types/message/ChatEvents/abstracts/ChatEvent;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
|
public static final fun ifDeleteChatPhoto (Ldev/inmo/tgbotapi/types/message/ChatEvents/abstracts/ChatEvent;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
|
||||||
public static final fun ifDeletedBusinessMessageUpdate (Ldev/inmo/tgbotapi/types/update/abstracts/Update;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
|
public static final fun ifDeletedBusinessMessageUpdate (Ldev/inmo/tgbotapi/types/update/abstracts/Update;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
|
||||||
public static final fun ifDescribedInlineQueryResult (Ldev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/InlineQueryResult;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
|
public static final fun ifDescribedInlineQueryResult (Ldev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/InlineQueryResult;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
|
||||||
@@ -3159,6 +3165,7 @@ public final class dev/inmo/tgbotapi/extensions/utils/extensions/raw/MessageKt {
|
|||||||
public static final fun getReply_markup (Ldev/inmo/tgbotapi/types/message/abstracts/Message;)Ldev/inmo/tgbotapi/types/buttons/InlineKeyboardMarkup;
|
public static final fun getReply_markup (Ldev/inmo/tgbotapi/types/message/abstracts/Message;)Ldev/inmo/tgbotapi/types/buttons/InlineKeyboardMarkup;
|
||||||
public static final fun getReply_to_message (Ldev/inmo/tgbotapi/types/message/abstracts/Message;)Ldev/inmo/tgbotapi/types/message/abstracts/Message;
|
public static final fun getReply_to_message (Ldev/inmo/tgbotapi/types/message/abstracts/Message;)Ldev/inmo/tgbotapi/types/message/abstracts/Message;
|
||||||
public static final fun getSender_chat (Ldev/inmo/tgbotapi/types/message/abstracts/Message;)Ldev/inmo/tgbotapi/types/chat/PreviewChat;
|
public static final fun getSender_chat (Ldev/inmo/tgbotapi/types/message/abstracts/Message;)Ldev/inmo/tgbotapi/types/chat/PreviewChat;
|
||||||
|
public static final fun getSender_tag (Ldev/inmo/tgbotapi/types/message/abstracts/Message;)Ljava/lang/String;
|
||||||
public static final fun getSticker (Ldev/inmo/tgbotapi/types/message/abstracts/Message;)Ldev/inmo/tgbotapi/types/files/Sticker;
|
public static final fun getSticker (Ldev/inmo/tgbotapi/types/message/abstracts/Message;)Ldev/inmo/tgbotapi/types/files/Sticker;
|
||||||
public static final fun getSuccessful_payment (Ldev/inmo/tgbotapi/types/message/abstracts/Message;)Ldev/inmo/tgbotapi/types/payments/SuccessfulPayment;
|
public static final fun getSuccessful_payment (Ldev/inmo/tgbotapi/types/message/abstracts/Message;)Ldev/inmo/tgbotapi/types/payments/SuccessfulPayment;
|
||||||
public static final fun getSupergroup_chat_created (Ldev/inmo/tgbotapi/types/message/abstracts/Message;)Z
|
public static final fun getSupergroup_chat_created (Ldev/inmo/tgbotapi/types/message/abstracts/Message;)Z
|
||||||
|
|||||||
@@ -3036,6 +3036,15 @@ inline fun TextSource.asTextMentionTextSource(): TextMentionTextSource? = this a
|
|||||||
@PreviewFeature
|
@PreviewFeature
|
||||||
inline fun TextSource.requireTextMentionTextSource(): TextMentionTextSource = this as TextMentionTextSource
|
inline fun TextSource.requireTextMentionTextSource(): TextMentionTextSource = this as TextMentionTextSource
|
||||||
|
|
||||||
|
@PreviewFeature
|
||||||
|
inline fun <T> TextSource.whenDateTimeTextSource(block: (DateTimeTextSource) -> T) = asDateTimeTextSource()?.let(block)
|
||||||
|
|
||||||
|
@PreviewFeature
|
||||||
|
inline fun TextSource.asDateTimeTextSource(): DateTimeTextSource? = this as? DateTimeTextSource
|
||||||
|
|
||||||
|
@PreviewFeature
|
||||||
|
inline fun TextSource.requireDateTimeTextSource(): DateTimeTextSource = this as DateTimeTextSource
|
||||||
|
|
||||||
@PreviewFeature
|
@PreviewFeature
|
||||||
inline fun <T> TextSource.whenURLTextSource(block: (URLTextSource) -> T) = asURLTextSource()?.let(block)
|
inline fun <T> TextSource.whenURLTextSource(block: (URLTextSource) -> T) = asURLTextSource()?.let(block)
|
||||||
|
|
||||||
|
|||||||
@@ -402,6 +402,7 @@ import dev.inmo.tgbotapi.types.message.textsources.BotCommandTextSource
|
|||||||
import dev.inmo.tgbotapi.types.message.textsources.CashTagTextSource
|
import dev.inmo.tgbotapi.types.message.textsources.CashTagTextSource
|
||||||
import dev.inmo.tgbotapi.types.message.textsources.CodeTextSource
|
import dev.inmo.tgbotapi.types.message.textsources.CodeTextSource
|
||||||
import dev.inmo.tgbotapi.types.message.textsources.CustomEmojiTextSource
|
import dev.inmo.tgbotapi.types.message.textsources.CustomEmojiTextSource
|
||||||
|
import dev.inmo.tgbotapi.types.message.textsources.DateTimeTextSource
|
||||||
import dev.inmo.tgbotapi.types.message.textsources.EMailTextSource
|
import dev.inmo.tgbotapi.types.message.textsources.EMailTextSource
|
||||||
import dev.inmo.tgbotapi.types.message.textsources.ExpandableBlockquoteTextSource
|
import dev.inmo.tgbotapi.types.message.textsources.ExpandableBlockquoteTextSource
|
||||||
import dev.inmo.tgbotapi.types.message.textsources.HashTagTextSource
|
import dev.inmo.tgbotapi.types.message.textsources.HashTagTextSource
|
||||||
@@ -2805,6 +2806,12 @@ public inline fun TextSource.italicTextSourceOrThrow(): ItalicTextSource = this
|
|||||||
|
|
||||||
public inline fun <T> TextSource.ifItalicTextSource(block: (ItalicTextSource) -> T): T? = italicTextSourceOrNull() ?.let(block)
|
public inline fun <T> TextSource.ifItalicTextSource(block: (ItalicTextSource) -> T): T? = italicTextSourceOrNull() ?.let(block)
|
||||||
|
|
||||||
|
public inline fun TextSource.dateTimeTextSourceOrNull(): DateTimeTextSource? = this as? dev.inmo.tgbotapi.types.message.textsources.DateTimeTextSource
|
||||||
|
|
||||||
|
public inline fun TextSource.dateTimeTextSourceOrThrow(): DateTimeTextSource = this as dev.inmo.tgbotapi.types.message.textsources.DateTimeTextSource
|
||||||
|
|
||||||
|
public inline fun <T> TextSource.ifDateTimeTextSource(block: (DateTimeTextSource) -> T): T? = dateTimeTextSourceOrNull() ?.let(block)
|
||||||
|
|
||||||
public inline fun TextSource.textMentionTextSourceOrNull(): TextMentionTextSource? = this as? dev.inmo.tgbotapi.types.message.textsources.TextMentionTextSource
|
public inline fun TextSource.textMentionTextSourceOrNull(): TextMentionTextSource? = this as? dev.inmo.tgbotapi.types.message.textsources.TextMentionTextSource
|
||||||
|
|
||||||
public inline fun TextSource.textMentionTextSourceOrThrow(): TextMentionTextSource = this as dev.inmo.tgbotapi.types.message.textsources.TextMentionTextSource
|
public inline fun TextSource.textMentionTextSourceOrThrow(): TextMentionTextSource = this as dev.inmo.tgbotapi.types.message.textsources.TextMentionTextSource
|
||||||
|
|||||||
@@ -28,6 +28,9 @@ inline val Message.from: User?
|
|||||||
inline val Message.sender_chat: PreviewChat?
|
inline val Message.sender_chat: PreviewChat?
|
||||||
get() = withSenderChatMessageOrNull() ?.senderChat
|
get() = withSenderChatMessageOrNull() ?.senderChat
|
||||||
@RiskFeature(RawFieldsUsageWarning)
|
@RiskFeature(RawFieldsUsageWarning)
|
||||||
|
inline val Message.sender_tag: UserTag?
|
||||||
|
get() = potentiallyFromUserGroupContentMessageOrNull() ?.senderTag
|
||||||
|
@RiskFeature(RawFieldsUsageWarning)
|
||||||
inline val Message.forward_from: User?
|
inline val Message.forward_from: User?
|
||||||
get() = asPossiblyForwardedMessage() ?.forwardInfo ?.asUserForwardInfo() ?.from
|
get() = asPossiblyForwardedMessage() ?.forwardInfo ?.asUserForwardInfo() ?.from
|
||||||
@RiskFeature(RawFieldsUsageWarning)
|
@RiskFeature(RawFieldsUsageWarning)
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
package dev.inmo.tgbotapi.webapps
|
package dev.inmo.tgbotapi.webapps
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.types.CustomEmojiId
|
||||||
import kotlin.js.Json
|
import kotlin.js.Json
|
||||||
import kotlin.js.json
|
import kotlin.js.json
|
||||||
|
|
||||||
external class BottomButton {
|
external class BottomButton {
|
||||||
|
|
||||||
val text: String
|
val text: String
|
||||||
|
val iconCustomEmojiId: CustomEmojiId?
|
||||||
fun setText(text: String): BottomButton
|
fun setText(text: String): BottomButton
|
||||||
|
|
||||||
var color: String
|
var color: String
|
||||||
@@ -32,6 +35,7 @@ external class BottomButton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
data class BottomButtonParams(
|
data class BottomButtonParams(
|
||||||
|
val iconCustomEmojiId: CustomEmojiId? = null,
|
||||||
val text: String? = null,
|
val text: String? = null,
|
||||||
val color: String? = null,
|
val color: String? = null,
|
||||||
val textColor: String? = null,
|
val textColor: String? = null,
|
||||||
@@ -42,6 +46,7 @@ data class BottomButtonParams(
|
|||||||
fun BottomButton.setParams(params: BottomButtonParams) = setParams(
|
fun BottomButton.setParams(params: BottomButtonParams) = setParams(
|
||||||
json(
|
json(
|
||||||
*listOfNotNull(
|
*listOfNotNull(
|
||||||
|
params.iconCustomEmojiId ?.let { "icon_custom_emoji_id" to params.iconCustomEmojiId },
|
||||||
params.text ?.let { "text" to params.text },
|
params.text ?.let { "text" to params.text },
|
||||||
params.color ?.let { "color" to params.color },
|
params.color ?.let { "color" to params.color },
|
||||||
params.textColor ?.let { "text_color" to params.textColor },
|
params.textColor ?.let { "text_color" to params.textColor },
|
||||||
|
|||||||
Reference in New Issue
Block a user