mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-11-18 13:00:18 +00:00
Compare commits
105 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 33d8dcf977 | |||
| 2f09504f08 | |||
| f4c11cacc6 | |||
| 4ac01d5331 | |||
| bb3ebb455e | |||
| 7694b25d33 | |||
| b095f07b9c | |||
| 72127ce133 | |||
| 398adf06ff | |||
| dbef69ffac | |||
| f68edebd24 | |||
| 482d924070 | |||
| e7495468a2 | |||
| bba37d8889 | |||
| 198e15a937 | |||
| 5ee472305c | |||
| 47428dd6f9 | |||
| b4e4bed622 | |||
| 4dd2a8437c | |||
| 8b93922f82 | |||
| 43b08e9319 | |||
| 62d474b7cc | |||
| 0066e814b3 | |||
| ef7e94ba68 | |||
| 27aba72a5a | |||
| 680e960037 | |||
| ff47168fdc | |||
| a68c31f9d1 | |||
| ac915b79f7 | |||
| 1659f6f909 | |||
| 5249fb517f | |||
| fdf45d7566 | |||
| dc93997b8c | |||
| 6dd701d33c | |||
| 6f1f5e640a | |||
| dd0e3c04bc | |||
| a17af67f83 | |||
| 761e08afc6 | |||
| a09af8870a | |||
| 0ef4341baf | |||
| 91d8fbb232 | |||
| 0c1df47dbb | |||
| b582adc3a0 | |||
| 7660102435 | |||
| 5dbfeca18f | |||
| f3fc0769ef | |||
| 24d11d2c2b | |||
| 498efc2ec3 | |||
| 21544013d9 | |||
| e296c2ee00 | |||
| ed60dc49e7 | |||
| c1b5b3ca19 | |||
| 24498479a8 | |||
| cb64f44ceb | |||
| ba145d3ff8 | |||
| f57bfb017f | |||
| 8b36767435 | |||
| 91ab60d1f5 | |||
| 88208016d4 | |||
| fec2ef8b30 | |||
| 7bc06eae31 | |||
| 128e69e3e3 | |||
| 6c5fc8144b | |||
| 73f5bf7e4b | |||
| 17c10a2975 | |||
| c6638f3102 | |||
| f86ae2b592 | |||
| 84eb2fac7c | |||
| bf8096ece2 | |||
| 2ee5d78362 | |||
| 704457715d | |||
| 44751d94b3 | |||
| 2530b85400 | |||
| 49cbcea405 | |||
| 0312c57741 | |||
| e7af08142b | |||
| 3285b2812e | |||
| 402e1b12dc | |||
| 41c5ba7309 | |||
| 617bccaa81 | |||
| c7a8bc5c9d | |||
| 56f36523db | |||
| 8330aa1b3d | |||
| fc0dcae4be | |||
| 861254fe64 | |||
| 790885fd0d | |||
| a7e533d94e | |||
| 7f7e82bbb0 | |||
| 647d1e79f7 | |||
| 9e469c7825 | |||
| 7e61b77ffe | |||
| 1f62c8cf98 | |||
| d6bb14e342 | |||
| c47c82ac43 | |||
| 8fbda09d24 | |||
| 6310dceacf | |||
| 394bec1805 | |||
| cb94a3a389 | |||
| 84ad751792 | |||
| d8887bb7ff | |||
| 4dba67979d | |||
| 8b6947231f | |||
| 76bbe2a064 | |||
| 26d001acce | |||
| 46a4e7ea27 |
154
CHANGELOG.md
154
CHANGELOG.md
@@ -1,5 +1,159 @@
|
|||||||
# TelegramBotAPI changelog
|
# TelegramBotAPI changelog
|
||||||
|
|
||||||
|
## 0.21.0 TelegramBotAPI 4.5
|
||||||
|
|
||||||
|
* _**All `MessageEntity`'es now are replaced with `TextPart`**_
|
||||||
|
* Added support of strikethrough and underline
|
||||||
|
* Added `UnderlineTextSource`
|
||||||
|
* Added `StrikethroughTextSource`
|
||||||
|
* Added support in `RawMessageEntity`
|
||||||
|
* Added support of `MarkdownV2`
|
||||||
|
* Now will not be thrown exception when there is income unknown type of `RawMessageEntity`. Instead of this will be
|
||||||
|
created `RegularTextSource` with the same text
|
||||||
|
* Fixed problem that usually string formatting did not trigger escaping of control characters
|
||||||
|
* Actualized work with `pre` type of text - now it is possible to use `language` for formatting of text
|
||||||
|
* Removed constructor of `TextMentionTextSource`, which was deprecated previously
|
||||||
|
* All `TelegramMediaFile` instances now have field `fileUniqueId`, which represents `file_unique_id` field from API
|
||||||
|
* Now `ChatPhoto` have two additional fields: `smallFileUniqueId` and `bigFileUniqueId`
|
||||||
|
* Now any administrator object instance have `customTitle` nullable field
|
||||||
|
* Added the new request `SetChatAdministratorCustomTitle` to manage the custom titles of administrators promoted by the
|
||||||
|
bot.
|
||||||
|
* Added the field `slowModeDelay` to the `ExtendedSupergroupChat` objects.
|
||||||
|
|
||||||
|
* `CaptionedInput` now have extension `fullEntitiesList` which will return list of `TextPart` with `RegularSource`'s
|
||||||
|
* `TextPart` added - it will be used as part of some text and can be not related to telegram bot
|
||||||
|
* `MultilevelTextSource` was added - it is type of `TextSource`, which can have subsources as parts of this text
|
||||||
|
* In all `TextSource`s all fields now are lazy for avoiding of potential risk for performance issues
|
||||||
|
|
||||||
|
## 0.20.0 MPP Migration
|
||||||
|
|
||||||
|
* Time library change: `joda-time` -> `com.soywiz.korlibs.klock:klock`
|
||||||
|
* `Currencied` now using as `currency` value with type `String`
|
||||||
|
* For `Java` there is `Currencied#javaCurrency` extension function, which will give an old currency work way
|
||||||
|
* `User` now have no field `userLocale`
|
||||||
|
* For `Java` there is `User#javaLocale` extension function, which will give an old locale work way
|
||||||
|
|
||||||
|
### 0.20.1
|
||||||
|
|
||||||
|
* `User` now implement `PrivateChat`
|
||||||
|
* `TextMentionMessageEntity` now accept `PrivateChat` instead of `User` in main constructor
|
||||||
|
* `TextMentionMessageEntity` now contains not user, but contains `PrivateChat`
|
||||||
|
* Fixed: `TextMentionMessageEntity#asHtmlSource` previously worked incorrect
|
||||||
|
* Abstraction `TextSource`
|
||||||
|
* `MessageEntity` now extends `TextSource`
|
||||||
|
* `createFormattedText` method now accept `List<TextSource>`
|
||||||
|
* `createHtmlText` method now accept `List<TextSource>`
|
||||||
|
* `createMarkdownText` method now accept `List<TextSource>`
|
||||||
|
* A lot of `TextSource` implementors was added. More info [here](src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/)
|
||||||
|
* All `MessageEntity` implementations now are using new `TextSource` analogues as delegates
|
||||||
|
|
||||||
|
### 0.20.2
|
||||||
|
|
||||||
|
* New exception type `MessageIsNotModifierException` was added
|
||||||
|
* New exception type `MessageToEditNotFoundException` was added
|
||||||
|
* Now exceptions in requests will be caught correctly
|
||||||
|
|
||||||
|
### 0.20.3
|
||||||
|
|
||||||
|
* Now `LeftChatMamber` is a `CommonEvent`
|
||||||
|
|
||||||
|
### 0.20.4
|
||||||
|
|
||||||
|
* Now `setWebhook` supports setting up of path for listening
|
||||||
|
* Now `setWebhook` supports custom listen address even if certificate was not provided
|
||||||
|
|
||||||
|
## 0.19.0 ImplicitReflection removing
|
||||||
|
|
||||||
|
* Total rework of serialization for requests. Now all `SimpleRequest` children have:
|
||||||
|
* `requestSerializer` - field, which must provide serializer of current type
|
||||||
|
* `resultDeserializer` - field, which must provide opportunity to deserializer result. Previously it was a function
|
||||||
|
* Removed deprecations:
|
||||||
|
* `com.github.insanusmokrassar.TelegramBotAPI.utils.extensions.WebhookPrivateKeyConfig`
|
||||||
|
* `com.github.insanusmokrassar.TelegramBotAPI.utils.extensions.UpdatesFilter`
|
||||||
|
* `com.github.insanusmokrassar.TelegramBotAPI.utils.extensions.createSimpleUpdateFilter`
|
||||||
|
* `com.github.insanusmokrassar.TelegramBotAPI.utils.createMarkdownText`
|
||||||
|
* `com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownCaption`
|
||||||
|
* `com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownText`
|
||||||
|
* `com.github.insanusmokrassar.TelegramBotAPI.updateshandlers.KtorUpdatesPoller`
|
||||||
|
* `com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.CaptionedMediaContent`
|
||||||
|
* `com.github.insanusmokrassar.TelegramBotAPI.types.message.CommonForwardedMessage`
|
||||||
|
* `com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.CaptionedInputMedia`
|
||||||
|
* `com.github.insanusmokrassar.TelegramBotAPI.types.games.Game#text`
|
||||||
|
* `com.github.insanusmokrassar.TelegramBotAPI.types.games.Game#textEntities`
|
||||||
|
* `com.github.insanusmokrassar.TelegramBotAPI.types.files.PathedFileKt.makeFileUrl`
|
||||||
|
* `com.github.insanusmokrassar.TelegramBotAPI.types.files.PathedFileKt.downloadingFilesBaseUrl`
|
||||||
|
* `com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.Data`
|
||||||
|
* `com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ByInlineMessageId`
|
||||||
|
* `com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ByMessageId`
|
||||||
|
* `com.github.insanusmokrassar.TelegramBotAPI.bot.RequestException`
|
||||||
|
* `com.github.insanusmokrassar.TelegramBotAPI.bot.exceptions.ReplyMessageNotFound`
|
||||||
|
* `com.github.insanusmokrassar.TelegramBotAPI.bot.BaseRequestsExecutor#baseUrl`
|
||||||
|
* `com.github.insanusmokrassar.TelegramBotAPI.bot.BaseRequestsExecutor#constructor(token, hostUrl)`
|
||||||
|
* `com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor.KtorRequestsExecutor#constructor(token, client, hostUrl, callsFactories, excludeDefaultFactories, requestsLimiter, jsonFormatter)`
|
||||||
|
* `com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor.KtorRequestsExecutor#constructor(token, engine, hostUrl)`
|
||||||
|
|
||||||
|
## 0.18.0 Raws cleaning
|
||||||
|
|
||||||
|
* Made internal and not available outside of library:
|
||||||
|
* `RawMessage`
|
||||||
|
* `RawUpdate`
|
||||||
|
* `RawChatMember`
|
||||||
|
* `RawMessageEntity`
|
||||||
|
* `RawInlineQuery`
|
||||||
|
* `RawCallbackQuery`
|
||||||
|
* `RawChosenInlineResult`
|
||||||
|
|
||||||
|
* All `RawMessage` usages was replaced with `Message` interface (with some of other raw classes was made the same things)
|
||||||
|
* `TelegramBotAPIMessageDeserializationStrategy` was created. It was used for deserialization of Telegram Bot API
|
||||||
|
incoming messages
|
||||||
|
* `TelegramBotAPIMessageDeserializeOnlySerializer` was created. It **MUST NOT** be used to serialize messages
|
||||||
|
* Update of description
|
||||||
|
* Make `Game` object a little bit more standartizated
|
||||||
|
* `Game` now is not serializable and have no additional trash, related to serialization
|
||||||
|
* `TelegramFile` was removed
|
||||||
|
|
||||||
|
### 0.18.1 Libraries update
|
||||||
|
|
||||||
|
* Update libraries:
|
||||||
|
* `kotlin`: 1.3.41 -> 1.3.61
|
||||||
|
* `kotlin coroutines`: 1.2.2 -> 1.3.2
|
||||||
|
* `kotlin serialization`: 0.11.1 -> 0.14.0
|
||||||
|
* `joda time`: 2.10.3 -> 2.10.5
|
||||||
|
* `ktor`: 1.2.3 -> 1.2.6
|
||||||
|
* `BotAction` now will be deserialized in a little bit other way
|
||||||
|
* `BotActionSerializer` now is internal
|
||||||
|
* Most part of serializers now are objects (instead of classes as was previously)
|
||||||
|
|
||||||
|
## 0.17.0 July 29, 2019 API Update
|
||||||
|
|
||||||
|
Libraries updates:
|
||||||
|
|
||||||
|
* Kotlin version `1.3.31` -> `1.3.41`
|
||||||
|
* Kotlin Coroutines version `1.2.1` -> `1.2.2`
|
||||||
|
* Kotlin Serialization version `0.11.0` -> `0.11.1`
|
||||||
|
* Joda Time version `2.10.1` -> `2.10.3`
|
||||||
|
* ktor version `1.1.4` -> `1.2.3`
|
||||||
|
|
||||||
|
Changes according to [July 29, 2019 Telegram Bot API update](https://core.telegram.org/bots/api#july-29-2019):
|
||||||
|
|
||||||
|
* `Sticker` and `StickerSet` now have field `isAnimated`
|
||||||
|
* `ChatPermissions` object was added, `GroupChat` interface got `permissions` field, request `SetChatPermissions` was added
|
||||||
|
* `GroupChat` object now have no field `allMembersAreAdmins`
|
||||||
|
* `SpecialRightsChatMember` was added for administrators and restricted members rights union, chat members abstractions
|
||||||
|
was replaced into `abstracts` package and available permissions was updated
|
||||||
|
* `RestrictChatMember` request now accept `permissions` object instead of separated permissions
|
||||||
|
* All `GroupChat` instances have description
|
||||||
|
|
||||||
|
Other important changes:
|
||||||
|
|
||||||
|
* Totally reworked chats hierarchy. `Extended` abstractions was added for cases when called `GetChat` request
|
||||||
|
* `RawChat` boilerplate was removed and replaced by serializers
|
||||||
|
* `BotCommandMessageEntity#command` will not contain `/`/`!` parts and also will cut outside of command begin token (`/`
|
||||||
|
or `!`) and username token (`@`) or end of command (any space character)
|
||||||
|
* `RequestsExecutor` now is `Closeable`
|
||||||
|
* `TelegramAPIUrlsKeeper` was added to provide more comfortable work with file urls and other things
|
||||||
|
like this
|
||||||
|
|
||||||
## 0.16.0 Bot API 4.3
|
## 0.16.0 Bot API 4.3
|
||||||
|
|
||||||
* `LoginURL` and `LoginURLInlineKeyboardButton` has been added
|
* `LoginURL` and `LoginURLInlineKeyboardButton` has been added
|
||||||
|
|||||||
50
README.md
50
README.md
@@ -1,20 +1,20 @@
|
|||||||
# TelegramBotAPI
|
# TelegramBotAPI
|
||||||
|
|
||||||
[ ](https://bintray.com/insanusmokrassar/StandardRepository/TelegramBotAPI/_latestVersion)
|
[ ](https://bintray.com/insanusmokrassar/StandardRepository/TelegramBotAPI/_latestVersion)
|
||||||
[](https://jenkins.insanusmokrassar.space/job/TelegramBotAPI_master__publishing/)
|
[](https://jenkins.insanusmokrassar.com/job/TelegramBotAPI_master__publishing/)
|
||||||
|
|
||||||
## What is it?
|
## What is it?
|
||||||
|
|
||||||
It is one more project which wish to be useful and full Telegram Bots API bridge for Kotlin. Most part of some specific
|
Library for Object-Oriented and type-safe work with Telegram Bot API. Most part of some specific solves or unuseful
|
||||||
solves or unuseful moments are describing by official [Telegram Bot API](https://core.telegram.org/bots/api).
|
moments are describing by official [Telegram Bot API](https://core.telegram.org/bots/api).
|
||||||
|
|
||||||
## Compatibility
|
## Compatibility
|
||||||
|
|
||||||
This version compatible with [31st of May 2019 update of TelegramBotAPI](https://core.telegram.org/bots/api#may-31-2019).
|
This version compatible with [29th of July 2019 update of TelegramBotAPI](https://core.telegram.org/bots/api#july-29-2019).
|
||||||
There is one exception of implemented functionality. It is Telegram Passport API, which was presented in
|
There is Telegram Passport API exception of implemented functionality, which was presented in
|
||||||
[August 2018 update of TelegramBotAPI](https://core.telegram.org/bots/api#august-27-2018) update. It will be implemented
|
[August 2018 update of TelegramBotAPI](https://core.telegram.org/bots/api#august-27-2018) update. It will be implemented
|
||||||
as soon as possible. All included and supported API can be found on
|
as soon as possible. All APIs that are not included are presented
|
||||||
[wiki](https://github.com/InsanusMokrassar/TelegramBotAPI/wiki/Included-API).
|
[wiki](https://github.com/InsanusMokrassar/TelegramBotAPI/wiki/Not-included-API).
|
||||||
|
|
||||||
## How to implement library?
|
## How to implement library?
|
||||||
|
|
||||||
@@ -25,8 +25,30 @@ like inserting of additional libraries (like `kotlin stdlib`). In the examples w
|
|||||||
|
|
||||||
[ ](https://bintray.com/insanusmokrassar/StandardRepository/TelegramBotAPI/_latestVersion)
|
[ ](https://bintray.com/insanusmokrassar/StandardRepository/TelegramBotAPI/_latestVersion)
|
||||||
|
|
||||||
|
Currently, last versions of library are not included into the Maven repository (for the reason difficult in publishing
|
||||||
|
of signed artifacts in Bintray). You can:
|
||||||
|
|
||||||
|
* Use earlier version (available version you can find
|
||||||
|
[here](https://mvnrepository.com/artifact/com.github.insanusmokrassar/TelegramBotAPI))
|
||||||
|
* Add `jCenter` repository in build config
|
||||||
|
|
||||||
### Maven
|
### Maven
|
||||||
|
|
||||||
|
To use last versions you will need to add several lines in repositories block of your pom.xml:
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<repository>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>false</enabled>
|
||||||
|
</snapshots>
|
||||||
|
<id>central</id>
|
||||||
|
<name>bintray</name>
|
||||||
|
<url>http://jcenter.bintray.com</url>
|
||||||
|
</repository>
|
||||||
|
```
|
||||||
|
|
||||||
|
Dependency config presented here:
|
||||||
|
|
||||||
```xml
|
```xml
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.insanusmokrassar</groupId>
|
<groupId>com.github.insanusmokrassar</groupId>
|
||||||
@@ -37,14 +59,22 @@ like inserting of additional libraries (like `kotlin stdlib`). In the examples w
|
|||||||
|
|
||||||
### Gradle
|
### Gradle
|
||||||
|
|
||||||
|
To use last versions you will need to add one line in repositories block of your build.gradle:
|
||||||
|
|
||||||
```groovy
|
```groovy
|
||||||
implementation "com.github.insanusmokrassar:TelegramBotAPI:${telegrambotapi.version}"
|
jcenter()
|
||||||
```
|
```
|
||||||
|
|
||||||
### Gradle (old)
|
And add next line to your dependencies block:
|
||||||
|
|
||||||
```groovy
|
```groovy
|
||||||
compile "com.github.insanusmokrassar:TelegramBotAPI:${telegrambotapi.version}"
|
implementation "com.github.insanusmokrassar:TelegramBotAPI:$telegrambotapi_version"
|
||||||
|
```
|
||||||
|
|
||||||
|
or for old gradle:
|
||||||
|
|
||||||
|
```groovy
|
||||||
|
compile "com.github.insanusmokrassar:TelegramBotAPI:$telegrambotapi_version"
|
||||||
```
|
```
|
||||||
|
|
||||||
## How to work with library?
|
## How to work with library?
|
||||||
|
|||||||
71
build.gradle
71
build.gradle
@@ -1,6 +1,3 @@
|
|||||||
project.version = "0.16.1"
|
|
||||||
project.group = "com.github.insanusmokrassar"
|
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
mavenLocal()
|
mavenLocal()
|
||||||
@@ -15,9 +12,13 @@ buildscript {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
apply plugin: 'java-library'
|
plugins {
|
||||||
apply plugin: 'kotlin'
|
id "org.jetbrains.kotlin.multiplatform" version "$kotlin_version"
|
||||||
apply plugin: 'kotlinx-serialization'
|
id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version"
|
||||||
|
}
|
||||||
|
|
||||||
|
project.version = "0.21.0"
|
||||||
|
project.group = "com.github.insanusmokrassar"
|
||||||
|
|
||||||
apply from: "publish.gradle"
|
apply from: "publish.gradle"
|
||||||
|
|
||||||
@@ -28,21 +29,53 @@ repositories {
|
|||||||
maven { url "https://kotlin.bintray.com/kotlinx" }
|
maven { url "https://kotlin.bintray.com/kotlinx" }
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
kotlin {
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
jvm()
|
||||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version"
|
js()
|
||||||
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$kotlin_serialisation_runtime_version"
|
|
||||||
implementation "joda-time:joda-time:$joda_time_version"
|
|
||||||
|
|
||||||
implementation "io.ktor:ktor-client:$ktor_version"
|
sourceSets {
|
||||||
implementation "io.ktor:ktor-client-cio:$ktor_version"
|
commonMain {
|
||||||
|
dependencies {
|
||||||
|
implementation kotlin('stdlib')
|
||||||
|
api "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:$kotlin_coroutines_version"
|
||||||
|
api "org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:$kotlin_serialisation_runtime_version"
|
||||||
|
|
||||||
implementation "io.ktor:ktor-server:$ktor_version"
|
api "com.soywiz.korlibs.klock:klock:$klock_version"
|
||||||
implementation "io.ktor:ktor-server-host-common:$ktor_version"
|
api "com.benasher44:uuid:$uuid_version"
|
||||||
}
|
|
||||||
|
|
||||||
compileKotlin {
|
api "io.ktor:ktor-client-core:$ktor_version"
|
||||||
kotlinOptions {
|
}
|
||||||
freeCompilerArgs = [ disableImplicitReflectionSerializerAnnotation ]
|
}
|
||||||
|
commonTest {
|
||||||
|
dependencies {
|
||||||
|
implementation kotlin('test-common')
|
||||||
|
implementation kotlin('test-annotations-common')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
jvmMain {
|
||||||
|
dependencies {
|
||||||
|
api "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$kotlin_serialisation_runtime_version"
|
||||||
|
|
||||||
|
api "io.ktor:ktor-client:$ktor_version"
|
||||||
|
api "io.ktor:ktor-server:$ktor_version"
|
||||||
|
|
||||||
|
api "io.ktor:ktor-server-host-common:$ktor_version"
|
||||||
|
api "io.ktor:ktor-client-cio:$ktor_version"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
jvmTest {
|
||||||
|
dependencies {
|
||||||
|
implementation kotlin('test-junit')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
jsMain {
|
||||||
|
dependencies {
|
||||||
|
api "org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:$kotlin_serialisation_runtime_version"
|
||||||
|
api "org.jetbrains.kotlinx:kotlinx-coroutines-core-js:$kotlin_coroutines_version"
|
||||||
|
api "io.ktor:ktor-client-js:$ktor_version"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
kotlin.code.style=official
|
kotlin.code.style=official
|
||||||
kotlin_version=1.3.31
|
kotlin_version=1.3.61
|
||||||
kotlin_coroutines_version=1.2.1
|
kotlin_coroutines_version=1.3.2
|
||||||
kotlin_serialisation_runtime_version=0.11.0
|
kotlin_serialisation_runtime_version=0.14.0
|
||||||
joda_time_version=2.10.1
|
klock_version=1.8.0
|
||||||
ktor_version=1.1.4
|
uuid_version=0.0.6
|
||||||
|
ktor_version=1.2.6
|
||||||
|
|
||||||
gradle_bintray_plugin_version=1.8.4
|
gradle_bintray_plugin_version=1.8.4
|
||||||
|
|
||||||
project_public_name=Telegram Bot API
|
project_public_name=Telegram Bot API
|
||||||
project_public_description=It is one more project which wish to be useful and full Telegram Bots API bridge for Kotlin
|
project_public_description=Library for Object-Oriented and type-safe work with Telegram Bot API
|
||||||
|
|
||||||
disableImplicitReflectionSerializerAnnotation=-Xexperimental=kotlinx.serialization.ImplicitReflectionSerializer
|
|
||||||
|
|||||||
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,6 @@
|
|||||||
#Thu Feb 21 12:05:40 HKT 2019
|
#Fri Nov 29 12:11:00 HKT 2019
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-all.zip
|
||||||
|
|||||||
@@ -1,56 +1,52 @@
|
|||||||
apply plugin: 'maven-publish'
|
apply plugin: 'maven-publish'
|
||||||
apply plugin: 'signing'
|
apply plugin: 'signing'
|
||||||
|
|
||||||
task sourcesJar(type: Jar) {
|
task javadocsJar(type: Jar) {
|
||||||
from sourceSets.main.allSource
|
|
||||||
classifier = 'sources'
|
|
||||||
}
|
|
||||||
|
|
||||||
task javadocJar(type: Jar) {
|
|
||||||
from javadoc
|
|
||||||
classifier = 'javadoc'
|
classifier = 'javadoc'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
afterEvaluate {
|
||||||
|
project.publishing.publications.all {
|
||||||
|
// rename artifacts
|
||||||
|
groupId "${project.group}"
|
||||||
|
if (it.name.contains('kotlinMultiplatform')) {
|
||||||
|
artifactId = "${project.name}"
|
||||||
|
} else {
|
||||||
|
artifactId = "${project.name}-$name"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
publications {
|
publications.all {
|
||||||
maven(MavenPublication) {
|
artifact javadocsJar
|
||||||
from components.java
|
|
||||||
groupId "${project.group}"
|
|
||||||
artifactId "${project.name}"
|
|
||||||
version "${project.version}"
|
|
||||||
|
|
||||||
artifact sourcesJar
|
pom.withXml {
|
||||||
artifact javadocJar
|
asNode().children().last() + {
|
||||||
|
resolveStrategy = Closure.DELEGATE_FIRST
|
||||||
pom.withXml {
|
|
||||||
asNode().children().last() + {
|
|
||||||
resolveStrategy = Closure.DELEGATE_FIRST
|
|
||||||
name "${project_public_name}"
|
|
||||||
description "${project_public_description}"
|
|
||||||
url "https://insanusmokrassar.github.io/${project.name}"
|
|
||||||
|
|
||||||
scm {
|
description "Library for Object-Oriented and type-safe work with Telegram Bot API"
|
||||||
connection "scm:git:git://github.com/insanusmokrassar/${project.name}.git"
|
name "Telegram Bot API"
|
||||||
developerConnection "scm:git:[fetch=]https://github.com/insanusmokrassar/${project.name}.git[push=]ssh:git@github.com:insanusmokrassar/${project.name}.git"
|
url "https://insanusmokrassar.github.io/TelegramBotAPI"
|
||||||
url "https://github.com/insanusmokrassar/${project.name}"
|
|
||||||
|
|
||||||
}
|
scm {
|
||||||
|
developerConnection "scm:git:[fetch=]https://github.com/insanusmokrassar/TelegramBotAPI.git[push=]https://github.com/insanusmokrassar/TelegramBotAPI.git"
|
||||||
|
url "https://github.com/insanusmokrassar/TelegramBotAPI.git"
|
||||||
|
}
|
||||||
|
|
||||||
developers {
|
developers {
|
||||||
developer {
|
developer {
|
||||||
id "InsanusMokrassar"
|
id "InsanusMokrassar"
|
||||||
name "Ovsyannikov Alexey"
|
name "Ovsiannikov Aleksei"
|
||||||
email "ovsyannikov.alexey95@gmail.com"
|
email "ovsyannikov.alexey95@gmail.com"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
licenses {
|
licenses {
|
||||||
license {
|
license {
|
||||||
name 'The Apache Software License, Version 2.0'
|
name "Apache Software License 2.0"
|
||||||
url 'https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE'
|
url "https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"
|
||||||
distribution 'repo'
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -59,5 +55,5 @@ publishing {
|
|||||||
|
|
||||||
signing {
|
signing {
|
||||||
useGpgCmd()
|
useGpgCmd()
|
||||||
sign publishing.publications.maven
|
sign(publishing.publications)
|
||||||
}
|
}
|
||||||
|
|||||||
1
mpp_publish_template.json
Normal file
1
mpp_publish_template.json
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"bintrayConfig":{"repo":"StandardRepository","packageName":"${project.name}","packageVcs":"https://github.com/InsanusMokrassar/TelegramBotAPI"},"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"}],"mavenConfig":{"name":"Telegram Bot API","description":"Library for Object-Oriented and type-safe work with Telegram Bot API","url":"https://insanusmokrassar.github.io/TelegramBotAPI","vcsUrl":"https://github.com/insanusmokrassar/TelegramBotAPI.git","developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}]}}
|
||||||
@@ -1,33 +1,27 @@
|
|||||||
apply plugin: 'com.jfrog.bintray'
|
apply plugin: 'com.jfrog.bintray'
|
||||||
|
|
||||||
ext {
|
apply from: "maven.publish.gradle"
|
||||||
projectBintrayDir = "${project.group}/".replace(".", "/") + "${project.name}/${project.version}"
|
|
||||||
}
|
|
||||||
|
|
||||||
bintray {
|
bintray {
|
||||||
user = project.hasProperty('BINTRAY_USER') ? project.property('BINTRAY_USER') : System.getenv('BINTRAY_USER')
|
user = project.hasProperty('BINTRAY_USER') ? project.property('BINTRAY_USER') : System.getenv('BINTRAY_USER')
|
||||||
key = project.hasProperty('BINTRAY_KEY') ? project.property('BINTRAY_KEY') : System.getenv('BINTRAY_KEY')
|
key = project.hasProperty('BINTRAY_KEY') ? project.property('BINTRAY_KEY') : System.getenv('BINTRAY_KEY')
|
||||||
publications = ["maven"]
|
|
||||||
filesSpec {
|
|
||||||
into "$projectBintrayDir"
|
|
||||||
from("build/libs") {
|
|
||||||
include "**/*.asc"
|
|
||||||
}
|
|
||||||
from("build/publications/maven") {
|
|
||||||
rename 'pom-default.xml(.*)', "${project.name}-${project.version}.pom\$1"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pkg {
|
pkg {
|
||||||
repo = 'StandardRepository'
|
repo = "StandardRepository"
|
||||||
name = "${project.name}"
|
name = "${project.name}"
|
||||||
vcsUrl = "https://github.com/InsanusMokrassar/${project.name}"
|
vcsUrl = "https://github.com/InsanusMokrassar/TelegramBotAPI"
|
||||||
licenses = ['Apache-2.0']
|
licenses = ["Apache-2.0"]
|
||||||
version {
|
version {
|
||||||
name = "${project.version}"
|
name = "${project.version}"
|
||||||
released = new Date()
|
released = new Date()
|
||||||
vcsTag = name
|
vcsTag = "${project.version}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
apply from: "maven.publish.gradle"
|
bintrayUpload.doFirst {
|
||||||
|
publications = publishing.publications.collect {
|
||||||
|
it.name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bintrayUpload.dependsOn publishToMavenLocal
|
||||||
@@ -1,18 +1 @@
|
|||||||
/*
|
|
||||||
* This settings file was generated by the Gradle 'init' task.
|
|
||||||
*
|
|
||||||
* The settings file is used to specify which projects to include in your build.
|
|
||||||
* In a single project build this file can be empty or even removed.
|
|
||||||
*
|
|
||||||
* Detailed information about configuring a multi-project build in Gradle can be found
|
|
||||||
* in the user guide at https://docs.gradle.org/3.4.1/userguide/multi_project_builds.html
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
// To declare projects as part of a multi-project build use the 'include' method
|
|
||||||
include 'shared'
|
|
||||||
include 'api'
|
|
||||||
include 'services:webservice'
|
|
||||||
*/
|
|
||||||
|
|
||||||
rootProject.name = 'TelegramBotAPI'
|
rootProject.name = 'TelegramBotAPI'
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts
|
package com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.fullListOfSubSource
|
||||||
|
|
||||||
interface Captioned {
|
interface Captioned {
|
||||||
val caption: String?
|
val caption: String?
|
||||||
@@ -12,5 +12,7 @@ interface CaptionedOutput : Captioned {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface CaptionedInput : Captioned {
|
interface CaptionedInput : Captioned {
|
||||||
val captionEntities: List<MessageEntity>
|
val captionEntities: List<TextPart>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun CaptionedInput.fullEntitiesList() = caption ?.fullListOfSubSource(captionEntities) ?.map { it.source } ?: emptyList()
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts
|
||||||
|
|
||||||
|
interface TextSource {
|
||||||
|
val asMarkdownSource: String
|
||||||
|
val asMarkdownV2Source: String
|
||||||
|
val asHtmlSource: String
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
interface MultilevelTextSource : TextSource {
|
||||||
|
val textParts: List<TextPart>
|
||||||
|
}
|
||||||
|
|
||||||
|
data class TextPart(
|
||||||
|
val range: IntRange,
|
||||||
|
val source: TextSource
|
||||||
|
)
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.bot
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.TelegramAPIUrlsKeeper
|
||||||
|
|
||||||
|
abstract class BaseRequestsExecutor(
|
||||||
|
protected val telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper
|
||||||
|
) : RequestsExecutor
|
||||||
@@ -9,32 +9,23 @@ import com.github.insanusmokrassar.TelegramBotAPI.bot.settings.limiters.RequestL
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.Response
|
import com.github.insanusmokrassar.TelegramBotAPI.types.Response
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.RetryAfterError
|
import com.github.insanusmokrassar.TelegramBotAPI.types.RetryAfterError
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.TelegramAPIUrlsKeeper
|
||||||
import io.ktor.client.HttpClient
|
import io.ktor.client.HttpClient
|
||||||
import io.ktor.client.call.HttpClientCall
|
import io.ktor.client.call.HttpClientCall
|
||||||
import io.ktor.client.engine.HttpClientEngine
|
import io.ktor.client.call.receive
|
||||||
import io.ktor.util.cio.toByteArray
|
import io.ktor.client.features.ClientRequestException
|
||||||
|
import io.ktor.client.response.readText
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
|
|
||||||
class KtorRequestsExecutor(
|
class KtorRequestsExecutor(
|
||||||
token: String,
|
telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper,
|
||||||
private val client: HttpClient = HttpClient(),
|
private val client: HttpClient = HttpClient(),
|
||||||
hostUrl: String = "https://api.telegram.org",
|
|
||||||
callsFactories: List<KtorCallFactory> = emptyList(),
|
callsFactories: List<KtorCallFactory> = emptyList(),
|
||||||
excludeDefaultFactories: Boolean = false,
|
excludeDefaultFactories: Boolean = false,
|
||||||
private val requestsLimiter: RequestLimiter = EmptyLimiter,
|
private val requestsLimiter: RequestLimiter = EmptyLimiter,
|
||||||
private val jsonFormatter: Json = Json.nonstrict
|
private val jsonFormatter: Json = Json.nonstrict
|
||||||
) : BaseRequestsExecutor(token, hostUrl) {
|
) : BaseRequestsExecutor(telegramAPIUrlsKeeper) {
|
||||||
constructor(
|
|
||||||
token: String,
|
|
||||||
engine: HttpClientEngine? = null,
|
|
||||||
hostUrl: String = "https://api.telegram.org"
|
|
||||||
) : this(
|
|
||||||
token,
|
|
||||||
engine ?.let { HttpClient(engine) } ?: HttpClient(),
|
|
||||||
hostUrl
|
|
||||||
)
|
|
||||||
|
|
||||||
private val callsFactories: List<KtorCallFactory> = callsFactories.run {
|
private val callsFactories: List<KtorCallFactory> = callsFactories.run {
|
||||||
if (!excludeDefaultFactories) {
|
if (!excludeDefaultFactories) {
|
||||||
asSequence().plus(SimpleRequestCallFactory()).plus(MultipartRequestCallFactory()).toList()
|
asSequence().plus(SimpleRequestCallFactory()).plus(MultipartRequestCallFactory()).toList()
|
||||||
@@ -49,7 +40,7 @@ class KtorRequestsExecutor(
|
|||||||
for (factory in callsFactories) {
|
for (factory in callsFactories) {
|
||||||
call = factory.prepareCall(
|
call = factory.prepareCall(
|
||||||
client,
|
client,
|
||||||
baseUrl,
|
telegramAPIUrlsKeeper.commonAPIUrl,
|
||||||
request
|
request
|
||||||
)
|
)
|
||||||
if (call != null) {
|
if (call != null) {
|
||||||
@@ -59,22 +50,30 @@ class KtorRequestsExecutor(
|
|||||||
if (call == null) {
|
if (call == null) {
|
||||||
throw IllegalArgumentException("Can't execute request: $request")
|
throw IllegalArgumentException("Can't execute request: $request")
|
||||||
}
|
}
|
||||||
val content = call.response.use {
|
try {
|
||||||
it.content.toByteArray().toString(Charsets.UTF_8)
|
val content = call.response.receive<String>()
|
||||||
}
|
val responseObject = jsonFormatter.parse(Response.serializer(), content)
|
||||||
val responseObject = jsonFormatter.parse(
|
|
||||||
Response.serializer(request.resultSerializer()),
|
(responseObject.result?.let {
|
||||||
content
|
jsonFormatter.fromJson(request.resultDeserializer, it)
|
||||||
)
|
} ?: responseObject.parameters?.let {
|
||||||
responseObject.result ?: responseObject.parameters ?.let {
|
val error = it.error
|
||||||
val error = it.error
|
if (error is RetryAfterError) {
|
||||||
if (error is RetryAfterError) {
|
delay(error.leftToRetry)
|
||||||
delay(error.leftToRetry)
|
execute(request)
|
||||||
execute(request)
|
} else {
|
||||||
} else {
|
null
|
||||||
null
|
}
|
||||||
}
|
} ?: call.let {
|
||||||
} ?: call.let {
|
throw newRequestException(
|
||||||
|
responseObject,
|
||||||
|
content,
|
||||||
|
"Can't get result object from $content"
|
||||||
|
)
|
||||||
|
})
|
||||||
|
} catch (e: ClientRequestException) {
|
||||||
|
val content = e.response.readText()
|
||||||
|
val responseObject = jsonFormatter.parse(Response.serializer(), content)
|
||||||
throw newRequestException(
|
throw newRequestException(
|
||||||
responseObject,
|
responseObject,
|
||||||
content,
|
content,
|
||||||
@@ -83,4 +82,8 @@ class KtorRequestsExecutor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun close() {
|
||||||
|
client.close()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -9,6 +9,7 @@ import io.ktor.client.request.accept
|
|||||||
import io.ktor.client.request.url
|
import io.ktor.client.request.url
|
||||||
import io.ktor.http.ContentType
|
import io.ktor.http.ContentType
|
||||||
import io.ktor.http.HttpMethod
|
import io.ktor.http.HttpMethod
|
||||||
|
import kotlin.collections.set
|
||||||
|
|
||||||
abstract class AbstractRequestCallFactory : KtorCallFactory {
|
abstract class AbstractRequestCallFactory : KtorCallFactory {
|
||||||
private val methodsCache: MutableMap<String, String> = mutableMapOf()
|
private val methodsCache: MutableMap<String, String> = mutableMapOf()
|
||||||
@@ -29,7 +30,6 @@ abstract class AbstractRequestCallFactory : KtorCallFactory {
|
|||||||
accept(ContentType.Application.Json)
|
accept(ContentType.Application.Json)
|
||||||
|
|
||||||
body = preparedBody
|
body = preparedBody
|
||||||
build()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20,14 +20,15 @@ class MultipartRequestCallFactory : AbstractRequestCallFactory() {
|
|||||||
val params = castedRequest.paramsJson.mapWithCommonValues()
|
val params = castedRequest.paramsJson.mapWithCommonValues()
|
||||||
for ((key, value) in castedRequest.mediaMap + params) {
|
for ((key, value) in castedRequest.mediaMap + params) {
|
||||||
when (value) {
|
when (value) {
|
||||||
is MultipartFile -> append(
|
is MultipartFile -> appendInput(
|
||||||
key,
|
key,
|
||||||
value.file.asInput(),
|
|
||||||
Headers.build {
|
Headers.build {
|
||||||
append(HttpHeaders.ContentType, value.mimeType)
|
append(HttpHeaders.ContentType, value.mimeType)
|
||||||
append(HttpHeaders.ContentDisposition, "filename=${value.fileId}")
|
append(HttpHeaders.ContentDisposition, "filename=${value.fileId}")
|
||||||
}
|
}
|
||||||
)
|
) {
|
||||||
|
value.file.asInput()
|
||||||
|
}
|
||||||
is FileId -> append(key, value.fileId)
|
is FileId -> append(key, value.fileId)
|
||||||
else -> append(key, value.toString())
|
else -> append(key, value.toString())
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor.base
|
package com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor.base
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toJsonWithoutNulls
|
|
||||||
import io.ktor.client.HttpClient
|
import io.ktor.client.HttpClient
|
||||||
import io.ktor.http.ContentType
|
import io.ktor.http.ContentType
|
||||||
import io.ktor.http.content.TextContent
|
import io.ktor.http.content.TextContent
|
||||||
@@ -12,12 +11,11 @@ class SimpleRequestCallFactory : AbstractRequestCallFactory() {
|
|||||||
baseUrl: String,
|
baseUrl: String,
|
||||||
request: Request<T>
|
request: Request<T>
|
||||||
): Any? = (request as? SimpleRequest<T>) ?.let { _ ->
|
): Any? = (request as? SimpleRequest<T>) ?.let { _ ->
|
||||||
val content = request.toJsonWithoutNulls(SimpleRequestSerializer).toString()
|
val content = request.json().toString()
|
||||||
|
|
||||||
TextContent(
|
TextContent(
|
||||||
content,
|
content,
|
||||||
ContentType.Application.Json
|
ContentType.Application.Json
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,11 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.bot
|
package com.github.insanusmokrassar.TelegramBotAPI.bot
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.exceptions.RequestException
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
|
||||||
|
import kotlinx.io.core.Closeable
|
||||||
|
|
||||||
interface RequestsExecutor {
|
interface RequestsExecutor : Closeable {
|
||||||
@Throws(RequestException::class)
|
/**
|
||||||
|
* @throws com.github.insanusmokrassar.TelegramBotAPI.bot.exceptions.RequestException
|
||||||
|
*/
|
||||||
suspend fun <T : Any> execute(request: Request<T>): T
|
suspend fun <T : Any> execute(request: Request<T>): T
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.bot
|
package com.github.insanusmokrassar.TelegramBotAPI.bot
|
||||||
|
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.CoroutineScope
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.io.core.Closeable
|
import kotlinx.io.core.Closeable
|
||||||
|
|
||||||
interface UpdatesPoller : Closeable {
|
interface UpdatesPoller : Closeable {
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.bot.exceptions
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.Response
|
||||||
|
import kotlinx.io.errors.IOException
|
||||||
|
|
||||||
|
fun newRequestException(
|
||||||
|
response: Response,
|
||||||
|
plainAnswer: String,
|
||||||
|
message: String? = null,
|
||||||
|
cause: Throwable? = null
|
||||||
|
) = response.description ?.let { description ->
|
||||||
|
when {
|
||||||
|
description == "Bad Request: reply message not found" -> ReplyMessageNotFoundException(response, plainAnswer, message, cause)
|
||||||
|
description == "Bad Request: message to edit not found" -> MessageToEditNotFoundException(response, plainAnswer, message, cause)
|
||||||
|
description.contains("Bad Request: message is not modified") -> MessageIsNotModifiedException(response, plainAnswer, message, cause)
|
||||||
|
description == "Unauthorized" -> UnauthorizedException(response, plainAnswer, message, cause)
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
} ?: CommonRequestException(response, plainAnswer, message, cause)
|
||||||
|
|
||||||
|
sealed class RequestException constructor(
|
||||||
|
val response: Response,
|
||||||
|
val plainAnswer: String,
|
||||||
|
message: String? = null,
|
||||||
|
cause: Throwable? = null
|
||||||
|
) : IOException(
|
||||||
|
message ?: "Something went wrong",
|
||||||
|
cause
|
||||||
|
)
|
||||||
|
|
||||||
|
class CommonRequestException(response: Response, plainAnswer: String, message: String?, cause: Throwable?) :
|
||||||
|
RequestException(response, plainAnswer, message, cause)
|
||||||
|
|
||||||
|
class UnauthorizedException(response: Response, plainAnswer: String, message: String?, cause: Throwable?) :
|
||||||
|
RequestException(response, plainAnswer, message, cause)
|
||||||
|
|
||||||
|
class ReplyMessageNotFoundException(response: Response, plainAnswer: String, message: String?, cause: Throwable?) :
|
||||||
|
RequestException(response, plainAnswer, message, cause)
|
||||||
|
|
||||||
|
class MessageIsNotModifiedException(response: Response, plainAnswer: String, message: String?, cause: Throwable?) :
|
||||||
|
RequestException(response, plainAnswer, message, cause)
|
||||||
|
|
||||||
|
class MessageToEditNotFoundException(response: Response, plainAnswer: String, message: String?, cause: Throwable?) :
|
||||||
|
RequestException(response, plainAnswer, message, cause)
|
||||||
@@ -1,9 +1,10 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.bot.settings.limiters
|
package com.github.insanusmokrassar.TelegramBotAPI.bot.settings.limiters
|
||||||
|
|
||||||
|
import com.soywiz.klock.DateTime
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import kotlinx.coroutines.channels.Channel
|
import kotlinx.coroutines.channels.Channel
|
||||||
|
|
||||||
private fun now(): Long = System.currentTimeMillis()
|
private fun now(): Long = DateTime.nowUnixLong()
|
||||||
|
|
||||||
class CommonLimiter(
|
class CommonLimiter(
|
||||||
private val lockCount: Int = 10,
|
private val lockCount: Int = 10,
|
||||||
@@ -4,8 +4,8 @@ import kotlinx.coroutines.*
|
|||||||
import kotlinx.coroutines.channels.Channel
|
import kotlinx.coroutines.channels.Channel
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import kotlinx.serialization.Transient
|
import kotlinx.serialization.Transient
|
||||||
import java.util.concurrent.Executors
|
|
||||||
import kotlin.coroutines.*
|
import kotlin.coroutines.*
|
||||||
|
import kotlin.math.pow
|
||||||
|
|
||||||
private sealed class RequestEvent
|
private sealed class RequestEvent
|
||||||
private class AddRequest(
|
private class AddRequest(
|
||||||
@@ -21,9 +21,7 @@ data class PowLimiter(
|
|||||||
private val powK: Double = 0.0016
|
private val powK: Double = 0.0016
|
||||||
) : RequestLimiter {
|
) : RequestLimiter {
|
||||||
@Transient
|
@Transient
|
||||||
private val scope = CoroutineScope(
|
private val scope = CoroutineScope(Dispatchers.Default)
|
||||||
Executors.newFixedThreadPool(3).asCoroutineDispatcher()
|
|
||||||
)
|
|
||||||
@Transient
|
@Transient
|
||||||
private val eventsChannel = Channel<RequestEvent>(Channel.UNLIMITED)
|
private val eventsChannel = Channel<RequestEvent>(Channel.UNLIMITED)
|
||||||
@Transient
|
@Transient
|
||||||
@@ -35,7 +33,7 @@ data class PowLimiter(
|
|||||||
for (event in eventsChannel) {
|
for (event in eventsChannel) {
|
||||||
when (event) {
|
when (event) {
|
||||||
is AddRequest -> {
|
is AddRequest -> {
|
||||||
val awaitTime = ((Math.pow(requestsInWork, powValue) * powK) * 1000L).toLong()
|
val awaitTime = (((requestsInWork.pow(powValue) * powK) * 1000L).toLong())
|
||||||
requestsInWork++
|
requestsInWork++
|
||||||
|
|
||||||
event.continuation.resume(
|
event.continuation.resume(
|
||||||
@@ -15,5 +15,8 @@ data class DeleteMessage(
|
|||||||
) : SimpleRequest<Boolean>, MessageAction {
|
) : SimpleRequest<Boolean>, MessageAction {
|
||||||
override fun method(): String = "deleteMessage"
|
override fun method(): String = "deleteMessage"
|
||||||
|
|
||||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
|
get() = BooleanSerializer
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.MessageAction
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.MessageAction
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
@@ -16,12 +17,15 @@ data class ForwardMessage(
|
|||||||
override val messageId: MessageIdentifier,
|
override val messageId: MessageIdentifier,
|
||||||
@SerialName(disableNotificationField)
|
@SerialName(disableNotificationField)
|
||||||
val disableNotification: Boolean = false
|
val disableNotification: Boolean = false
|
||||||
): SimpleRequest<RawMessage>, MessageAction {
|
): SimpleRequest<Message>, MessageAction {
|
||||||
@Transient
|
@Transient
|
||||||
override val chatId: ChatIdentifier
|
override val chatId: ChatIdentifier
|
||||||
get() = fromChatId
|
get() = fromChatId
|
||||||
|
|
||||||
override fun method(): String = "forwardMessage"
|
override fun method(): String = "forwardMessage"
|
||||||
|
|
||||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
override val resultDeserializer: DeserializationStrategy<Message>
|
||||||
|
get() = TelegramBotAPIMessageDeserializationStrategy
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
}
|
}
|
||||||
@@ -2,11 +2,13 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests
|
|||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.User
|
import com.github.insanusmokrassar.TelegramBotAPI.types.User
|
||||||
import kotlinx.serialization.KSerializer
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.Serializable
|
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
class GetMe : SimpleRequest<User> {
|
class GetMe : SimpleRequest<User> {
|
||||||
override fun method(): String = "getMe"
|
override fun method(): String = "getMe"
|
||||||
override fun resultSerializer(): KSerializer<User> = User.serializer()
|
override val resultDeserializer: DeserializationStrategy<User>
|
||||||
|
get() = User.serializer()
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.requests
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ALL_UPDATES_LIST
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.UpdateSerializerWithoutDeserialization
|
||||||
|
import kotlinx.serialization.*
|
||||||
|
import kotlinx.serialization.internal.ArrayListSerializer
|
||||||
|
|
||||||
|
private val updatesListSerializer = ArrayListSerializer(
|
||||||
|
UpdateSerializerWithoutDeserialization
|
||||||
|
)
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class GetUpdates(
|
||||||
|
val offset: UpdateIdentifier? = null,// set `last update id + 1` to receive next part of updates
|
||||||
|
val limit: Int? = null,
|
||||||
|
val timeout: Int? = null,
|
||||||
|
val allowed_updates: List<String>? = ALL_UPDATES_LIST
|
||||||
|
): SimpleRequest<List<Update>> {
|
||||||
|
override fun method(): String = "getUpdates"
|
||||||
|
|
||||||
|
override val resultDeserializer: DeserializationStrategy<List<Update>>
|
||||||
|
get() = updatesListSerializer
|
||||||
|
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
|
}
|
||||||
@@ -18,5 +18,8 @@ data class StopPoll(
|
|||||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) : MessageAction, SimpleRequest<Poll>, ReplyMarkup {
|
) : MessageAction, SimpleRequest<Poll>, ReplyMarkup {
|
||||||
override fun method(): String = "stopPoll"
|
override fun method(): String = "stopPoll"
|
||||||
override fun resultSerializer(): KSerializer<Poll> = Poll.serializer()
|
override val resultDeserializer: DeserializationStrategy<Poll>
|
||||||
|
get() = Poll.serializer()
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,6 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.StorageFile
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.StorageFile
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.StringDescriptor
|
import kotlinx.serialization.internal.StringDescriptor
|
||||||
import java.io.File
|
|
||||||
|
|
||||||
@Serializable(InputFileSerializer::class)
|
@Serializable(InputFileSerializer::class)
|
||||||
sealed class InputFile {
|
sealed class InputFile {
|
||||||
@@ -40,7 +39,3 @@ data class MultipartFile (
|
|||||||
) : InputFile() {
|
) : InputFile() {
|
||||||
override val fileId: String = file.generateCustomName()
|
override val fileId: String = file.generateCustomName()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun File.toInputFile(): InputFile = MultipartFile(
|
|
||||||
StorageFile(this)
|
|
||||||
)
|
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts
|
||||||
|
|
||||||
|
import kotlinx.serialization.DeserializationStrategy
|
||||||
|
|
||||||
|
interface Request<T: Any> {
|
||||||
|
fun method(): String
|
||||||
|
val resultDeserializer: DeserializationStrategy<T>
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.toJsonWithoutNulls
|
||||||
|
import kotlinx.serialization.SerializationStrategy
|
||||||
|
import kotlinx.serialization.json.JsonObject
|
||||||
|
|
||||||
|
interface SimpleRequest<T: Any> : Request<T> {
|
||||||
|
val requestSerializer: SerializationStrategy<*>
|
||||||
|
}
|
||||||
|
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
inline fun <T: Any, K: SimpleRequest<T>> K.json(): JsonObject = toJsonWithoutNulls(requestSerializer as SerializationStrategy<K>)
|
||||||
@@ -20,7 +20,10 @@ data class AnswerCallbackQuery(
|
|||||||
val cachedTimeSeconds: Int? = null
|
val cachedTimeSeconds: Int? = null
|
||||||
) : SimpleRequest<Boolean> {
|
) : SimpleRequest<Boolean> {
|
||||||
override fun method(): String = "answerCallbackQuery"
|
override fun method(): String = "answerCallbackQuery"
|
||||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
|
get() = BooleanSerializer
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun CallbackQuery.createAnswer(
|
fun CallbackQuery.createAnswer(
|
||||||
@@ -28,7 +28,10 @@ data class AnswerInlineQuery(
|
|||||||
val switchPmParameter: String? = null
|
val switchPmParameter: String? = null
|
||||||
): SimpleRequest<Boolean> {
|
): SimpleRequest<Boolean> {
|
||||||
override fun method(): String = "answerInlineQuery"
|
override fun method(): String = "answerInlineQuery"
|
||||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
|
get() = BooleanSerializer
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun InlineQuery.createAnswer(
|
fun InlineQuery.createAnswer(
|
||||||
@@ -3,8 +3,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.answers.payments
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.answers.payments.abstracts.AnswerPreCheckoutQuery
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.answers.payments.abstracts.AnswerPreCheckoutQuery
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.PreCheckoutQuery
|
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.PreCheckoutQuery
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.Serializable
|
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class AnswerPreCheckoutQueryOk(
|
data class AnswerPreCheckoutQueryOk(
|
||||||
@@ -13,6 +12,8 @@ data class AnswerPreCheckoutQueryOk(
|
|||||||
) : AnswerPreCheckoutQuery {
|
) : AnswerPreCheckoutQuery {
|
||||||
@SerialName(okField)
|
@SerialName(okField)
|
||||||
override val isOk: Boolean = true
|
override val isOk: Boolean = true
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -25,6 +26,8 @@ data class AnswerPreCheckoutQueryError(
|
|||||||
) : AnswerPreCheckoutQuery {
|
) : AnswerPreCheckoutQuery {
|
||||||
@SerialName(okField)
|
@SerialName(okField)
|
||||||
override val isOk: Boolean = false
|
override val isOk: Boolean = false
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun PreCheckoutQuery.createAnswerOk(): AnswerPreCheckoutQueryOk = AnswerPreCheckoutQueryOk(
|
fun PreCheckoutQuery.createAnswerOk(): AnswerPreCheckoutQueryOk = AnswerPreCheckoutQueryOk(
|
||||||
@@ -17,6 +17,8 @@ data class AnswerShippingQueryOk(
|
|||||||
) : AnswerShippingQuery {
|
) : AnswerShippingQuery {
|
||||||
@SerialName(okField)
|
@SerialName(okField)
|
||||||
override val isOk: Boolean = true
|
override val isOk: Boolean = true
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
object ShippingOptionsSerializer : KSerializer<List<ShippingOption>> by ArrayListSerializer(
|
object ShippingOptionsSerializer : KSerializer<List<ShippingOption>> by ArrayListSerializer(
|
||||||
@@ -32,6 +34,8 @@ data class AnswerShippingQueryError(
|
|||||||
) : AnswerShippingQuery {
|
) : AnswerShippingQuery {
|
||||||
@SerialName(okField)
|
@SerialName(okField)
|
||||||
override val isOk: Boolean = false
|
override val isOk: Boolean = false
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun ShippingQuery.createAnswerOk(
|
fun ShippingQuery.createAnswerOk(
|
||||||
@@ -3,11 +3,12 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.answers.payments.abs
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.PreCheckoutQueryId
|
import com.github.insanusmokrassar.TelegramBotAPI.types.PreCheckoutQueryId
|
||||||
import kotlinx.serialization.KSerializer
|
import kotlinx.serialization.KSerializer
|
||||||
import kotlinx.serialization.serializer
|
import kotlinx.serialization.internal.BooleanSerializer
|
||||||
|
|
||||||
interface AnswerPreCheckoutQuery : SimpleRequest<Boolean> {
|
interface AnswerPreCheckoutQuery : SimpleRequest<Boolean> {
|
||||||
override fun method(): String = "answerPreCheckoutQuery"
|
override fun method(): String = "answerPreCheckoutQuery"
|
||||||
override fun resultSerializer(): KSerializer<Boolean> = Boolean.serializer()
|
override val resultDeserializer: KSerializer<Boolean>
|
||||||
|
get() = BooleanSerializer
|
||||||
|
|
||||||
val preCheckoutQueryId: PreCheckoutQueryId
|
val preCheckoutQueryId: PreCheckoutQueryId
|
||||||
val isOk: Boolean
|
val isOk: Boolean
|
||||||
@@ -2,12 +2,13 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.answers.payments.abs
|
|||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ShippingQueryIdentifier
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ShippingQueryIdentifier
|
||||||
import kotlinx.serialization.KSerializer
|
import kotlinx.serialization.DeserializationStrategy
|
||||||
import kotlinx.serialization.serializer
|
import kotlinx.serialization.internal.BooleanSerializer
|
||||||
|
|
||||||
interface AnswerShippingQuery : SimpleRequest<Boolean> {
|
interface AnswerShippingQuery : SimpleRequest<Boolean> {
|
||||||
override fun method(): String = "answerShippingQuery"
|
override fun method(): String = "answerShippingQuery"
|
||||||
override fun resultSerializer(): KSerializer<Boolean> = Boolean.serializer()
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
|
get() = BooleanSerializer
|
||||||
|
|
||||||
val shippingQueryId: ShippingQueryIdentifier
|
val shippingQueryId: ShippingQueryIdentifier
|
||||||
val isOk: Boolean
|
val isOk: Boolean
|
||||||
@@ -13,5 +13,8 @@ data class ExportChatInviteLink(
|
|||||||
override val chatId: ChatIdentifier
|
override val chatId: ChatIdentifier
|
||||||
): ChatRequest, SimpleRequest<String> {
|
): ChatRequest, SimpleRequest<String> {
|
||||||
override fun method(): String = "exportChatInviteLink"
|
override fun method(): String = "exportChatInviteLink"
|
||||||
override fun resultSerializer(): KSerializer<String> = StringSerializer
|
override val resultDeserializer: DeserializationStrategy<String>
|
||||||
|
get() = StringSerializer
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
}
|
}
|
||||||
@@ -13,5 +13,8 @@ data class LeaveChat(
|
|||||||
override val chatId: ChatIdentifier
|
override val chatId: ChatIdentifier
|
||||||
): ChatRequest, SimpleRequest<Boolean> {
|
): ChatRequest, SimpleRequest<Boolean> {
|
||||||
override fun method(): String = "leaveChat"
|
override fun method(): String = "leaveChat"
|
||||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
|
get() = BooleanSerializer
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.get
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.RawChat
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.ExtendedChatSerializer
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.extended.ExtendedChat
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
@@ -11,7 +12,10 @@ import kotlinx.serialization.*
|
|||||||
data class GetChat(
|
data class GetChat(
|
||||||
@SerialName(chatIdField)
|
@SerialName(chatIdField)
|
||||||
override val chatId: ChatIdentifier
|
override val chatId: ChatIdentifier
|
||||||
): ChatRequest, SimpleRequest<RawChat> {
|
): ChatRequest, SimpleRequest<ExtendedChat> {
|
||||||
override fun method(): String = "getChat"
|
override fun method(): String = "getChat"
|
||||||
override fun resultSerializer(): KSerializer<RawChat> = RawChat.serializer()
|
override val resultDeserializer: DeserializationStrategy<ExtendedChat>
|
||||||
|
get() = ExtendedChatSerializer
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
}
|
}
|
||||||
@@ -3,16 +3,24 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.get
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.RawChatMember
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.ChatMember
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.ChatMemberSerializerWithoutDeserialization
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.ArrayListSerializer
|
import kotlinx.serialization.internal.ArrayListSerializer
|
||||||
|
|
||||||
|
private val chatMembersListSerializer = ArrayListSerializer(
|
||||||
|
ChatMemberSerializerWithoutDeserialization
|
||||||
|
)
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class GetChatAdministrators(
|
data class GetChatAdministrators(
|
||||||
@SerialName(chatIdField)
|
@SerialName(chatIdField)
|
||||||
override val chatId: ChatIdentifier
|
override val chatId: ChatIdentifier
|
||||||
): ChatRequest, SimpleRequest<List<RawChatMember>> {
|
): ChatRequest, SimpleRequest<List<ChatMember>> {
|
||||||
override fun method(): String = "getChatAdministrators"
|
override fun method(): String = "getChatAdministrators"
|
||||||
override fun resultSerializer(): KSerializer<List<RawChatMember>> = ArrayListSerializer(RawChatMember.serializer())
|
override val resultDeserializer: DeserializationStrategy<List<ChatMember>>
|
||||||
|
get() = chatMembersListSerializer
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
}
|
}
|
||||||
@@ -13,5 +13,8 @@ data class GetChatMembersCount(
|
|||||||
override val chatId: ChatIdentifier
|
override val chatId: ChatIdentifier
|
||||||
): ChatRequest, SimpleRequest<Int> {
|
): ChatRequest, SimpleRequest<Int> {
|
||||||
override fun method(): String = "getChatMembersCount"
|
override fun method(): String = "getChatMembersCount"
|
||||||
override fun resultSerializer(): KSerializer<Int> = IntSerializer
|
override val resultDeserializer: DeserializationStrategy<Int>
|
||||||
|
get() = IntSerializer
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.members
|
|||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.abstracts.ChatMemberRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.abstracts.ChatMemberRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.RawChatMember
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.ChatMember
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.ChatMemberDeserializationStrategy
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
@@ -11,7 +12,10 @@ data class GetChatMember(
|
|||||||
override val chatId: ChatIdentifier,
|
override val chatId: ChatIdentifier,
|
||||||
@SerialName(userIdField)
|
@SerialName(userIdField)
|
||||||
override val userId: UserId
|
override val userId: UserId
|
||||||
) : ChatMemberRequest<RawChatMember> {
|
) : ChatMemberRequest<ChatMember> {
|
||||||
override fun method(): String = "getChatMember"
|
override fun method(): String = "getChatMember"
|
||||||
override fun resultSerializer(): KSerializer<RawChatMember> = RawChatMember.serializer()
|
override val resultDeserializer: DeserializationStrategy<ChatMember>
|
||||||
|
get() = ChatMemberDeserializationStrategy
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
}
|
}
|
||||||
@@ -16,5 +16,8 @@ data class KickChatMember(
|
|||||||
override val untilDate: TelegramDate? = null
|
override val untilDate: TelegramDate? = null
|
||||||
) : ChatMemberRequest<Boolean>, UntilDate {
|
) : ChatMemberRequest<Boolean>, UntilDate {
|
||||||
override fun method(): String = "kickChatMember"
|
override fun method(): String = "kickChatMember"
|
||||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
|
get() = BooleanSerializer
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
}
|
}
|
||||||
@@ -32,5 +32,8 @@ data class PromoteChatMember(
|
|||||||
private val canPromoteMembers: Boolean? = null
|
private val canPromoteMembers: Boolean? = null
|
||||||
) : ChatMemberRequest<Boolean>, UntilDate {
|
) : ChatMemberRequest<Boolean>, UntilDate {
|
||||||
override fun method(): String = "promoteChatMember"
|
override fun method(): String = "promoteChatMember"
|
||||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
|
get() = BooleanSerializer
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.members
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.UntilDate
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.UntilDate
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.abstracts.ChatMemberRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.abstracts.ChatMemberRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.ChatPermissions
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.BooleanSerializer
|
import kotlinx.serialization.internal.BooleanSerializer
|
||||||
|
|
||||||
@@ -14,15 +15,12 @@ data class RestrictChatMember(
|
|||||||
override val userId: UserId,
|
override val userId: UserId,
|
||||||
@SerialName(untilDateField)
|
@SerialName(untilDateField)
|
||||||
override val untilDate: TelegramDate? = null,
|
override val untilDate: TelegramDate? = null,
|
||||||
@SerialName(canSendMessagesField)
|
@SerialName(permissionsField)
|
||||||
private val canSendMessages: Boolean? = null,
|
val permissions: ChatPermissions
|
||||||
@SerialName(canSendMediaMessagesField)
|
|
||||||
private val canSendMediaMessages: Boolean? = null,
|
|
||||||
@SerialName(canSendOtherMessagesField)
|
|
||||||
private val canSendOtherMessages: Boolean? = null,
|
|
||||||
@SerialName(canAddWebPagePreviewsField)
|
|
||||||
private val canAddWebPagePreviews: Boolean? = null
|
|
||||||
) : ChatMemberRequest<Boolean>, UntilDate {
|
) : ChatMemberRequest<Boolean>, UntilDate {
|
||||||
override fun method(): String = "restrictChatMember"
|
override fun method(): String = "restrictChatMember"
|
||||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
|
get() = BooleanSerializer
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.members
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.abstracts.ChatMemberRequest
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
|
import kotlinx.serialization.*
|
||||||
|
import kotlinx.serialization.internal.BooleanSerializer
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Representation of https://core.telegram.org/bots/api#setchatadministratorcustomtitle
|
||||||
|
*
|
||||||
|
* Please, remember about restrictions for characters in custom title
|
||||||
|
*/
|
||||||
|
@Serializable
|
||||||
|
data class SetChatAdministratorCustomTitle(
|
||||||
|
@SerialName(chatIdField)
|
||||||
|
override val chatId: ChatId,
|
||||||
|
@SerialName(userIdField)
|
||||||
|
override val userId: UserId,
|
||||||
|
@SerialName(customTitleField)
|
||||||
|
val customTitle: String
|
||||||
|
) : ChatMemberRequest<Boolean> {
|
||||||
|
override fun method(): String = "setChatAdministratorCustomTitle"
|
||||||
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
|
get() = BooleanSerializer
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = RestrictChatMember.serializer()
|
||||||
|
|
||||||
|
init {
|
||||||
|
if (customTitle.length !in customTitleLength) {
|
||||||
|
throw IllegalArgumentException("Custom title length must be in range $customTitleLength, but was ${customTitle.length}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,5 +13,8 @@ data class UnbanChatMember(
|
|||||||
override val userId: UserId
|
override val userId: UserId
|
||||||
) : ChatMemberRequest<Boolean> {
|
) : ChatMemberRequest<Boolean> {
|
||||||
override fun method(): String = "unbanChatMember"
|
override fun method(): String = "unbanChatMember"
|
||||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
|
get() = BooleanSerializer
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
}
|
}
|
||||||
@@ -13,5 +13,8 @@ data class DeleteChatPhoto(
|
|||||||
override val chatId: ChatIdentifier
|
override val chatId: ChatIdentifier
|
||||||
): ChatRequest, SimpleRequest<Boolean> {
|
): ChatRequest, SimpleRequest<Boolean> {
|
||||||
override fun method(): String = "deleteChatPhoto"
|
override fun method(): String = "deleteChatPhoto"
|
||||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
|
get() = BooleanSerializer
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
}
|
}
|
||||||
@@ -16,5 +16,8 @@ data class PinChatMessage (
|
|||||||
override val disableNotification: Boolean = false
|
override val disableNotification: Boolean = false
|
||||||
): ChatRequest, SimpleRequest<Boolean>, MessageAction, DisableNotification {
|
): ChatRequest, SimpleRequest<Boolean>, MessageAction, DisableNotification {
|
||||||
override fun method(): String = "pinChatMessage"
|
override fun method(): String = "pinChatMessage"
|
||||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
|
get() = BooleanSerializer
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
}
|
}
|
||||||
@@ -20,5 +20,8 @@ data class SetChatDescription (
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun method(): String = "setChatDescription"
|
override fun method(): String = "setChatDescription"
|
||||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
|
get() = BooleanSerializer
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.ChatPermissions
|
||||||
|
import kotlinx.serialization.*
|
||||||
|
import kotlinx.serialization.internal.BooleanSerializer
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class SetChatPermissions (
|
||||||
|
@SerialName(chatIdField)
|
||||||
|
override val chatId: ChatIdentifier,
|
||||||
|
@SerialName(permissionsField)
|
||||||
|
val permissions: ChatPermissions
|
||||||
|
): ChatRequest, SimpleRequest<Boolean> {
|
||||||
|
override fun method(): String = "setChatPermissions"
|
||||||
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
|
get() = BooleanSerializer
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
|
}
|
||||||
@@ -16,7 +16,8 @@ data class SetChatPhoto (
|
|||||||
val photo: MultipartFile = throw IllegalArgumentException("Unfortunately, this type of objects can't be parsed automatically")
|
val photo: MultipartFile = throw IllegalArgumentException("Unfortunately, this type of objects can't be parsed automatically")
|
||||||
): ChatRequest, MultipartRequest<Boolean> {
|
): ChatRequest, MultipartRequest<Boolean> {
|
||||||
override fun method(): String = "setChatPhoto"
|
override fun method(): String = "setChatPhoto"
|
||||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
|
get() = BooleanSerializer
|
||||||
override val mediaMap: Map<String, MultipartFile> = mapOf(photoField to photo)
|
override val mediaMap: Map<String, MultipartFile> = mapOf(photoField to photo)
|
||||||
override val paramsJson: JsonObject = toJson(serializer())
|
override val paramsJson: JsonObject = toJson(serializer())
|
||||||
}
|
}
|
||||||
@@ -20,5 +20,8 @@ data class SetChatTitle (
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun method(): String = "setChatTitle"
|
override fun method(): String = "setChatTitle"
|
||||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
|
get() = BooleanSerializer
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
}
|
}
|
||||||
@@ -13,5 +13,8 @@ data class UnpinChatMessage(
|
|||||||
override val chatId: ChatIdentifier
|
override val chatId: ChatIdentifier
|
||||||
): ChatRequest, SimpleRequest<Boolean> {
|
): ChatRequest, SimpleRequest<Boolean> {
|
||||||
override fun method(): String = "unpinChatMessage"
|
override fun method(): String = "unpinChatMessage"
|
||||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
|
get() = BooleanSerializer
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
}
|
}
|
||||||
@@ -13,5 +13,8 @@ data class DeleteChatStickerSet(
|
|||||||
override val chatId: ChatIdentifier
|
override val chatId: ChatIdentifier
|
||||||
): ChatRequest, SimpleRequest<Boolean> {
|
): ChatRequest, SimpleRequest<Boolean> {
|
||||||
override fun method(): String = "deleteChatStickerSet"
|
override fun method(): String = "deleteChatStickerSet"
|
||||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
|
get() = BooleanSerializer
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
}
|
}
|
||||||
@@ -11,8 +11,11 @@ data class SetChatStickerSet(
|
|||||||
@SerialName(chatIdField)
|
@SerialName(chatIdField)
|
||||||
override val chatId: ChatIdentifier,
|
override val chatId: ChatIdentifier,
|
||||||
@SerialName(stickerSetNameField)
|
@SerialName(stickerSetNameField)
|
||||||
val stickerSetName: String
|
val stickerSetName: StickerSetName
|
||||||
): ChatRequest, SimpleRequest<Boolean> {
|
): ChatRequest, SimpleRequest<Boolean> {
|
||||||
override fun method(): String = "setChatStickerSet"
|
override fun method(): String = "setChatStickerSet"
|
||||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
|
get() = BooleanSerializer
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
|||||||
import kotlinx.serialization.json.JsonObject
|
import kotlinx.serialization.json.JsonObject
|
||||||
|
|
||||||
data class CommonMultipartFileRequest<T: Any>(
|
data class CommonMultipartFileRequest<T: Any>(
|
||||||
val data: Request<T>,
|
val data: SimpleRequest<T>,
|
||||||
override val mediaMap: Map<String, MultipartFile>
|
override val mediaMap: Map<String, MultipartFile>
|
||||||
) : MultipartRequest<T>, Request<T> by data {
|
) : MultipartRequest<T>, Request<T> by data {
|
||||||
override val paramsJson: JsonObject = data.json()
|
override val paramsJson: JsonObject = data.json()
|
||||||
@@ -3,7 +3,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.LiveLocation
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
@@ -20,5 +21,8 @@ data class EditChatMessageLiveLocation(
|
|||||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) : EditChatMessage, EditReplyMessage, EditLocationMessage {
|
) : EditChatMessage, EditReplyMessage, EditLocationMessage {
|
||||||
override fun method(): String = "editMessageLiveLocation"
|
override fun method(): String = "editMessageLiveLocation"
|
||||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
override val resultDeserializer: DeserializationStrategy<Message>
|
||||||
|
get() = TelegramBotAPIMessageDeserializationStrategy
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
}
|
}
|
||||||
@@ -3,8 +3,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.LiveLocation
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.Serializable
|
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class EditInlineMessageLiveLocation(
|
data class EditInlineMessageLiveLocation(
|
||||||
@@ -18,4 +17,6 @@ data class EditInlineMessageLiveLocation(
|
|||||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) : EditInlineMessage, EditReplyMessage, EditLocationMessage {
|
) : EditInlineMessage, EditReplyMessage, EditLocationMessage {
|
||||||
override fun method(): String = "editMessageLiveLocation"
|
override fun method(): String = "editMessageLiveLocation"
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditCh
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditReplyMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditReplyMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
@@ -17,5 +18,8 @@ data class StopChatMessageLiveLocation(
|
|||||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) : EditChatMessage, EditReplyMessage {
|
) : EditChatMessage, EditReplyMessage {
|
||||||
override fun method(): String = "stopMessageLiveLocation"
|
override fun method(): String = "stopMessageLiveLocation"
|
||||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
override val resultDeserializer: DeserializationStrategy<Message>
|
||||||
|
get() = TelegramBotAPIMessageDeserializationStrategy
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
}
|
}
|
||||||
@@ -4,8 +4,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditIn
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditReplyMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditReplyMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.Serializable
|
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class StopInlineMessageLiveLocation(
|
data class StopInlineMessageLiveLocation(
|
||||||
@@ -15,4 +14,6 @@ data class StopInlineMessageLiveLocation(
|
|||||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) : EditInlineMessage, EditReplyMessage {
|
) : EditInlineMessage, EditReplyMessage {
|
||||||
override fun method(): String = "stopMessageLiveLocation"
|
override fun method(): String = "stopMessageLiveLocation"
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditCh
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditReplyMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditReplyMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
const val editMessageReplyMarkupMethod = "editMessageReplyMarkup"
|
const val editMessageReplyMarkupMethod = "editMessageReplyMarkup"
|
||||||
@@ -20,5 +21,8 @@ data class EditChatMessageReplyMarkup(
|
|||||||
) : EditChatMessage, EditReplyMessage {
|
) : EditChatMessage, EditReplyMessage {
|
||||||
|
|
||||||
override fun method(): String = editMessageReplyMarkupMethod
|
override fun method(): String = editMessageReplyMarkupMethod
|
||||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
override val resultDeserializer: DeserializationStrategy<Message>
|
||||||
|
get() = TelegramBotAPIMessageDeserializationStrategy
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
}
|
}
|
||||||
@@ -4,8 +4,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditIn
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditReplyMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditReplyMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.Serializable
|
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class EditInlineMessageReplyMarkup(
|
data class EditInlineMessageReplyMarkup(
|
||||||
@@ -15,4 +14,6 @@ data class EditInlineMessageReplyMarkup(
|
|||||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) : EditInlineMessage, EditReplyMessage {
|
) : EditInlineMessage, EditReplyMessage {
|
||||||
override fun method(): String = editMessageReplyMarkupMethod
|
override fun method(): String = editMessageReplyMarkupMethod
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,6 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts
|
|||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.MessageAction
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.MessageAction
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
|
|
||||||
interface EditChatMessage : SimpleRequest<RawMessage>, MessageAction
|
interface EditChatMessage : SimpleRequest<Message>, MessageAction
|
||||||
@@ -2,10 +2,11 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts
|
|||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineMessageIdentifier
|
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineMessageIdentifier
|
||||||
import kotlinx.serialization.KSerializer
|
import kotlinx.serialization.DeserializationStrategy
|
||||||
import kotlinx.serialization.internal.BooleanSerializer
|
import kotlinx.serialization.internal.BooleanSerializer
|
||||||
|
|
||||||
interface EditInlineMessage : SimpleRequest<Boolean> {
|
interface EditInlineMessage : SimpleRequest<Boolean> {
|
||||||
val inlineMessageId: InlineMessageIdentifier
|
val inlineMessageId: InlineMessageIdentifier
|
||||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
|
get() = BooleanSerializer
|
||||||
}
|
}
|
||||||
@@ -5,7 +5,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
const val editMessageCaptionMethod = "editMessageCaption"
|
const val editMessageCaptionMethod = "editMessageCaption"
|
||||||
@@ -25,5 +26,8 @@ data class EditChatMessageCaption(
|
|||||||
) : EditChatMessage, EditTextChatMessage, EditReplyMessage {
|
) : EditChatMessage, EditTextChatMessage, EditReplyMessage {
|
||||||
|
|
||||||
override fun method(): String = editMessageCaptionMethod
|
override fun method(): String = editMessageCaptionMethod
|
||||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
override val resultDeserializer: DeserializationStrategy<Message>
|
||||||
|
get() = TelegramBotAPIMessageDeserializationStrategy
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
}
|
}
|
||||||
@@ -5,8 +5,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.Serializable
|
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class EditInlineMessageCaption(
|
data class EditInlineMessageCaption(
|
||||||
@@ -20,4 +19,6 @@ data class EditInlineMessageCaption(
|
|||||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) : EditInlineMessage, EditTextChatMessage, EditReplyMessage {
|
) : EditInlineMessage, EditTextChatMessage, EditReplyMessage {
|
||||||
override fun method(): String = editMessageCaptionMethod
|
override fun method(): String = editMessageCaptionMethod
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
}
|
}
|
||||||
@@ -5,7 +5,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.*
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.InputMedia
|
import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.InputMedia
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
const val editMessageMediaMethod = "editMessageMedia"
|
const val editMessageMediaMethod = "editMessageMedia"
|
||||||
@@ -29,5 +30,8 @@ data class EditChatMessageMedia(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun method(): String = editMessageMediaMethod
|
override fun method(): String = editMessageMediaMethod
|
||||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
override val resultDeserializer: DeserializationStrategy<Message>
|
||||||
|
get() = TelegramBotAPIMessageDeserializationStrategy
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
}
|
}
|
||||||
@@ -5,8 +5,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.*
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.InputMedia
|
import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.InputMedia
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.Serializable
|
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class EditInlineMessageMedia(
|
data class EditInlineMessageMedia(
|
||||||
@@ -23,6 +22,8 @@ data class EditInlineMessageMedia(
|
|||||||
throw IllegalArgumentException("For editing of media messages you MUST use file id (according to documentation)")
|
throw IllegalArgumentException("For editing of media messages you MUST use file id (according to documentation)")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
|
|
||||||
override fun method(): String = editMessageMediaMethod
|
override fun method(): String = editMessageMediaMethod
|
||||||
}
|
}
|
||||||
@@ -5,7 +5,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
const val editMessageTextMethod = "editMessageText"
|
const val editMessageTextMethod = "editMessageText"
|
||||||
@@ -27,5 +28,8 @@ data class EditChatMessageText(
|
|||||||
) : EditChatMessage, EditTextChatMessage, EditReplyMessage, EditDisableWebPagePreviewMessage {
|
) : EditChatMessage, EditTextChatMessage, EditReplyMessage, EditDisableWebPagePreviewMessage {
|
||||||
|
|
||||||
override fun method(): String = editMessageTextMethod
|
override fun method(): String = editMessageTextMethod
|
||||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
override val resultDeserializer: DeserializationStrategy<Message>
|
||||||
|
get() = TelegramBotAPIMessageDeserializationStrategy
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
}
|
}
|
||||||
@@ -6,8 +6,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.Serializable
|
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class EditInlineMessageText(
|
data class EditInlineMessageText(
|
||||||
@@ -23,4 +22,6 @@ data class EditInlineMessageText(
|
|||||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) : EditInlineMessage, EditTextChatMessage, EditReplyMessage, EditDisableWebPagePreviewMessage {
|
) : EditInlineMessage, EditTextChatMessage, EditReplyMessage, EditDisableWebPagePreviewMessage {
|
||||||
override fun method(): String = editMessageMediaMethod
|
override fun method(): String = editMessageMediaMethod
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
}
|
}
|
||||||
@@ -3,8 +3,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.games
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.MessageAction
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.MessageAction
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.games.abstracts.GetGameHighScores
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.games.abstracts.GetGameHighScores
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.Serializable
|
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class GetGameHighScoresByChat (
|
data class GetGameHighScoresByChat (
|
||||||
@@ -14,4 +13,7 @@ data class GetGameHighScoresByChat (
|
|||||||
override val chatId: ChatId,
|
override val chatId: ChatId,
|
||||||
@SerialName(messageIdField)
|
@SerialName(messageIdField)
|
||||||
override val messageId: MessageIdentifier
|
override val messageId: MessageIdentifier
|
||||||
) : GetGameHighScores, MessageAction
|
) : GetGameHighScores, MessageAction {
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
|
}
|
||||||
@@ -3,8 +3,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.games
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.InlineMessageAction
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.InlineMessageAction
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.games.abstracts.GetGameHighScores
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.games.abstracts.GetGameHighScores
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.Serializable
|
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class GetGameHighScoresByInlineMessageId (
|
data class GetGameHighScoresByInlineMessageId (
|
||||||
@@ -12,4 +11,7 @@ data class GetGameHighScoresByInlineMessageId (
|
|||||||
override val userId: UserId,
|
override val userId: UserId,
|
||||||
@SerialName(inlineMessageIdField)
|
@SerialName(inlineMessageIdField)
|
||||||
override val inlineMessageId: InlineMessageIdentifier
|
override val inlineMessageId: InlineMessageIdentifier
|
||||||
) : GetGameHighScores, InlineMessageAction
|
) : GetGameHighScores, InlineMessageAction {
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
|
}
|
||||||
@@ -3,8 +3,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.games
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.MessageAction
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.MessageAction
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.games.abstracts.SetGameScore
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.games.abstracts.SetGameScore
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.Serializable
|
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class SetGameScoreByChatId (
|
data class SetGameScoreByChatId (
|
||||||
@@ -20,4 +19,7 @@ data class SetGameScoreByChatId (
|
|||||||
override val force: Boolean = false,
|
override val force: Boolean = false,
|
||||||
@SerialName(disableEditMessageField)
|
@SerialName(disableEditMessageField)
|
||||||
override val disableEditMessage: Boolean = false
|
override val disableEditMessage: Boolean = false
|
||||||
) : SetGameScore, MessageAction
|
) : SetGameScore, MessageAction {
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user