mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-11-18 04:50:20 +00:00
Compare commits
77 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 34f606545e | |||
| 0e33b123e9 | |||
| d6bbb0cadc | |||
| 8fd6a09763 | |||
| aa333d7c58 | |||
| fe8c3392fa | |||
| c2c7ac0d1e | |||
| 04e4407b96 | |||
| 60a30f972f | |||
| 9ed1500bee | |||
| 7d0009039f | |||
| e43ad41d2f | |||
| c7d5fdd2e0 | |||
| e7bdc85279 | |||
| dcfa198c8c | |||
| a846d0031c | |||
| 0dd632eb46 | |||
| dfe5595fd3 | |||
| 945dd05cfd | |||
| 09c623c1d7 | |||
| 269a4dd707 | |||
| 2399dc0d0a | |||
| 3a0be49cc5 | |||
| 28898ea2d4 | |||
| 679f282bd2 | |||
| 02fa83c92a | |||
| 69f81785bf | |||
| 86f1e3ea36 | |||
| be4043f3c2 | |||
| b4d0ca507b | |||
| cc433d4091 | |||
| f8ffd5fec3 | |||
| 799eadd7a7 | |||
| bc7cfc0d32 | |||
| 4ca8125637 | |||
| 5475f27a24 | |||
| 6d425cc0f6 | |||
| ff3ef6e957 | |||
| 28eecfa3ef | |||
| 56663d8e73 | |||
| 2fd842746b | |||
| 5e5dc105a5 | |||
| 6cf836708d | |||
| 5e6ff01940 | |||
| 2cfabb1c2a | |||
| de1d6aa70c | |||
| 90d5833021 | |||
| 527b718f55 | |||
| 2eb2d25662 | |||
| 9c25254937 | |||
| 601958a513 | |||
| ab6688bbaa | |||
| f2701b920f | |||
| a3b29f7db5 | |||
| 43a36072f1 | |||
| 0c11be7fe4 | |||
| 7a880ba2bd | |||
| 1a258ae912 | |||
| 9dc3e1ecc6 | |||
| b9e674821b | |||
| f4a731940e | |||
| 43ef7656d0 | |||
| b9ab7f2955 | |||
| 00886dcfb7 | |||
| 46573512a2 | |||
| a8ae0a296a | |||
| 8687a2ba6b | |||
| dbd9c72249 | |||
| 7aef76f432 | |||
| aece0784ab | |||
| 4e1dbb8741 | |||
| 41db785696 | |||
| 4e39f77b53 | |||
| 258ab44bac | |||
| 423efafa04 | |||
| 229334e781 | |||
| c4f22c2c43 |
50
CHANGELOG.md
50
CHANGELOG.md
@@ -1,5 +1,55 @@
|
|||||||
# TelegramBotAPI changelog
|
# TelegramBotAPI changelog
|
||||||
|
|
||||||
|
## 0.23.0 TelegramBotAPI 4.6
|
||||||
|
|
||||||
|
* `Poll` now is sealed class
|
||||||
|
* `RegularPoll` type was added to represent polls with type `regular`
|
||||||
|
* `QuizPoll` type was added to represent polls with type `quiz`
|
||||||
|
* `UnknownPollType` type was added to represent polls which are unknown in current version
|
||||||
|
* `AnonymousPollOption` was renamed to `SimplePollOption`
|
||||||
|
* `SendPoll` was rewritten as sealed class
|
||||||
|
* `SendRegularPoll` was created and represent `sendPoll` method with type `regular`
|
||||||
|
* `SendQuizPoll` was created and represent `sendPoll` method with type `quiz`
|
||||||
|
* `Poll#createRequest` extension was added
|
||||||
|
* `PollAnswerUpdate` type of update was added
|
||||||
|
* `PollAnswer` type was added
|
||||||
|
* `UpdatesFilter` now support work with `PollAnswerUpdate`
|
||||||
|
* `language` field in PreTextSource now correctly passed from telegram MessageEntities
|
||||||
|
* `KeyboardButton` now is sealed class
|
||||||
|
* Fixed problem of incorrect representation of this class (any type of request can be created separately)
|
||||||
|
* Added new types of `KeyboardButton`:
|
||||||
|
* `UnknownKeyboardButton`
|
||||||
|
* `SimpleKeyboardButton`
|
||||||
|
* `RequestContactKeyboardButton`
|
||||||
|
* `RequestLocationKeyboardButton`
|
||||||
|
* `RequestPollKeyboardButton`
|
||||||
|
* Added new type `KeyboardButtonPollType`:
|
||||||
|
* `UnknownKeyboardButtonPollType`
|
||||||
|
* `RegularKeyboardButtonPollType`
|
||||||
|
* `QuizKeyboardButtonPollType`
|
||||||
|
* `User` now is sealed class
|
||||||
|
* `CommonUser` was added as representation of default `User`
|
||||||
|
* `Bot` was added as representation of bot user (it is sealed class)
|
||||||
|
* `ExtendedBot` with additional info
|
||||||
|
* `CommonBot` with simple info
|
||||||
|
* `GetMe` now return `ExtendedBot` object
|
||||||
|
* Now extension `javaLocale` is extension for `CommonUser`
|
||||||
|
|
||||||
|
### 0.23.1
|
||||||
|
|
||||||
|
* Versions updates:
|
||||||
|
* Klock `1.8.6` -> `1.8.7`
|
||||||
|
* Ktor `1.3.0` -> `1.3.1`
|
||||||
|
* Now it is possible to get updates by polling with custom executor engine
|
||||||
|
* `CommonMultipartFileRequest` now is internal
|
||||||
|
* Added `LiveLocation` class for more useful tracking live locations
|
||||||
|
* `InvoiceOfPayment` is renamed to `InvoiceContent` and now is `MessageContent` instead of `PaymentInfo`
|
||||||
|
* `SendInvoice` now return `ContentMessage<InvoiceContent>`
|
||||||
|
* `paymentInfo` inside of `CommonMessageImpl` now can be set only to `SuccessfulPaymentInfo`
|
||||||
|
* Added `RecordVideoNoteAction` and `UploadVideoNoteAction` for `record_video_note` and `upload_video_note` actions
|
||||||
|
* For most part of messages was added `RequestsExecutor` extensions for more useful way of usage
|
||||||
|
* `toInputFile` extensions now will return more exact types
|
||||||
|
|
||||||
## 0.22.0
|
## 0.22.0
|
||||||
|
|
||||||
* **`KtorCallFactory` must return `HttpStatement` instead of `HttpClientCall`**
|
* **`KtorCallFactory` must return `HttpStatement` instead of `HttpClientCall`**
|
||||||
|
|||||||
49
README.md
49
README.md
@@ -10,9 +10,9 @@ moments are describing by official [Telegram Bot API](https://core.telegram.org/
|
|||||||
|
|
||||||
## Compatibility
|
## Compatibility
|
||||||
|
|
||||||
This version compatible with [31th of December 2019 update of TelegramBotAPI (version 4.5)](https://core.telegram.org/bots/api#december-31-2019).
|
This version compatible with [23th of January 2020 update of TelegramBotAPI (version 4.6)](https://core.telegram.org/bots/api#january-23-2020).
|
||||||
There is Telegram Passport API exception of implemented functionality, 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-changelog#august-27-2018) update. It will be implemented
|
||||||
as soon as possible. All APIs that are not included are presented
|
as soon as possible. All APIs that are not included are presented
|
||||||
[wiki](https://github.com/InsanusMokrassar/TelegramBotAPI/wiki/Not-included-API).
|
[wiki](https://github.com/InsanusMokrassar/TelegramBotAPI/wiki/Not-included-API).
|
||||||
|
|
||||||
@@ -76,10 +76,10 @@ important objects:
|
|||||||
Types declare different objects representation. For example, `Chat` for now represented as
|
Types declare different objects representation. For example, `Chat` for now represented as
|
||||||
interface and has several realisations:
|
interface and has several realisations:
|
||||||
|
|
||||||
* PrivateChat
|
* `PrivateChat`
|
||||||
* GroupChat
|
* `GroupChat`
|
||||||
* SupergroupChat
|
* `SupergroupChat`
|
||||||
* ChannelChat
|
* `ChannelChat`
|
||||||
|
|
||||||
Instead of common garbage with all information as in original [Chat](https://core.telegram.org/bots/api#chat),
|
Instead of common garbage with all information as in original [Chat](https://core.telegram.org/bots/api#chat),
|
||||||
here it was separated for more obvious difference between chats types and their possible content.
|
here it was separated for more obvious difference between chats types and their possible content.
|
||||||
@@ -96,10 +96,16 @@ val requestsExecutor: RequestsExecutor = ...
|
|||||||
requestsExecutor.execute(GetMe())
|
requestsExecutor.execute(GetMe())
|
||||||
```
|
```
|
||||||
|
|
||||||
The result type of [GetMe](https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/GetMe.kt) request is
|
Or you can use new syntax:
|
||||||
[User](https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/User.kt). In fact, in this result must contain
|
|
||||||
`isBot` equal to `true` always.
|
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
val bot: RequestsExecutor = ...
|
||||||
|
bot.getMe()
|
||||||
|
```
|
||||||
|
|
||||||
|
The result type of [GetMe (and getMe extension)](https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/GetMe.kt)
|
||||||
|
request is
|
||||||
|
[ExtendedBot](https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/User.kt).
|
||||||
|
|
||||||
### RequestsExecutor
|
### RequestsExecutor
|
||||||
|
|
||||||
@@ -108,31 +114,38 @@ realisation of `RequestsExecutor`, but it is possible, that in future it will be
|
|||||||
project. How to create `RequestsExecutor`:
|
project. How to create `RequestsExecutor`:
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
val requestsExecutor = KtorRequestsExecutor(TOKEN)
|
val requestsExecutor = KtorRequestsExecutor(
|
||||||
|
TelegramAPIUrlsKeeper(TOKEN)
|
||||||
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
Here `KtorRequestsExecutor` - default realisation with Ktor. `TOKEN` is just a token of bot which was retrieved
|
Here:
|
||||||
according to [instruction](https://core.telegram.org/bots#3-how-do-i-create-a-bot).
|
|
||||||
|
|
||||||
Besides, for correct usage of this, you must implement in your project both one of engines for client and server
|
* `KtorRequestsExecutor` - default realisation with [ktor](https://ktor.io)
|
||||||
Ktor libraries:
|
* `TelegramAPIUrlsKeeper` - special keeper, which you can save and use for getting files full urls (`resolveFileURL`
|
||||||
|
extension inside of `PathedFile.kt`)
|
||||||
|
* `TOKEN` is just a token of bot which was retrieved according to
|
||||||
|
[instruction](https://core.telegram.org/bots#3-how-do-i-create-a-bot).
|
||||||
|
|
||||||
|
By default, for JVM there is implemented `CIO` client engine, but there is not server engine. Both can be changed like
|
||||||
|
here:
|
||||||
|
|
||||||
```groovy
|
```groovy
|
||||||
dependencies {
|
dependencies {
|
||||||
// ...
|
// ...
|
||||||
implementation "io.ktor:ktor-server-cio:$ktor_version"
|
implementation "io.ktor:ktor-server-cio:$ktor_version" // for implementing of server engine
|
||||||
implementation "io.ktor:ktor-client-okhttp:$ktor_version"
|
implementation "io.ktor:ktor-client-okhttp:$ktor_version" // for implementing of additional client engine
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
It is able to avoid using of `server` dependency in case if will not be used `Webhook`s. In this case,
|
You can avoid using of `server` dependency in case if you will not use `Webhook`s. In this case,
|
||||||
dependencies list will be simplify:
|
dependencies list will be simplify:
|
||||||
|
|
||||||
```groovy
|
```groovy
|
||||||
dependencies {
|
dependencies {
|
||||||
// ...
|
// ...
|
||||||
implementation "io.ktor:ktor-client-okhttp:$ktor_version"
|
implementation "io.ktor:ktor-client-okhttp:$ktor_version" // for implementing of additional client engine
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ plugins {
|
|||||||
id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version"
|
id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version"
|
||||||
}
|
}
|
||||||
|
|
||||||
project.version = "0.22.2"
|
project.version = "0.23.1"
|
||||||
project.group = "com.github.insanusmokrassar"
|
project.group = "com.github.insanusmokrassar"
|
||||||
|
|
||||||
apply from: "publish.gradle"
|
apply from: "publish.gradle"
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ kotlin.code.style=official
|
|||||||
kotlin_version=1.3.61
|
kotlin_version=1.3.61
|
||||||
kotlin_coroutines_version=1.3.3
|
kotlin_coroutines_version=1.3.3
|
||||||
kotlin_serialisation_runtime_version=0.14.0
|
kotlin_serialisation_runtime_version=0.14.0
|
||||||
klock_version=1.8.6
|
klock_version=1.8.7
|
||||||
uuid_version=0.0.7
|
uuid_version=0.0.7
|
||||||
ktor_version=1.3.0
|
ktor_version=1.3.1
|
||||||
|
|
||||||
gradle_bintray_plugin_version=1.8.4
|
gradle_bintray_plugin_version=1.8.4
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests
|
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.bot.RequestsExecutor
|
||||||
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.chat.abstracts.Chat
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.BooleanSerializer
|
import kotlinx.serialization.internal.BooleanSerializer
|
||||||
|
|
||||||
@@ -20,3 +23,23 @@ data class DeleteMessage(
|
|||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.deleteMessage(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
messageId: MessageIdentifier
|
||||||
|
) = execute(
|
||||||
|
DeleteMessage(chatId, messageId)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.deleteMessage(
|
||||||
|
chat: Chat,
|
||||||
|
messageId: MessageIdentifier
|
||||||
|
) = deleteMessage(chat.id, messageId)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.deleteMessage(
|
||||||
|
message: Message
|
||||||
|
) = deleteMessage(message.chat, message.messageId)
|
||||||
|
|
||||||
|
suspend fun Message.delete(
|
||||||
|
requestsExecutor: RequestsExecutor
|
||||||
|
) = requestsExecutor.deleteMessage(this)
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests
|
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.bot.RequestsExecutor
|
||||||
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.abstracts.PossiblyForwardedMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
@@ -30,3 +32,45 @@ data class ForwardMessage(
|
|||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.forwardMessage(
|
||||||
|
fromChatId: ChatIdentifier,
|
||||||
|
toChatId: ChatIdentifier,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
disableNotification: Boolean = false
|
||||||
|
) = execute(
|
||||||
|
ForwardMessage(fromChatId, toChatId, messageId, disableNotification)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.forwardMessage(
|
||||||
|
fromChat: Chat,
|
||||||
|
toChatId: ChatIdentifier,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
disableNotification: Boolean = false
|
||||||
|
) = forwardMessage(fromChat.id, toChatId, messageId, disableNotification)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.forwardMessage(
|
||||||
|
fromChatId: ChatIdentifier,
|
||||||
|
toChat: Chat,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
disableNotification: Boolean = false
|
||||||
|
) = forwardMessage(fromChatId, toChat.id, messageId, disableNotification)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.forwardMessage(
|
||||||
|
fromChat: Chat,
|
||||||
|
toChat: Chat,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
disableNotification: Boolean = false
|
||||||
|
) = forwardMessage(fromChat.id, toChat.id, messageId, disableNotification)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.forwardMessage(
|
||||||
|
toChatId: ChatIdentifier,
|
||||||
|
message: Message,
|
||||||
|
disableNotification: Boolean = false
|
||||||
|
) = forwardMessage(message.chat, toChatId, message.messageId, disableNotification)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.forwardMessage(
|
||||||
|
toChat: Chat,
|
||||||
|
message: Message,
|
||||||
|
disableNotification: Boolean = false
|
||||||
|
) = forwardMessage(message.chat, toChat, message.messageId, disableNotification)
|
||||||
|
|||||||
@@ -1,14 +1,17 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests
|
package com.github.insanusmokrassar.TelegramBotAPI.requests
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
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.*
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
class GetMe : SimpleRequest<User> {
|
class GetMe : SimpleRequest<ExtendedBot> {
|
||||||
override fun method(): String = "getMe"
|
override fun method(): String = "getMe"
|
||||||
override val resultDeserializer: DeserializationStrategy<User>
|
override val resultDeserializer: DeserializationStrategy<ExtendedBot>
|
||||||
get() = User.serializer()
|
get() = ExtendedBot.serializer()
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getMe() = execute(GetMe())
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests
|
package com.github.insanusmokrassar.TelegramBotAPI.requests
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ALL_UPDATES_LIST
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ALL_UPDATES_LIST
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier
|
import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier
|
||||||
@@ -27,3 +28,23 @@ data class GetUpdates(
|
|||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getUpdates(
|
||||||
|
offset: UpdateIdentifier? = null,
|
||||||
|
limit: Int? = null,
|
||||||
|
timeout: Int? = null,
|
||||||
|
allowed_updates: List<String>? = ALL_UPDATES_LIST
|
||||||
|
) = execute(
|
||||||
|
GetUpdates(
|
||||||
|
offset, limit, timeout, allowed_updates
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getUpdates(
|
||||||
|
lastUpdate: Update,
|
||||||
|
limit: Int? = null,
|
||||||
|
timeout: Int? = null,
|
||||||
|
allowed_updates: List<String>? = ALL_UPDATES_LIST
|
||||||
|
) = getUpdates(
|
||||||
|
lastUpdate.updateId + 1, limit, timeout, allowed_updates
|
||||||
|
)
|
||||||
|
|||||||
@@ -0,0 +1,133 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.requests
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.LiveLocation.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.SendLocation
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.LocationContent
|
||||||
|
import com.soywiz.klock.DateTime
|
||||||
|
import com.soywiz.klock.TimeSpan
|
||||||
|
import io.ktor.utils.io.core.Closeable
|
||||||
|
import kotlinx.coroutines.*
|
||||||
|
import kotlin.math.ceil
|
||||||
|
|
||||||
|
private val livePeriodDelayMillis = (livePeriodLimit.last - 60L) * 1000L
|
||||||
|
class LiveLocation internal constructor(
|
||||||
|
private val requestsExecutor: RequestsExecutor,
|
||||||
|
scope: CoroutineScope,
|
||||||
|
autoCloseTimeDelay: Double,
|
||||||
|
initMessage: ContentMessage<LocationContent>
|
||||||
|
) : Closeable {
|
||||||
|
private val doWhenClose = {
|
||||||
|
scope.launch {
|
||||||
|
requestsExecutor.stopLiveLocation(message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private val autoCloseTime = DateTime.now() + TimeSpan(autoCloseTimeDelay)
|
||||||
|
val leftUntilCloseMillis: TimeSpan
|
||||||
|
get() = autoCloseTime - DateTime.now()
|
||||||
|
|
||||||
|
var isClosed: Boolean = false
|
||||||
|
private set
|
||||||
|
get() = field || leftUntilCloseMillis.millisecondsLong < 0L
|
||||||
|
|
||||||
|
private var message: ContentMessage<LocationContent> = initMessage
|
||||||
|
val lastLocation: Location
|
||||||
|
get() = message.content.location
|
||||||
|
|
||||||
|
suspend fun updateLocation(
|
||||||
|
location: Location,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
): Location {
|
||||||
|
if (!isClosed) {
|
||||||
|
message = requestsExecutor.editLiveLocation(
|
||||||
|
message,
|
||||||
|
location,
|
||||||
|
replyMarkup
|
||||||
|
)
|
||||||
|
return lastLocation
|
||||||
|
} else {
|
||||||
|
error("LiveLocation is closed")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun close() {
|
||||||
|
if (isClosed) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
isClosed = true
|
||||||
|
doWhenClose()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.startLiveLocation(
|
||||||
|
scope: CoroutineScope,
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
latitude: Double,
|
||||||
|
longitude: Double,
|
||||||
|
liveTimeMillis: Long = livePeriodDelayMillis,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
): LiveLocation {
|
||||||
|
val liveTimeAsDouble = liveTimeMillis.toDouble()
|
||||||
|
val locationMessage = execute(
|
||||||
|
SendLocation(
|
||||||
|
chatId,
|
||||||
|
latitude,
|
||||||
|
longitude,
|
||||||
|
ceil(liveTimeAsDouble / 1000).toLong(),
|
||||||
|
disableNotification,
|
||||||
|
replyToMessageId,
|
||||||
|
replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
return LiveLocation(
|
||||||
|
this,
|
||||||
|
scope,
|
||||||
|
liveTimeAsDouble,
|
||||||
|
locationMessage
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.startLiveLocation(
|
||||||
|
scope: CoroutineScope,
|
||||||
|
chat: Chat,
|
||||||
|
latitude: Double,
|
||||||
|
longitude: Double,
|
||||||
|
liveTimeMillis: Long = livePeriodDelayMillis,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
): LiveLocation = startLiveLocation(
|
||||||
|
scope, chat.id, latitude, longitude, liveTimeMillis, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.startLiveLocation(
|
||||||
|
scope: CoroutineScope,
|
||||||
|
chatId: ChatId,
|
||||||
|
location: Location,
|
||||||
|
liveTimeMillis: Long = livePeriodDelayMillis,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
): LiveLocation = startLiveLocation(
|
||||||
|
scope, chatId, location.latitude, location.longitude, liveTimeMillis, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.startLiveLocation(
|
||||||
|
scope: CoroutineScope,
|
||||||
|
chat: Chat,
|
||||||
|
location: Location,
|
||||||
|
liveTimeMillis: Long = livePeriodDelayMillis,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
): LiveLocation = startLiveLocation(
|
||||||
|
scope, chat.id, location.latitude, location.longitude, liveTimeMillis, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
@@ -2,9 +2,13 @@ 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.CommonAbstracts.types.ReplyMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ReplyMarkup
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.ReplyMarkup.EditChatMessageReplyMarkup
|
||||||
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.chat.abstracts.Chat
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.polls.Poll
|
import com.github.insanusmokrassar.TelegramBotAPI.types.polls.Poll
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
@@ -23,3 +27,29 @@ data class StopPoll(
|
|||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.stopPoll(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
StopPoll(chatId, messageId, replyMarkup)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.stopPoll(
|
||||||
|
chat: Chat,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = stopPoll(chat.id, messageId, replyMarkup)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.stopPoll(
|
||||||
|
chatId: ChatId,
|
||||||
|
message: Message,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = stopPoll(chatId, message.messageId, replyMarkup)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.stopPoll(
|
||||||
|
chat: Chat,
|
||||||
|
message: Message,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = stopPoll(chat.id, message.messageId, replyMarkup)
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ data class FileId(
|
|||||||
override val fileId: String
|
override val fileId: String
|
||||||
) : InputFile()
|
) : InputFile()
|
||||||
|
|
||||||
fun String.toInputFile(): InputFile = FileId(this)
|
fun String.toInputFile() = FileId(this)
|
||||||
|
|
||||||
@Serializer(InputFile::class)
|
@Serializer(InputFile::class)
|
||||||
internal object InputFileSerializer : KSerializer<InputFile> {
|
internal object InputFileSerializer : KSerializer<InputFile> {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.answers
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.answers
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
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.CallbackQuery.CallbackQuery
|
import com.github.insanusmokrassar.TelegramBotAPI.types.CallbackQuery.CallbackQuery
|
||||||
@@ -32,3 +33,19 @@ fun CallbackQuery.createAnswer(
|
|||||||
url: String? = null,
|
url: String? = null,
|
||||||
cachedTimeSeconds: Int? = null
|
cachedTimeSeconds: Int? = null
|
||||||
): AnswerCallbackQuery = AnswerCallbackQuery(id, text, showAlert, url, cachedTimeSeconds)
|
): AnswerCallbackQuery = AnswerCallbackQuery(id, text, showAlert, url, cachedTimeSeconds)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.answerCallbackQuery(
|
||||||
|
callbackQueryId: CallbackQueryIdentifier,
|
||||||
|
text: String? = null,
|
||||||
|
showAlert: Boolean? = null,
|
||||||
|
url: String? = null,
|
||||||
|
cachedTimeSeconds: Int? = null
|
||||||
|
) = execute(AnswerCallbackQuery(callbackQueryId, text, showAlert, url, cachedTimeSeconds))
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.answerCallbackQuery(
|
||||||
|
callbackQuery: CallbackQuery,
|
||||||
|
text: String? = null,
|
||||||
|
showAlert: Boolean? = null,
|
||||||
|
url: String? = null,
|
||||||
|
cachedTimeSeconds: Int? = null
|
||||||
|
) = answerCallbackQuery(callbackQuery.id, text, showAlert, url, cachedTimeSeconds)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.answers
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.answers
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
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.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult
|
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult
|
||||||
@@ -51,6 +52,28 @@ fun InlineQuery.createAnswer(
|
|||||||
switchPmParameter
|
switchPmParameter
|
||||||
)
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.answerInlineQuery(
|
||||||
|
inlineQueryID: InlineQueryIdentifier,
|
||||||
|
results: List<InlineQueryResult> = emptyList(),
|
||||||
|
cachedTime: Int? = null,
|
||||||
|
isPersonal: Boolean? = null,
|
||||||
|
nextOffset: String? = null,
|
||||||
|
switchPmText: String? = null,
|
||||||
|
switchPmParameter: String? = null
|
||||||
|
) = execute(
|
||||||
|
AnswerInlineQuery(inlineQueryID, results, cachedTime, isPersonal, nextOffset, switchPmText, switchPmParameter)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.answerInlineQuery(
|
||||||
|
inlineQuery: InlineQuery,
|
||||||
|
results: List<InlineQueryResult> = emptyList(),
|
||||||
|
cachedTime: Int? = null,
|
||||||
|
isPersonal: Boolean? = null,
|
||||||
|
nextOffset: String? = null,
|
||||||
|
switchPmText: String? = null,
|
||||||
|
switchPmParameter: String? = null
|
||||||
|
) = answerInlineQuery(inlineQuery.id, results, cachedTime, isPersonal, nextOffset, switchPmText, switchPmParameter)
|
||||||
|
|
||||||
internal object InlineQueryAnswersResultsSerializer: KSerializer<List<InlineQueryResult>> by ArrayListSerializer(
|
internal object InlineQueryAnswersResultsSerializer: KSerializer<List<InlineQueryResult>> by ArrayListSerializer(
|
||||||
InlineQueryResultSerializer
|
InlineQueryResultSerializer
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.answers.payments
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.answers.payments
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
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.*
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
@@ -40,3 +41,19 @@ fun PreCheckoutQuery.createAnswerError(
|
|||||||
id,
|
id,
|
||||||
error
|
error
|
||||||
)
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.answerPreCheckoutQueryOk(
|
||||||
|
id: PreCheckoutQueryId
|
||||||
|
) = execute(AnswerPreCheckoutQueryOk(id))
|
||||||
|
suspend fun RequestsExecutor.answerPreCheckoutQueryOk(
|
||||||
|
preCheckoutQuery: PreCheckoutQuery
|
||||||
|
) = answerPreCheckoutQueryOk(preCheckoutQuery.id)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.answerPreCheckoutQueryError(
|
||||||
|
id: PreCheckoutQueryId,
|
||||||
|
error: String
|
||||||
|
) = execute(AnswerPreCheckoutQueryError(id, error))
|
||||||
|
suspend fun RequestsExecutor.answerPreCheckoutQueryError(
|
||||||
|
preCheckoutQuery: PreCheckoutQuery,
|
||||||
|
error: String
|
||||||
|
) = answerPreCheckoutQueryError(preCheckoutQuery.id, error)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.answers.payments
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.answers.payments
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.answers.payments.abstracts.AnswerShippingQuery
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.answers.payments.abstracts.AnswerShippingQuery
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.ShippingOption
|
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.ShippingOption
|
||||||
@@ -51,3 +52,23 @@ fun ShippingQuery.createAnswerError(
|
|||||||
id,
|
id,
|
||||||
error
|
error
|
||||||
)
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.answerShippingQueryOk(
|
||||||
|
id: ShippingQueryIdentifier,
|
||||||
|
shippingOptions: List<ShippingOption>
|
||||||
|
) = execute(AnswerShippingQueryOk(id, shippingOptions))
|
||||||
|
suspend fun RequestsExecutor.answerShippingQueryOk(
|
||||||
|
shippingQuery: ShippingQuery,
|
||||||
|
shippingOptions: List<ShippingOption>
|
||||||
|
) = answerShippingQueryOk(shippingQuery.id, shippingOptions)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.answerShippingQueryError(
|
||||||
|
id: ShippingQueryIdentifier,
|
||||||
|
error: String
|
||||||
|
) = execute(AnswerShippingQueryError(id, error))
|
||||||
|
suspend fun RequestsExecutor.answerShippingQueryError(
|
||||||
|
shippingQuery: ShippingQuery,
|
||||||
|
error: String
|
||||||
|
) = answerShippingQueryError(shippingQuery.id, error)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
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.abstracts.Chat
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.StringSerializer
|
import kotlinx.serialization.internal.StringSerializer
|
||||||
@@ -18,3 +21,11 @@ data class ExportChatInviteLink(
|
|||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.exportChatInviteLink(
|
||||||
|
chatId: ChatIdentifier
|
||||||
|
) = execute(ExportChatInviteLink(chatId))
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.exportChatInviteLink(
|
||||||
|
chat: PublicChat
|
||||||
|
) = exportChatInviteLink(chat.id)
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
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.abstracts.Chat
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.BooleanSerializer
|
import kotlinx.serialization.internal.BooleanSerializer
|
||||||
@@ -18,3 +21,11 @@ data class LeaveChat(
|
|||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.leaveChat(
|
||||||
|
chatId: ChatIdentifier
|
||||||
|
) = execute(LeaveChat(chatId))
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.leaveChat(
|
||||||
|
chat: PublicChat
|
||||||
|
) = leaveChat(chat.id)
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.get
|
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.bot.RequestsExecutor
|
||||||
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.ExtendedChatSerializer
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.ExtendedChatSerializer
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.extended.ExtendedChat
|
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.*
|
||||||
@@ -19,3 +21,11 @@ data class GetChat(
|
|||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getChat(
|
||||||
|
chatId: ChatIdentifier
|
||||||
|
) = execute(GetChat(chatId))
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getChat(
|
||||||
|
chat: Chat
|
||||||
|
) = getChat(chat.id)
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.get
|
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.bot.RequestsExecutor
|
||||||
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.abstracts.AdministratorChatMember
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.AdministratorChatMember
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.AdministratorChatMemberSerializerWithoutDeserialization
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.AdministratorChatMemberSerializerWithoutDeserialization
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||||
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
|
||||||
@@ -24,3 +27,11 @@ data class GetChatAdministrators(
|
|||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getChatAdministrators(
|
||||||
|
chatId: ChatIdentifier
|
||||||
|
) = execute(GetChatAdministrators(chatId))
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getChatAdministrators(
|
||||||
|
chat: PublicChat
|
||||||
|
) = getChatAdministrators(chat.id)
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.get
|
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.bot.RequestsExecutor
|
||||||
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.abstracts.Chat
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.IntSerializer
|
import kotlinx.serialization.internal.IntSerializer
|
||||||
@@ -18,3 +21,11 @@ data class GetChatMembersCount(
|
|||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getChatMembersCount(
|
||||||
|
chatId: ChatIdentifier
|
||||||
|
) = execute(GetChatMembersCount(chatId))
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getChatMembersCount(
|
||||||
|
chat: PublicChat
|
||||||
|
) = getChatMembersCount(chat.id)
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.members
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.members
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.abstracts.ChatMemberRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.abstracts.ChatMemberRequest
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.get.getChatMembersCount
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.ChatMember
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.ChatMember
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.ChatMemberDeserializationStrategy
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.ChatMemberDeserializationStrategy
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
@@ -19,3 +23,23 @@ data class GetChatMember(
|
|||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getChatMember(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
userId: UserId
|
||||||
|
) = execute(GetChatMember(chatId, userId))
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getChatMember(
|
||||||
|
chat: PublicChat,
|
||||||
|
userId: UserId
|
||||||
|
) = getChatMember(chat.id, userId)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getChatMember(
|
||||||
|
chatId: ChatId,
|
||||||
|
user: User
|
||||||
|
) = getChatMember(chatId, user.id)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getChatMember(
|
||||||
|
chat: PublicChat,
|
||||||
|
user: User
|
||||||
|
) = getChatMember(chat.id, user.id)
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.members
|
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.bot.RequestsExecutor
|
||||||
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.abstracts.Chat
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.BooleanSerializer
|
import kotlinx.serialization.internal.BooleanSerializer
|
||||||
|
|
||||||
@@ -21,3 +24,27 @@ data class KickChatMember(
|
|||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.kickChatMember(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
userId: UserId,
|
||||||
|
untilDate: TelegramDate? = null
|
||||||
|
) = execute(KickChatMember(chatId, userId, untilDate))
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.kickChatMember(
|
||||||
|
chat: PublicChat,
|
||||||
|
userId: UserId,
|
||||||
|
untilDate: TelegramDate? = null
|
||||||
|
) = kickChatMember(chat.id, userId, untilDate)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.kickChatMember(
|
||||||
|
chatId: ChatId,
|
||||||
|
user: User,
|
||||||
|
untilDate: TelegramDate? = null
|
||||||
|
) = kickChatMember(chatId, user.id, untilDate)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.kickChatMember(
|
||||||
|
chat: PublicChat,
|
||||||
|
user: User,
|
||||||
|
untilDate: TelegramDate? = null
|
||||||
|
) = kickChatMember(chat.id, user.id, untilDate)
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.members
|
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.bot.RequestsExecutor
|
||||||
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.abstracts.Chat
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.BooleanSerializer
|
import kotlinx.serialization.internal.BooleanSerializer
|
||||||
|
|
||||||
@@ -37,3 +40,109 @@ data class PromoteChatMember(
|
|||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.promoteChatMember(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
userId: UserId,
|
||||||
|
untilDate: TelegramDate? = null,
|
||||||
|
canChangeInfo: Boolean? = null,
|
||||||
|
canPostMessages: Boolean? = null,
|
||||||
|
canEditMessages: Boolean? = null,
|
||||||
|
canDeleteMessages: Boolean? = null,
|
||||||
|
canInviteUsers: Boolean? = null,
|
||||||
|
canRestrictMembers: Boolean? = null,
|
||||||
|
canPinMessages: Boolean? = null,
|
||||||
|
canPromoteMembers: Boolean? = null
|
||||||
|
) = execute(
|
||||||
|
PromoteChatMember(
|
||||||
|
chatId,
|
||||||
|
userId,
|
||||||
|
untilDate,
|
||||||
|
canChangeInfo,
|
||||||
|
canPostMessages,
|
||||||
|
canEditMessages,
|
||||||
|
canDeleteMessages,
|
||||||
|
canInviteUsers,
|
||||||
|
canRestrictMembers,
|
||||||
|
canPinMessages,
|
||||||
|
canPromoteMembers
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.promoteChatMember(
|
||||||
|
chat: PublicChat,
|
||||||
|
userId: UserId,
|
||||||
|
untilDate: TelegramDate? = null,
|
||||||
|
canChangeInfo: Boolean? = null,
|
||||||
|
canPostMessages: Boolean? = null,
|
||||||
|
canEditMessages: Boolean? = null,
|
||||||
|
canDeleteMessages: Boolean? = null,
|
||||||
|
canInviteUsers: Boolean? = null,
|
||||||
|
canRestrictMembers: Boolean? = null,
|
||||||
|
canPinMessages: Boolean? = null,
|
||||||
|
canPromoteMembers: Boolean? = null
|
||||||
|
) = promoteChatMember(
|
||||||
|
chat.id,
|
||||||
|
userId,
|
||||||
|
untilDate,
|
||||||
|
canChangeInfo,
|
||||||
|
canPostMessages,
|
||||||
|
canEditMessages,
|
||||||
|
canDeleteMessages,
|
||||||
|
canInviteUsers,
|
||||||
|
canRestrictMembers,
|
||||||
|
canPinMessages,
|
||||||
|
canPromoteMembers
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.promoteChatMember(
|
||||||
|
chatId: ChatId,
|
||||||
|
user: User,
|
||||||
|
untilDate: TelegramDate? = null,
|
||||||
|
canChangeInfo: Boolean? = null,
|
||||||
|
canPostMessages: Boolean? = null,
|
||||||
|
canEditMessages: Boolean? = null,
|
||||||
|
canDeleteMessages: Boolean? = null,
|
||||||
|
canInviteUsers: Boolean? = null,
|
||||||
|
canRestrictMembers: Boolean? = null,
|
||||||
|
canPinMessages: Boolean? = null,
|
||||||
|
canPromoteMembers: Boolean? = null
|
||||||
|
) = promoteChatMember(
|
||||||
|
chatId,
|
||||||
|
user.id,
|
||||||
|
untilDate,
|
||||||
|
canChangeInfo,
|
||||||
|
canPostMessages,
|
||||||
|
canEditMessages,
|
||||||
|
canDeleteMessages,
|
||||||
|
canInviteUsers,
|
||||||
|
canRestrictMembers,
|
||||||
|
canPinMessages,
|
||||||
|
canPromoteMembers
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.promoteChatMember(
|
||||||
|
chat: PublicChat,
|
||||||
|
user: User,
|
||||||
|
untilDate: TelegramDate? = null,
|
||||||
|
canChangeInfo: Boolean? = null,
|
||||||
|
canPostMessages: Boolean? = null,
|
||||||
|
canEditMessages: Boolean? = null,
|
||||||
|
canDeleteMessages: Boolean? = null,
|
||||||
|
canInviteUsers: Boolean? = null,
|
||||||
|
canRestrictMembers: Boolean? = null,
|
||||||
|
canPinMessages: Boolean? = null,
|
||||||
|
canPromoteMembers: Boolean? = null
|
||||||
|
) = promoteChatMember(
|
||||||
|
chat.id,
|
||||||
|
user.id,
|
||||||
|
untilDate,
|
||||||
|
canChangeInfo,
|
||||||
|
canPostMessages,
|
||||||
|
canEditMessages,
|
||||||
|
canDeleteMessages,
|
||||||
|
canInviteUsers,
|
||||||
|
canRestrictMembers,
|
||||||
|
canPinMessages,
|
||||||
|
canPromoteMembers
|
||||||
|
)
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.members
|
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.bot.RequestsExecutor
|
||||||
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 com.github.insanusmokrassar.TelegramBotAPI.types.chat.ChatPermissions
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.BooleanSerializer
|
import kotlinx.serialization.internal.BooleanSerializer
|
||||||
|
|
||||||
@@ -16,7 +19,7 @@ data class RestrictChatMember(
|
|||||||
@SerialName(untilDateField)
|
@SerialName(untilDateField)
|
||||||
override val untilDate: TelegramDate? = null,
|
override val untilDate: TelegramDate? = null,
|
||||||
@SerialName(permissionsField)
|
@SerialName(permissionsField)
|
||||||
val permissions: ChatPermissions
|
val permissions: ChatPermissions = ChatPermissions()
|
||||||
) : ChatMemberRequest<Boolean>, UntilDate {
|
) : ChatMemberRequest<Boolean>, UntilDate {
|
||||||
override fun method(): String = "restrictChatMember"
|
override fun method(): String = "restrictChatMember"
|
||||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
@@ -24,3 +27,32 @@ data class RestrictChatMember(
|
|||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.restrictChatMember(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
userId: UserId,
|
||||||
|
untilDate: TelegramDate? = null,
|
||||||
|
permissions: ChatPermissions = ChatPermissions()
|
||||||
|
) = execute(RestrictChatMember(chatId, userId, untilDate, permissions))
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.restrictChatMember(
|
||||||
|
chat: PublicChat,
|
||||||
|
userId: UserId,
|
||||||
|
untilDate: TelegramDate? = null,
|
||||||
|
permissions: ChatPermissions = ChatPermissions()
|
||||||
|
) = restrictChatMember(chat.id, userId, untilDate, permissions)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.restrictChatMember(
|
||||||
|
chatId: ChatId,
|
||||||
|
user: User,
|
||||||
|
untilDate: TelegramDate? = null,
|
||||||
|
permissions: ChatPermissions = ChatPermissions()
|
||||||
|
) = restrictChatMember(chatId, user.id, untilDate, permissions)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.restrictChatMember(
|
||||||
|
chat: PublicChat,
|
||||||
|
user: User,
|
||||||
|
untilDate: TelegramDate? = null,
|
||||||
|
permissions: ChatPermissions = ChatPermissions()
|
||||||
|
) = restrictChatMember(chat.id, user.id, untilDate, permissions)
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.members
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.members
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
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.abstracts.Chat
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.BooleanSerializer
|
import kotlinx.serialization.internal.BooleanSerializer
|
||||||
|
|
||||||
@@ -13,7 +16,7 @@ import kotlinx.serialization.internal.BooleanSerializer
|
|||||||
@Serializable
|
@Serializable
|
||||||
data class SetChatAdministratorCustomTitle(
|
data class SetChatAdministratorCustomTitle(
|
||||||
@SerialName(chatIdField)
|
@SerialName(chatIdField)
|
||||||
override val chatId: ChatId,
|
override val chatId: ChatIdentifier,
|
||||||
@SerialName(userIdField)
|
@SerialName(userIdField)
|
||||||
override val userId: UserId,
|
override val userId: UserId,
|
||||||
@SerialName(customTitleField)
|
@SerialName(customTitleField)
|
||||||
@@ -30,4 +33,28 @@ data class SetChatAdministratorCustomTitle(
|
|||||||
throw IllegalArgumentException("Custom title length must be in range $customTitleLength, but was ${customTitle.length}")
|
throw IllegalArgumentException("Custom title length must be in range $customTitleLength, but was ${customTitle.length}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setChatAdministratorCustomTitle(
|
||||||
|
chatId: ChatId,
|
||||||
|
userId: UserId,
|
||||||
|
customTitle: String
|
||||||
|
) = execute(SetChatAdministratorCustomTitle(chatId, userId, customTitle))
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setChatAdministratorCustomTitle(
|
||||||
|
chat: PublicChat,
|
||||||
|
userId: UserId,
|
||||||
|
customTitle: String
|
||||||
|
) = setChatAdministratorCustomTitle(chat.id, userId, customTitle)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setChatAdministratorCustomTitle(
|
||||||
|
chatId: ChatId,
|
||||||
|
user: User,
|
||||||
|
customTitle: String
|
||||||
|
) = setChatAdministratorCustomTitle(chatId, user.id, customTitle)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setChatAdministratorCustomTitle(
|
||||||
|
chat: PublicChat,
|
||||||
|
user: User,
|
||||||
|
customTitle: String
|
||||||
|
) = setChatAdministratorCustomTitle(chat.id, user.id, customTitle)
|
||||||
@@ -1,7 +1,10 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.members
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.members
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
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.abstracts.Chat
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.BooleanSerializer
|
import kotlinx.serialization.internal.BooleanSerializer
|
||||||
|
|
||||||
@@ -18,3 +21,24 @@ data class UnbanChatMember(
|
|||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.unbanChatMember(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
userId: UserId
|
||||||
|
) = execute(UnbanChatMember(chatId, userId))
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.unbanChatMember(
|
||||||
|
chat: PublicChat,
|
||||||
|
userId: UserId
|
||||||
|
) = unbanChatMember(chat.id, userId)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.unbanChatMember(
|
||||||
|
chatId: ChatId,
|
||||||
|
user: User
|
||||||
|
) = unbanChatMember(chatId, user.id)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.unbanChatMember(
|
||||||
|
chat: PublicChat,
|
||||||
|
user: User
|
||||||
|
) = unbanChatMember(chat.id, user.id)
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.get.GetChat
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.BooleanSerializer
|
import kotlinx.serialization.internal.BooleanSerializer
|
||||||
@@ -18,3 +22,11 @@ data class DeleteChatPhoto(
|
|||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.deleteChatPhoto(
|
||||||
|
chatId: ChatIdentifier
|
||||||
|
) = execute(DeleteChatPhoto(chatId))
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.deleteChatPhoto(
|
||||||
|
chat: PublicChat
|
||||||
|
) = deleteChatPhoto(chat.id)
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
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.chat.abstracts.Chat
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.BooleanSerializer
|
import kotlinx.serialization.internal.BooleanSerializer
|
||||||
|
|
||||||
@@ -21,3 +25,24 @@ data class PinChatMessage (
|
|||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.pinChatMessage(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
disableNotification: Boolean = false
|
||||||
|
) = execute(PinChatMessage(chatId, messageId, disableNotification))
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.pinChatMessage(
|
||||||
|
chat: PublicChat,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
disableNotification: Boolean = false
|
||||||
|
) = pinChatMessage(chat.id, messageId, disableNotification)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.pinChatMessage(
|
||||||
|
message: Message,
|
||||||
|
disableNotification: Boolean = false
|
||||||
|
) = if (message.chat is PublicChat) {
|
||||||
|
pinChatMessage(message.chat.id, message.messageId, disableNotification)
|
||||||
|
} else {
|
||||||
|
error("It is possible to pin messages only in non one-to-one chats")
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
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.chat.abstracts.Chat
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.BooleanSerializer
|
import kotlinx.serialization.internal.BooleanSerializer
|
||||||
|
|
||||||
@@ -25,3 +28,13 @@ data class SetChatDescription (
|
|||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setChatDescription(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
description: String
|
||||||
|
) = execute(SetChatDescription(chatId, description))
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setChatDescription(
|
||||||
|
chat: PublicChat,
|
||||||
|
description: String
|
||||||
|
) = setChatDescription(chat.id, description)
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
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.chat.ChatPermissions
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.ChatPermissions
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.BooleanSerializer
|
import kotlinx.serialization.internal.BooleanSerializer
|
||||||
|
|
||||||
@@ -20,3 +22,13 @@ data class SetChatPermissions (
|
|||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setDefaultChatMembersPermissions(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
permissions: ChatPermissions
|
||||||
|
) = execute(SetChatPermissions(chatId, permissions))
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setDefaultChatMembersPermissions(
|
||||||
|
chat: PublicChat,
|
||||||
|
permissions: ChatPermissions
|
||||||
|
) = setDefaultChatMembersPermissions(chat.id, permissions)
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.ChatPermissions
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toJson
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.toJson
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.BooleanSerializer
|
import kotlinx.serialization.internal.BooleanSerializer
|
||||||
@@ -21,3 +25,13 @@ data class SetChatPhoto (
|
|||||||
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())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setChatPhoto(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
photo: MultipartFile
|
||||||
|
) = execute(SetChatPhoto(chatId, photo))
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setChatPhoto(
|
||||||
|
chat: PublicChat,
|
||||||
|
photo: MultipartFile
|
||||||
|
) = setChatPhoto(chat.id, photo)
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
|
||||||
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.chat.abstracts.Chat
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.BooleanSerializer
|
import kotlinx.serialization.internal.BooleanSerializer
|
||||||
|
|
||||||
@@ -25,3 +29,13 @@ data class SetChatTitle (
|
|||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setChatTitle(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
title: String
|
||||||
|
) = execute(SetChatTitle(chatId, title))
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setChatTitle(
|
||||||
|
chat: PublicChat,
|
||||||
|
title: String
|
||||||
|
) = setChatTitle(chat.id, title)
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
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.abstracts.Chat
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.BooleanSerializer
|
import kotlinx.serialization.internal.BooleanSerializer
|
||||||
@@ -18,3 +21,11 @@ data class UnpinChatMessage(
|
|||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.unpinChatMessage(
|
||||||
|
chatId: ChatIdentifier
|
||||||
|
) = execute(UnpinChatMessage(chatId))
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.unpinChatMessage(
|
||||||
|
chat: PublicChat
|
||||||
|
) = unpinChatMessage(chat.id)
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.stickers
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.stickers
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify.DeleteChatPhoto
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.BooleanSerializer
|
import kotlinx.serialization.internal.BooleanSerializer
|
||||||
@@ -18,3 +21,11 @@ data class DeleteChatStickerSet(
|
|||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.deleteChatStickerSet(
|
||||||
|
chatId: ChatIdentifier
|
||||||
|
) = execute(DeleteChatStickerSet(chatId))
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.deleteChatStickerSet(
|
||||||
|
chat: SupergroupChat
|
||||||
|
) = deleteChatStickerSet(chat.id)
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.stickers
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.stickers
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
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.chat.abstracts.*
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.BooleanSerializer
|
import kotlinx.serialization.internal.BooleanSerializer
|
||||||
|
|
||||||
@@ -19,3 +21,13 @@ data class SetChatStickerSet(
|
|||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setChatStickerSet(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
stickerSetName: StickerSetName
|
||||||
|
) = execute(SetChatStickerSet(chatId, stickerSetName))
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setChatStickerSet(
|
||||||
|
chat: SupergroupChat,
|
||||||
|
stickerSetName: StickerSetName
|
||||||
|
) = setChatStickerSet(chat.id, stickerSetName)
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.common
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
||||||
import kotlinx.serialization.json.JsonObject
|
import kotlinx.serialization.json.JsonObject
|
||||||
|
|
||||||
data class CommonMultipartFileRequest<T: Any>(
|
internal data class CommonMultipartFileRequest<T: Any>(
|
||||||
val data: SimpleRequest<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 {
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.LiveLocation
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.LiveLocation
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
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.chat.abstracts.Chat
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.LocationContent
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.LocationContent
|
||||||
@@ -29,3 +31,54 @@ data class EditChatMessageLiveLocation(
|
|||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.editLiveLocation(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
latitude: Double,
|
||||||
|
longitude: Double,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
EditChatMessageLiveLocation(
|
||||||
|
chatId, messageId, latitude, longitude, replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.editLiveLocation(
|
||||||
|
chat: Chat,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
latitude: Double,
|
||||||
|
longitude: Double,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = editLiveLocation(chat.id, messageId, latitude, longitude, replyMarkup)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.editLiveLocation(
|
||||||
|
message: ContentMessage<LocationContent>,
|
||||||
|
latitude: Double,
|
||||||
|
longitude: Double,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = editLiveLocation(message.chat, message.messageId, latitude, longitude, replyMarkup)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.editLiveLocation(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
location: Location,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
EditChatMessageLiveLocation(
|
||||||
|
chatId, messageId, location.latitude, location.longitude, replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.editLiveLocation(
|
||||||
|
chat: Chat,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
location: Location,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = editLiveLocation(chat.id, messageId, location.latitude, location.longitude, replyMarkup)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.editLiveLocation(
|
||||||
|
message: ContentMessage<LocationContent>,
|
||||||
|
location: Location,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = editLiveLocation(message.chat, message.messageId, location.latitude, location.longitude, replyMarkup)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.LiveLocation
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.LiveLocation
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
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
|
||||||
@@ -20,3 +21,19 @@ data class EditInlineMessageLiveLocation(
|
|||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.editLiveLocation(
|
||||||
|
inlineMessageId: InlineMessageIdentifier,
|
||||||
|
latitude: Double,
|
||||||
|
longitude: Double,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
EditInlineMessageLiveLocation(
|
||||||
|
inlineMessageId, latitude, longitude, replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
|
suspend fun RequestsExecutor.editLiveLocation(
|
||||||
|
inlineMessageId: InlineMessageIdentifier,
|
||||||
|
location: Location,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = editLiveLocation(inlineMessageId, location.latitude, location.longitude, replyMarkup)
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.LiveLocation
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.LiveLocation
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditChatMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditChatMessage
|
||||||
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.chat.abstracts.Chat
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.LocationContent
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.LocationContent
|
||||||
@@ -26,3 +28,25 @@ data class StopChatMessageLiveLocation(
|
|||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.stopLiveLocation(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
StopChatMessageLiveLocation(
|
||||||
|
chatId, messageId, replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.stopLiveLocation(
|
||||||
|
chat: Chat,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = stopLiveLocation(chat.id, messageId, replyMarkup)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.stopLiveLocation(
|
||||||
|
message: ContentMessage<LocationContent>,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = stopLiveLocation(message.chat, message.messageId, replyMarkup)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.LiveLocation
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.LiveLocation
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditInlineMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditInlineMessage
|
||||||
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.*
|
||||||
@@ -17,3 +18,12 @@ data class StopInlineMessageLiveLocation(
|
|||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.stopLiveLocation(
|
||||||
|
inlineMessageId: InlineMessageIdentifier,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
StopInlineMessageLiveLocation(
|
||||||
|
inlineMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.ReplyMarkup
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.ReplyMarkup
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditChatMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditChatMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditReplyMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditReplyMessage
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.media.EditChatMessageMedia
|
||||||
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.buttons.InlineKeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
@@ -29,3 +33,23 @@ data class EditChatMessageReplyMarkup(
|
|||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.editMessageReplyMarkup(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
EditChatMessageReplyMarkup(chatId, messageId, replyMarkup)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.editMessageReplyMarkup(
|
||||||
|
chat: Chat,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = editMessageReplyMarkup(chat.id, messageId, replyMarkup)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.editMessageReplyMarkup(
|
||||||
|
message: Message,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = editMessageReplyMarkup(message.chat.id, message.messageId, replyMarkup)
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.ReplyMarkup
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.ReplyMarkup
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditInlineMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditInlineMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditReplyMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditReplyMessage
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.media.EditInlineMessageMedia
|
||||||
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.buttons.InlineKeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
@@ -17,3 +20,8 @@ data class EditInlineMessageReplyMarkup(
|
|||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.editMessageReplyMarkup(
|
||||||
|
inlineMessageId: InlineMessageIdentifier,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = execute(EditInlineMessageReplyMarkup(inlineMessageId, replyMarkup))
|
||||||
|
|||||||
@@ -1,13 +1,21 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.caption
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.caption
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedInput
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.media.MediaContentMessageResultDeserializer
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.media.MediaContentMessageResultDeserializer
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.text.EditChatMessageText
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
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.chat.abstracts.Chat
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.CommonMessageImpl
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.PhotoContent
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
const val editMessageCaptionMethod = "editMessageCaption"
|
const val editMessageCaptionMethod = "editMessageCaption"
|
||||||
@@ -32,3 +40,30 @@ data class EditChatMessageCaption(
|
|||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.editMessageCaption(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
text: String,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
EditChatMessageCaption(chatId, messageId, text, parseMode, replyMarkup)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.editMessageCaption(
|
||||||
|
chat: Chat,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
text: String,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = editMessageCaption(chat.id, messageId, text, parseMode, replyMarkup)
|
||||||
|
|
||||||
|
suspend fun <T> RequestsExecutor.editMessageCaption(
|
||||||
|
message: ContentMessage<T>,
|
||||||
|
text: String,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
): ContentMessage<MediaContent> where T : CaptionedInput, T : MediaContent {
|
||||||
|
return editMessageCaption(message.chat.id, message.messageId, text, parseMode, replyMarkup)
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.caption
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.caption
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.text.EditInlineMessageText
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
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
|
||||||
@@ -22,3 +24,10 @@ data class EditInlineMessageCaption(
|
|||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.editMessageCaption(
|
||||||
|
inlineMessageId: InlineMessageIdentifier,
|
||||||
|
text: String,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = execute(EditInlineMessageCaption(inlineMessageId, text, parseMode, replyMarkup))
|
||||||
|
|||||||
@@ -1,13 +1,20 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.media
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.media
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.caption.EditChatMessageCaption
|
||||||
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.ParseMode.ParseMode
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.CommonMessageImpl
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.TextContent
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.PhotoContent
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
const val editMessageMediaMethod = "editMessageMedia"
|
const val editMessageMediaMethod = "editMessageMedia"
|
||||||
@@ -38,3 +45,25 @@ data class EditChatMessageMedia(
|
|||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.editMessageMedia(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
media: InputMedia,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
EditChatMessageMedia(chatId, messageId, media, replyMarkup)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.editMessageMedia(
|
||||||
|
chat: Chat,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
media: InputMedia,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = editMessageMedia(chat.id, messageId, media, replyMarkup)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.editMessageMedia(
|
||||||
|
message: ContentMessage<out MediaContent>,
|
||||||
|
media: InputMedia,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = editMessageMedia(message.chat.id, message.messageId, media, replyMarkup)
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.media
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.media
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.caption.EditInlineMessageCaption
|
||||||
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.ParseMode.ParseMode
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
@@ -27,3 +30,9 @@ data class EditInlineMessageMedia(
|
|||||||
|
|
||||||
override fun method(): String = editMessageMediaMethod
|
override fun method(): String = editMessageMediaMethod
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.editMessageCaption(
|
||||||
|
inlineMessageId: InlineMessageIdentifier,
|
||||||
|
media: InputMedia,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = execute(EditInlineMessageMedia(inlineMessageId, media, replyMarkup))
|
||||||
|
|||||||
@@ -1,12 +1,15 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.text
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.text
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.TextContentMessageResultDeserializer
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.TextContentMessageResultDeserializer
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
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.chat.abstracts.Chat
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.TextContent
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.TextContent
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
@@ -34,3 +37,31 @@ data class EditChatMessageText(
|
|||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.editMessageText(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
text: String,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
disableWebPagePreview: Boolean? = null,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
EditChatMessageText(chatId, messageId, text, parseMode, disableWebPagePreview, replyMarkup)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.editMessageText(
|
||||||
|
chat: Chat,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
text: String,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
disableWebPagePreview: Boolean? = null,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = editMessageText(chat.id, messageId, text, parseMode, disableWebPagePreview, replyMarkup)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.editMessageText(
|
||||||
|
message: ContentMessage<TextContent>,
|
||||||
|
text: String,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
disableWebPagePreview: Boolean? = null,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = editMessageText(message.chat.id, message.messageId, text, parseMode, disableWebPagePreview, replyMarkup)
|
||||||
@@ -1,11 +1,13 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.text
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.text
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.media.editMessageMediaMethod
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.media.editMessageMediaMethod
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
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.chat.abstracts.Chat
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
@@ -25,3 +27,11 @@ data class EditInlineMessageText(
|
|||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.editMessageText(
|
||||||
|
inlineMessageId: InlineMessageIdentifier,
|
||||||
|
text: String,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
disableWebPagePreview: Boolean? = null,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = execute(EditInlineMessageText(inlineMessageId, text, parseMode, disableWebPagePreview, replyMarkup))
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.games
|
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.bot.RequestsExecutor
|
||||||
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 com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.GameContent
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
@@ -17,3 +21,50 @@ data class GetGameHighScoresByChat (
|
|||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getGameScore(
|
||||||
|
userId: UserId,
|
||||||
|
chatId: ChatId,
|
||||||
|
messageId: MessageIdentifier
|
||||||
|
) = execute(
|
||||||
|
GetGameHighScoresByChat(userId, chatId, messageId)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getGameScore(
|
||||||
|
user: CommonUser,
|
||||||
|
chatId: ChatId,
|
||||||
|
messageId: MessageIdentifier
|
||||||
|
) = getGameScore(
|
||||||
|
user.id, chatId, messageId
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getGameScore(
|
||||||
|
userId: UserId,
|
||||||
|
chat: Chat,
|
||||||
|
messageId: MessageIdentifier
|
||||||
|
) = getGameScore(
|
||||||
|
userId, chat.id, messageId
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getGameScore(
|
||||||
|
user: CommonUser,
|
||||||
|
chat: Chat,
|
||||||
|
messageId: MessageIdentifier
|
||||||
|
) = getGameScore(
|
||||||
|
user.id, chat.id, messageId
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getGameScore(
|
||||||
|
userId: UserId,
|
||||||
|
message: ContentMessage<GameContent>
|
||||||
|
) = getGameScore(
|
||||||
|
userId, message.chat.id, message.messageId
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getGameScore(
|
||||||
|
user: CommonUser,
|
||||||
|
message: ContentMessage<GameContent>
|
||||||
|
) = getGameScore(
|
||||||
|
user.id, message.chat.id, message.messageId
|
||||||
|
)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.games
|
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.bot.RequestsExecutor
|
||||||
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.*
|
import kotlinx.serialization.*
|
||||||
@@ -15,3 +16,17 @@ data class GetGameHighScoresByInlineMessageId (
|
|||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getGameScore(
|
||||||
|
userId: UserId,
|
||||||
|
inlineMessageId: InlineMessageIdentifier
|
||||||
|
) = execute(
|
||||||
|
GetGameHighScoresByInlineMessageId(
|
||||||
|
userId, inlineMessageId
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getGameScore(
|
||||||
|
user: CommonUser,
|
||||||
|
inlineMessageId: InlineMessageIdentifier
|
||||||
|
) = getGameScore(user.id, inlineMessageId)
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.games
|
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.bot.RequestsExecutor
|
||||||
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 com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.GameContent
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
@@ -23,3 +27,68 @@ data class SetGameScoreByChatId (
|
|||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setGameScore(
|
||||||
|
userId: UserId,
|
||||||
|
score: Long,
|
||||||
|
chatId: ChatId,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
force: Boolean = false,
|
||||||
|
disableEditMessage: Boolean = false
|
||||||
|
) = execute(
|
||||||
|
SetGameScoreByChatId(userId, score, chatId, messageId, force, disableEditMessage)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setGameScore(
|
||||||
|
user: CommonUser,
|
||||||
|
score: Long,
|
||||||
|
chatId: ChatId,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
force: Boolean = false,
|
||||||
|
disableEditMessage: Boolean = false
|
||||||
|
) = setGameScore(
|
||||||
|
user.id, score, chatId, messageId, force, disableEditMessage
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setGameScore(
|
||||||
|
userId: UserId,
|
||||||
|
score: Long,
|
||||||
|
chat: Chat,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
force: Boolean = false,
|
||||||
|
disableEditMessage: Boolean = false
|
||||||
|
) = setGameScore(
|
||||||
|
userId, score, chat.id, messageId, force, disableEditMessage
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setGameScore(
|
||||||
|
user: CommonUser,
|
||||||
|
score: Long,
|
||||||
|
chat: Chat,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
force: Boolean = false,
|
||||||
|
disableEditMessage: Boolean = false
|
||||||
|
) = setGameScore(
|
||||||
|
user.id, score, chat.id, messageId, force, disableEditMessage
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setGameScore(
|
||||||
|
userId: UserId,
|
||||||
|
score: Long,
|
||||||
|
message: ContentMessage<GameContent>,
|
||||||
|
force: Boolean = false,
|
||||||
|
disableEditMessage: Boolean = false
|
||||||
|
) = setGameScore(
|
||||||
|
userId, score, message.chat.id, message.messageId, force, disableEditMessage
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setGameScore(
|
||||||
|
user: CommonUser,
|
||||||
|
score: Long,
|
||||||
|
message: ContentMessage<GameContent>,
|
||||||
|
force: Boolean = false,
|
||||||
|
disableEditMessage: Boolean = false
|
||||||
|
) = setGameScore(
|
||||||
|
user.id, score, message.chat.id, message.messageId, force, disableEditMessage
|
||||||
|
)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.games
|
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.bot.RequestsExecutor
|
||||||
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.*
|
import kotlinx.serialization.*
|
||||||
@@ -21,3 +22,23 @@ data class SetGameScoreByInlineMessageId (
|
|||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setGameScore(
|
||||||
|
userId: UserId,
|
||||||
|
score: Long,
|
||||||
|
inlineMessageId: InlineMessageIdentifier,
|
||||||
|
force: Boolean = false,
|
||||||
|
disableEditMessage: Boolean = false
|
||||||
|
) = execute(
|
||||||
|
SetGameScoreByInlineMessageId(
|
||||||
|
userId, score, inlineMessageId, force, disableEditMessage
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setGameScore(
|
||||||
|
user: CommonUser,
|
||||||
|
score: Long,
|
||||||
|
inlineMessageId: InlineMessageIdentifier,
|
||||||
|
force: Boolean = false,
|
||||||
|
disableEditMessage: Boolean = false
|
||||||
|
) = setGameScore(user.id, score, inlineMessageId, force, disableEditMessage)
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.get
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.get
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.files.PathedFile
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.PathedFile
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.abstracts.TelegramMediaFile
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.files.abstracts.fileIdField
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.abstracts.fileIdField
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
@@ -17,3 +19,13 @@ data class GetFile(
|
|||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getFileAdditionalInfo(
|
||||||
|
fileId: FileId
|
||||||
|
) = execute(
|
||||||
|
GetFile(fileId)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getFileAdditionalInfo(
|
||||||
|
file: TelegramMediaFile
|
||||||
|
) = getFileAdditionalInfo(file.fileId)
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.get
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.get
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.Sticker
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.stickerSetNameField
|
import com.github.insanusmokrassar.TelegramBotAPI.types.stickerSetNameField
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.StickerSet
|
import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.StickerSet
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
@@ -16,3 +18,15 @@ data class GetStickerSet(
|
|||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getStickerSet(
|
||||||
|
name: String
|
||||||
|
) = execute(
|
||||||
|
GetStickerSet(name)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getStickerSet(
|
||||||
|
sticker: Sticker
|
||||||
|
) = getStickerSet(
|
||||||
|
sticker.stickerSetName ?: error("Sticker must contains stickerSetName to be correctly used in getStickerSet method")
|
||||||
|
)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.get
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.get
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
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 kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
@@ -28,3 +29,19 @@ data class GetUserProfilePhotos(
|
|||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getUserProfilePhotos(
|
||||||
|
userId: UserId,
|
||||||
|
offset: Int? = null,
|
||||||
|
limit: Int? = null
|
||||||
|
) = execute(
|
||||||
|
GetUserProfilePhotos(
|
||||||
|
userId, offset, limit
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getUserProfilePhotos(
|
||||||
|
user: CommonUser,
|
||||||
|
offset: Int? = null,
|
||||||
|
limit: Int? = null
|
||||||
|
) = getUserProfilePhotos(user.id, offset, limit)
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.send
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.send
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendChatMessageRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendChatMessageRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.actions.BotAction
|
import com.github.insanusmokrassar.TelegramBotAPI.types.actions.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.BooleanSerializer
|
import kotlinx.serialization.internal.BooleanSerializer
|
||||||
|
|
||||||
@@ -22,3 +24,99 @@ data class SendAction(
|
|||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendBotAction(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
action: BotAction
|
||||||
|
) = execute(
|
||||||
|
SendAction(chatId, action)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendBotAction(
|
||||||
|
chat: Chat,
|
||||||
|
action: BotAction
|
||||||
|
) = sendBotAction(chat.id, action)
|
||||||
|
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionTyping(
|
||||||
|
chatId: ChatIdentifier
|
||||||
|
) = sendBotAction(chatId, TypingAction)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionUploadPhoto(
|
||||||
|
chatId: ChatIdentifier
|
||||||
|
) = sendBotAction(chatId, UploadPhotoAction)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionRecordVideo(
|
||||||
|
chatId: ChatIdentifier
|
||||||
|
) = sendBotAction(chatId, RecordVideoAction)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionUploadVideo(
|
||||||
|
chatId: ChatIdentifier
|
||||||
|
) = sendBotAction(chatId, UploadVideoAction)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionRecordAudio(
|
||||||
|
chatId: ChatIdentifier
|
||||||
|
) = sendBotAction(chatId, RecordAudioAction)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionUploadAudio(
|
||||||
|
chatId: ChatIdentifier
|
||||||
|
) = sendBotAction(chatId, UploadAudioAction)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionUploadDocument(
|
||||||
|
chatId: ChatIdentifier
|
||||||
|
) = sendBotAction(chatId, UploadDocumentAction)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionFindLocation(
|
||||||
|
chatId: ChatIdentifier
|
||||||
|
) = sendBotAction(chatId, FindLocationAction)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionRecordVideoNote(
|
||||||
|
chatId: ChatIdentifier
|
||||||
|
) = sendBotAction(chatId, RecordVideoNoteAction)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionUploadVideoNote(
|
||||||
|
chatId: ChatIdentifier
|
||||||
|
) = sendBotAction(chatId, UploadVideoNoteAction)
|
||||||
|
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionTyping(
|
||||||
|
chat: Chat
|
||||||
|
) = sendBotAction(chat, TypingAction)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionUploadPhoto(
|
||||||
|
chat: Chat
|
||||||
|
) = sendBotAction(chat, UploadPhotoAction)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionRecordVideo(
|
||||||
|
chat: Chat
|
||||||
|
) = sendBotAction(chat, RecordVideoAction)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionUploadVideo(
|
||||||
|
chat: Chat
|
||||||
|
) = sendBotAction(chat, UploadVideoAction)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionRecordAudio(
|
||||||
|
chat: Chat
|
||||||
|
) = sendBotAction(chat, RecordAudioAction)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionUploadAudio(
|
||||||
|
chat: Chat
|
||||||
|
) = sendBotAction(chat, UploadAudioAction)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionUploadDocument(
|
||||||
|
chat: Chat
|
||||||
|
) = sendBotAction(chat, UploadDocumentAction)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionFindLocation(
|
||||||
|
chat: Chat
|
||||||
|
) = sendBotAction(chat, FindLocationAction)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionRecordVideoNote(
|
||||||
|
chat: Chat
|
||||||
|
) = sendBotAction(chat, RecordVideoNoteAction)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionUploadVideoNote(
|
||||||
|
chat: Chat
|
||||||
|
) = sendBotAction(chat, UploadVideoNoteAction)
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.send
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.send
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.ReplyingMarkupSendMessageRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.ReplyingMarkupSendMessageRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendMessageRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendMessageRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.ContactContent
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.ContactContent
|
||||||
@@ -66,3 +68,51 @@ fun Contact.toRequest(
|
|||||||
replyToMessageId,
|
replyToMessageId,
|
||||||
replyMarkup
|
replyMarkup
|
||||||
)
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendContact(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
phoneNumber: String,
|
||||||
|
firstName: String,
|
||||||
|
lastName: String? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
SendContact(
|
||||||
|
chatId, phoneNumber, firstName, lastName, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendContact(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
contact: Contact,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
SendContact(
|
||||||
|
chatId, contact, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendContact(
|
||||||
|
chat: Chat,
|
||||||
|
phoneNumber: String,
|
||||||
|
firstName: String,
|
||||||
|
lastName: String? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendContact(
|
||||||
|
chat.id, phoneNumber, firstName, lastName, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendContact(
|
||||||
|
chat: Chat,
|
||||||
|
contact: Contact,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendContact(
|
||||||
|
chat.id, contact, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
|||||||
@@ -1,11 +1,21 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.send
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.send
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.LiveLocation.EditChatMessageLiveLocation
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.LiveLocation.StopChatMessageLiveLocation
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.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.KeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.LocationContent
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.LocationContent
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.extensions.executeAsync
|
||||||
|
import com.soywiz.klock.DateTime
|
||||||
|
import com.soywiz.klock.TimeSpan
|
||||||
|
import io.ktor.utils.io.core.Closeable
|
||||||
|
import kotlinx.coroutines.*
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
|
|
||||||
@@ -33,10 +43,79 @@ data class SendLocation(
|
|||||||
ReplyingMarkupSendMessageRequest<ContentMessage<LocationContent>>,
|
ReplyingMarkupSendMessageRequest<ContentMessage<LocationContent>>,
|
||||||
PositionedSendMessageRequest<ContentMessage<LocationContent>>
|
PositionedSendMessageRequest<ContentMessage<LocationContent>>
|
||||||
{
|
{
|
||||||
|
|
||||||
override fun method(): String = "sendLocation"
|
override fun method(): String = "sendLocation"
|
||||||
override val resultDeserializer: DeserializationStrategy<ContentMessage<LocationContent>>
|
override val resultDeserializer: DeserializationStrategy<ContentMessage<LocationContent>>
|
||||||
get() = commonResultDeserializer
|
get() = commonResultDeserializer
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
|
|
||||||
|
init {
|
||||||
|
if (livePeriod != null && livePeriod !in livePeriodLimit) {
|
||||||
|
error("Live period for sending location must be in $livePeriodLimit, but was $livePeriod")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendLocation(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
latitude: Double,
|
||||||
|
longitude: Double,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
SendLocation(
|
||||||
|
chatId,
|
||||||
|
latitude,
|
||||||
|
longitude,
|
||||||
|
disableNotification = disableNotification,
|
||||||
|
replyToMessageId = replyToMessageId,
|
||||||
|
replyMarkup = replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendLocation(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
location: Location,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendLocation(
|
||||||
|
chatId,
|
||||||
|
location.latitude,
|
||||||
|
location.longitude,
|
||||||
|
disableNotification,
|
||||||
|
replyToMessageId,
|
||||||
|
replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendLocation(
|
||||||
|
chat: Chat,
|
||||||
|
latitude: Double,
|
||||||
|
longitude: Double,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendLocation(
|
||||||
|
chat.id,
|
||||||
|
latitude,
|
||||||
|
longitude,
|
||||||
|
disableNotification,
|
||||||
|
replyToMessageId,
|
||||||
|
replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendLocation(
|
||||||
|
chat: Chat,
|
||||||
|
location: Location,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendLocation(
|
||||||
|
chat.id,
|
||||||
|
location.latitude,
|
||||||
|
location.longitude,
|
||||||
|
disableNotification,
|
||||||
|
replyToMessageId,
|
||||||
|
replyMarkup
|
||||||
|
)
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.send
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.send
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.DisableWebPagePreview
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.DisableWebPagePreview
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
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.KeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.TextContent
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.TextContent
|
||||||
@@ -55,3 +57,48 @@ data class SendTextMessage(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
typealias SendMessage = SendTextMessage
|
typealias SendMessage = SendTextMessage
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendMessage(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
text: String,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
disableWebPagePreview: Boolean? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
SendTextMessage(chatId, text, parseMode, disableWebPagePreview, disableNotification, replyToMessageId, replyMarkup)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendTextMessage(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
text: String,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
disableWebPagePreview: Boolean? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendMessage(
|
||||||
|
chatId, text, parseMode, disableWebPagePreview, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendMessage(
|
||||||
|
chat: Chat,
|
||||||
|
text: String,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
disableWebPagePreview: Boolean? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendMessage(chat.id, text, parseMode, disableWebPagePreview, disableNotification, replyToMessageId, replyMarkup)
|
||||||
|
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendTextMessage(
|
||||||
|
chat: Chat,
|
||||||
|
text: String,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
disableWebPagePreview: Boolean? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendTextMessage(chat.id, text, parseMode, disableWebPagePreview, disableNotification, replyToMessageId, replyMarkup)
|
||||||
|
|||||||
@@ -1,51 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.send
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.ReplyingMarkupSendMessageRequest
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendMessageRequest
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.PollContent
|
|
||||||
import kotlinx.serialization.*
|
|
||||||
|
|
||||||
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<PollContent>>
|
|
||||||
= TelegramBotAPIMessageDeserializationStrategyClass()
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class SendPoll(
|
|
||||||
@SerialName(chatIdField)
|
|
||||||
override val chatId: ChatIdentifier,
|
|
||||||
@SerialName(questionField)
|
|
||||||
val question: String,
|
|
||||||
@SerialName(optionsField)
|
|
||||||
val options: List<String>,
|
|
||||||
@SerialName(disableNotificationField)
|
|
||||||
override val disableNotification: Boolean = false,
|
|
||||||
@SerialName(replyToMessageIdField)
|
|
||||||
override val replyToMessageId: MessageIdentifier? = null,
|
|
||||||
@SerialName(replyMarkupField)
|
|
||||||
override val replyMarkup: KeyboardMarkup? = null
|
|
||||||
) : SendMessageRequest<ContentMessage<PollContent>>,
|
|
||||||
ReplyingMarkupSendMessageRequest<ContentMessage<PollContent>> {
|
|
||||||
|
|
||||||
init {
|
|
||||||
if (question.length !in pollQuestionTextLength) {
|
|
||||||
throw IllegalArgumentException("The length of questions for polls must be in $pollQuestionTextLength range, but was ${question.length}")
|
|
||||||
}
|
|
||||||
options.forEach {
|
|
||||||
if (it.length !in pollOptionTextLength) {
|
|
||||||
throw IllegalArgumentException("The length of question option text for polls must be in $pollOptionTextLength range, but was ${it.length}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (options.size !in pollOptionsLimit) {
|
|
||||||
throw IllegalArgumentException("The amount of question options for polls must be in $pollOptionsLimit range, but was ${options.size}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun method(): String = "sendPoll"
|
|
||||||
override val resultDeserializer: DeserializationStrategy<ContentMessage<PollContent>>
|
|
||||||
get() = commonResultDeserializer
|
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
|
||||||
get() = serializer()
|
|
||||||
}
|
|
||||||
@@ -1,8 +1,10 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.send
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.send
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.VenueContent
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.VenueContent
|
||||||
@@ -73,3 +75,55 @@ fun Venue.toRequest(
|
|||||||
replyToMessageId,
|
replyToMessageId,
|
||||||
replyMarkup
|
replyMarkup
|
||||||
)
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendVenue(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
latitude: Double,
|
||||||
|
longitude: Double,
|
||||||
|
title: String,
|
||||||
|
address: String,
|
||||||
|
foursquareId: String? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
SendVenue(
|
||||||
|
chatId, latitude, longitude, title, address, foursquareId, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendVenue(
|
||||||
|
chat: Chat,
|
||||||
|
latitude: Double,
|
||||||
|
longitude: Double,
|
||||||
|
title: String,
|
||||||
|
address: String,
|
||||||
|
foursquareId: String? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendVenue(
|
||||||
|
chat.id, latitude, longitude, title, address, foursquareId, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendVenue(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
venue: Venue,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
SendVenue(
|
||||||
|
chatId, venue, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendVenue(
|
||||||
|
chat: Chat,
|
||||||
|
venue: Venue,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendVenue(
|
||||||
|
chat.id, venue, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.send.games
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.send.games
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ReplyMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ReplyMarkup
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendMessageRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendMessageRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.games.Game
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.GameContent
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.GameContent
|
||||||
@@ -31,4 +34,46 @@ data class SendGame (
|
|||||||
get() = commonResultDeserializer
|
get() = commonResultDeserializer
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendGame(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
gameShortName: String,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
SendGame(
|
||||||
|
chatId, gameShortName, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendGame(
|
||||||
|
chat: Chat,
|
||||||
|
gameShortName: String,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendGame(
|
||||||
|
chat.id, gameShortName, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendGame(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
game: Game,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendGame(
|
||||||
|
chatId, game.title, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendGame(
|
||||||
|
chat: Chat,
|
||||||
|
game: Game,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendGame(
|
||||||
|
chat.id, game.title, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.send.media
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.send.media
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.*
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.*
|
||||||
@@ -7,6 +8,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.KeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.AnimationFile
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.PhotoSize
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.AnimationContent
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.AnimationContent
|
||||||
@@ -112,3 +115,137 @@ data class SendAnimationFiles internal constructor(
|
|||||||
animationField to animation,
|
animationField to animation,
|
||||||
thumbField to thumb
|
thumbField to thumb
|
||||||
)
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendAnimation(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
animation: FileId,
|
||||||
|
thumb: FileId? = null,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
duration: Long? = null,
|
||||||
|
width: Int? = null,
|
||||||
|
height: Int? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
SendAnimationData(
|
||||||
|
chatId,
|
||||||
|
animation.fileId,
|
||||||
|
thumb ?.fileId,
|
||||||
|
text,
|
||||||
|
parseMode,
|
||||||
|
duration,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
disableNotification,
|
||||||
|
replyToMessageId,
|
||||||
|
replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendAnimation(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
animation: AnimationFile,
|
||||||
|
thumb: PhotoSize? = animation.thumb,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendAnimation(
|
||||||
|
chatId, animation.fileId, thumb ?.fileId, text, parseMode, animation.duration, animation.width, animation.height, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendAnimation(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
animation: MultipartFile,
|
||||||
|
thumb: FileId? = null,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
duration: Long? = null,
|
||||||
|
width: Int? = null,
|
||||||
|
height: Int? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
MultipartRequestImpl(
|
||||||
|
SendAnimationData(
|
||||||
|
chatId, null, thumb ?.fileId, text, parseMode, duration, width, height, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
),
|
||||||
|
SendAnimationFiles(animation)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendAnimation(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
animation: MultipartFile,
|
||||||
|
thumb: MultipartFile? = null,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
duration: Long? = null,
|
||||||
|
width: Int? = null,
|
||||||
|
height: Int? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
MultipartRequestImpl(
|
||||||
|
SendAnimationData(
|
||||||
|
chatId, null, null, text, parseMode, duration, width, height, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
),
|
||||||
|
SendAnimationFiles(animation, thumb)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendAnimation(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
animation: FileId,
|
||||||
|
thumb: MultipartFile,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
duration: Long? = null,
|
||||||
|
width: Int? = null,
|
||||||
|
height: Int? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
MultipartRequestImpl(
|
||||||
|
SendAnimationData(
|
||||||
|
chatId, animation.fileId, null, text, parseMode, duration, width, height, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
),
|
||||||
|
SendAnimationFiles(null, thumb)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendAnimation(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
animation: MultipartFile,
|
||||||
|
thumb: PhotoSize? = null,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
duration: Long? = null,
|
||||||
|
width: Int? = null,
|
||||||
|
height: Int? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendAnimation(
|
||||||
|
chatId, animation, thumb ?.fileId , text, parseMode, duration, width, height, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendAnimation(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
animation: AnimationFile,
|
||||||
|
thumb: MultipartFile,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendAnimation(
|
||||||
|
chatId, animation.fileId, thumb, text, parseMode, animation.duration, animation.width, animation.height, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.send.media
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.send.media
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.Performerable
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.Performerable
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.*
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.*
|
||||||
@@ -8,6 +9,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.KeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.AudioFile
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.PhotoSize
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.AudioContent
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.AudioContent
|
||||||
@@ -114,3 +117,138 @@ data class SendAudioFiles internal constructor(
|
|||||||
audioField to audio,
|
audioField to audio,
|
||||||
thumbField to thumb
|
thumbField to thumb
|
||||||
)
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendAudio(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
audio: FileId,
|
||||||
|
thumb: FileId? = null,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
duration: Long? = null,
|
||||||
|
performer: String? = null,
|
||||||
|
title: String? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
SendAudioData(
|
||||||
|
chatId,
|
||||||
|
audio.fileId,
|
||||||
|
thumb ?.fileId,
|
||||||
|
text,
|
||||||
|
parseMode,
|
||||||
|
duration,
|
||||||
|
performer,
|
||||||
|
title,
|
||||||
|
disableNotification,
|
||||||
|
replyToMessageId,
|
||||||
|
replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendAudio(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
audio: AudioFile,
|
||||||
|
thumb: PhotoSize? = audio.thumb,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
title: String? = audio.title,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendAudio(
|
||||||
|
chatId, audio.fileId, thumb ?.fileId, text, parseMode, audio.duration, audio.performer, title, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendAudio(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
audio: MultipartFile,
|
||||||
|
thumb: FileId? = null,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
duration: Long? = null,
|
||||||
|
performer: String? = null,
|
||||||
|
title: String? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
MultipartRequestImpl(
|
||||||
|
SendAudioData(
|
||||||
|
chatId, null, thumb ?.fileId, text, parseMode, duration, performer, title, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
),
|
||||||
|
SendAudioFiles(audio)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendAudio(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
audio: MultipartFile,
|
||||||
|
thumb: MultipartFile? = null,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
duration: Long? = null,
|
||||||
|
performer: String? = null,
|
||||||
|
title: String? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
MultipartRequestImpl(
|
||||||
|
SendAudioData(
|
||||||
|
chatId, null, null, text, parseMode, duration, performer, title, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
),
|
||||||
|
SendAudioFiles(audio, thumb)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendAudio(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
audio: FileId,
|
||||||
|
thumb: MultipartFile,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
duration: Long? = null,
|
||||||
|
performer: String? = null,
|
||||||
|
title: String? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
MultipartRequestImpl(
|
||||||
|
SendAudioData(
|
||||||
|
chatId, audio.fileId, null, text, parseMode, duration, performer, title, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
),
|
||||||
|
SendAudioFiles(null, thumb)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendAudio(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
audio: MultipartFile,
|
||||||
|
thumb: PhotoSize? = null,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
duration: Long? = null,
|
||||||
|
performer: String? = null,
|
||||||
|
title: String? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendAudio(
|
||||||
|
chatId, audio, thumb ?.fileId , text, parseMode, duration, performer, title, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendAudio(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
audio: AudioFile,
|
||||||
|
thumb: MultipartFile,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
title: String? = audio.title,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendAudio(
|
||||||
|
chatId, audio.fileId, thumb, text, parseMode, audio.duration, audio.performer, title, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.send.media
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.send.media
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.*
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.*
|
||||||
@@ -7,6 +8,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.KeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.DocumentFile
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.PhotoSize
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.DocumentContent
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.DocumentContent
|
||||||
@@ -98,3 +101,118 @@ data class SendDocumentFiles internal constructor(
|
|||||||
documentField to document,
|
documentField to document,
|
||||||
thumbField to thumb
|
thumbField to thumb
|
||||||
)
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendDocument(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
document: FileId,
|
||||||
|
thumb: FileId? = null,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
SendDocumentData(
|
||||||
|
chatId,
|
||||||
|
document.fileId,
|
||||||
|
thumb ?.fileId,
|
||||||
|
text,
|
||||||
|
parseMode,
|
||||||
|
disableNotification,
|
||||||
|
replyToMessageId,
|
||||||
|
replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendDocument(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
document: DocumentFile,
|
||||||
|
thumb: PhotoSize? = document.thumb,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendDocument(
|
||||||
|
chatId, document.fileId, thumb ?.fileId, text, parseMode, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendDocument(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
document: MultipartFile,
|
||||||
|
thumb: FileId? = null,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
MultipartRequestImpl(
|
||||||
|
SendDocumentData(
|
||||||
|
chatId, null, thumb ?.fileId, text, parseMode, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
),
|
||||||
|
SendDocumentFiles(document)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendDocument(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
document: MultipartFile,
|
||||||
|
thumb: MultipartFile? = null,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
MultipartRequestImpl(
|
||||||
|
SendDocumentData(
|
||||||
|
chatId, null, null, text, parseMode, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
),
|
||||||
|
SendDocumentFiles(document, thumb)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendDocument(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
document: FileId,
|
||||||
|
thumb: MultipartFile,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
MultipartRequestImpl(
|
||||||
|
SendDocumentData(
|
||||||
|
chatId, document.fileId, null, text, parseMode, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
),
|
||||||
|
SendDocumentFiles(null, thumb)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendDocument(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
document: MultipartFile,
|
||||||
|
thumb: PhotoSize? = null,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendDocument(
|
||||||
|
chatId, document, thumb ?.fileId , text, parseMode, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendDocument(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
document: DocumentFile,
|
||||||
|
thumb: MultipartFile,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendDocument(
|
||||||
|
chatId, document.fileId, thumb, text, parseMode, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.send.media
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.send.media
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendMessageRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendMessageRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.*
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.MediaGroupMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.MediaGroupMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializerClass
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializerClass
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toJsonWithoutNulls
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.toJsonWithoutNulls
|
||||||
@@ -85,3 +87,23 @@ data class SendMediaGroupData internal constructor(
|
|||||||
data class SendMediaGroupFiles internal constructor(
|
data class SendMediaGroupFiles internal constructor(
|
||||||
val files: List<MultipartFile>
|
val files: List<MultipartFile>
|
||||||
) : Files by (files.map { it.fileId to it }.toMap())
|
) : Files by (files.map { it.fileId to it }.toMap())
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendMediaGroup(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
media: List<MediaGroupMemberInputMedia>,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null
|
||||||
|
) = execute(
|
||||||
|
SendMediaGroup(
|
||||||
|
chatId, media, disableNotification, replyToMessageId
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendMediaGroup(
|
||||||
|
chat: Chat,
|
||||||
|
media: List<MediaGroupMemberInputMedia>,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null
|
||||||
|
) = sendMediaGroup(
|
||||||
|
chat.id, media, disableNotification, replyToMessageId
|
||||||
|
)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.send.media
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.send.media
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.*
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.*
|
||||||
@@ -7,6 +8,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.KeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.PhotoContent
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.PhotoContent
|
||||||
@@ -82,3 +85,89 @@ data class SendPhotoFiles internal constructor(
|
|||||||
) : Files by mapOf(
|
) : Files by mapOf(
|
||||||
photoField to photo
|
photoField to photo
|
||||||
)
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendPhoto(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
fileId: FileId,
|
||||||
|
caption: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
SendPhotoData(
|
||||||
|
chatId,
|
||||||
|
fileId.fileId,
|
||||||
|
caption,
|
||||||
|
parseMode,
|
||||||
|
disableNotification,
|
||||||
|
replyToMessageId,
|
||||||
|
replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendPhoto(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
file: PhotoSize,
|
||||||
|
caption: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendPhoto(
|
||||||
|
chatId, file.fileId, caption, parseMode, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendPhoto(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
photo: Photo,
|
||||||
|
caption: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendPhoto(
|
||||||
|
chatId, photo.biggest() ?: throw IllegalArgumentException("Photo $photo is empty"), caption, parseMode, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendPhoto(
|
||||||
|
chat: Chat,
|
||||||
|
fileId: FileId,
|
||||||
|
caption: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendPhoto(
|
||||||
|
chat.id,
|
||||||
|
fileId,
|
||||||
|
caption,
|
||||||
|
parseMode,
|
||||||
|
disableNotification,
|
||||||
|
replyToMessageId,
|
||||||
|
replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendPhoto(
|
||||||
|
chat: Chat,
|
||||||
|
file: PhotoSize,
|
||||||
|
caption: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendPhoto(
|
||||||
|
chat.id, file.fileId, caption, parseMode, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendPhoto(
|
||||||
|
chat: Chat,
|
||||||
|
photo: Photo,
|
||||||
|
caption: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendPhoto(
|
||||||
|
chat.id, photo.biggest() ?: throw IllegalArgumentException("Photo $photo is empty"), caption, parseMode, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.send.media
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.send.media
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.ReplyingMarkupSendMessageRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.ReplyingMarkupSendMessageRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendMessageRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendMessageRequest
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.MultipartRequestImpl
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.Sticker
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.StickerContent
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.StickerContent
|
||||||
@@ -64,3 +68,60 @@ data class SendStickerByFile internal constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendSticker(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
sticker: FileId,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
SendStickerByFileId(chatId, sticker, disableNotification, replyToMessageId, replyMarkup)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendSticker(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
sticker: MultipartFile,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
SendStickerByFile(
|
||||||
|
SendStickerByFileId(chatId, null, disableNotification, replyToMessageId, replyMarkup),
|
||||||
|
sticker
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendSticker(
|
||||||
|
chat: Chat,
|
||||||
|
sticker: FileId,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendSticker(chat.id, sticker, disableNotification, replyToMessageId, replyMarkup)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendSticker(
|
||||||
|
chat: Chat,
|
||||||
|
sticker: MultipartFile,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendSticker(chat.id, sticker, disableNotification, replyToMessageId, replyMarkup)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendSticker(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
sticker: Sticker,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendSticker(
|
||||||
|
chatId, sticker.fileId, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendSticker(
|
||||||
|
chat: Chat,
|
||||||
|
sticker: Sticker,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendSticker(chat.id, sticker.fileId, disableNotification, replyToMessageId, replyMarkup)
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.send.media
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.send.media
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.*
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.*
|
||||||
@@ -7,6 +8,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.KeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.VideoFile
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.PhotoSize
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.VideoContent
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.VideoContent
|
||||||
@@ -116,3 +119,141 @@ data class SendVideoFiles internal constructor(
|
|||||||
videoField to video,
|
videoField to video,
|
||||||
thumbField to thumb
|
thumbField to thumb
|
||||||
)
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendVideo(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
video: FileId,
|
||||||
|
thumb: FileId? = null,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
duration: Long? = null,
|
||||||
|
width: Int? = null,
|
||||||
|
height: Int? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
SendVideoData(
|
||||||
|
chatId,
|
||||||
|
video.fileId,
|
||||||
|
thumb ?.fileId,
|
||||||
|
text,
|
||||||
|
parseMode,
|
||||||
|
duration,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
null,
|
||||||
|
disableNotification,
|
||||||
|
replyToMessageId,
|
||||||
|
replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendVideo(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
video: VideoFile,
|
||||||
|
thumb: PhotoSize? = video.thumb,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendVideo(
|
||||||
|
chatId, video.fileId, thumb ?.fileId, text, parseMode, video.duration, video.width, video.height, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendVideo(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
video: MultipartFile,
|
||||||
|
thumb: FileId? = null,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
duration: Long? = null,
|
||||||
|
width: Int? = null,
|
||||||
|
height: Int? = null,
|
||||||
|
supportStreaming: Boolean? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
MultipartRequestImpl(
|
||||||
|
SendVideoData(
|
||||||
|
chatId, null, thumb ?.fileId, text, parseMode, duration, width, height, supportStreaming, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
),
|
||||||
|
SendVideoFiles(video)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendVideo(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
video: MultipartFile,
|
||||||
|
thumb: MultipartFile? = null,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
duration: Long? = null,
|
||||||
|
width: Int? = null,
|
||||||
|
height: Int? = null,
|
||||||
|
supportStreaming: Boolean? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
MultipartRequestImpl(
|
||||||
|
SendVideoData(
|
||||||
|
chatId, null, null, text, parseMode, duration, width, height, supportStreaming, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
),
|
||||||
|
SendVideoFiles(video, thumb)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendVideo(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
video: FileId,
|
||||||
|
thumb: MultipartFile,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
duration: Long? = null,
|
||||||
|
width: Int? = null,
|
||||||
|
height: Int? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
MultipartRequestImpl(
|
||||||
|
SendVideoData(
|
||||||
|
chatId, video.fileId, null, text, parseMode, duration, width, height, null, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
),
|
||||||
|
SendVideoFiles(null, thumb)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendVideo(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
video: MultipartFile,
|
||||||
|
thumb: PhotoSize? = null,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
duration: Long? = null,
|
||||||
|
width: Int? = null,
|
||||||
|
height: Int? = null,
|
||||||
|
supportStreaming: Boolean? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendVideo(
|
||||||
|
chatId, video, thumb ?.fileId , text, parseMode, duration, width, height, supportStreaming, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendVideo(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
video: VideoFile,
|
||||||
|
thumb: MultipartFile,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendVideo(
|
||||||
|
chatId, video.fileId, thumb, text, parseMode, video.duration, video.width, video.height, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.send.media
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.send.media
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.*
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.*
|
||||||
@@ -7,6 +8,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.KeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.PhotoSize
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.VideoFile
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.VideoNoteContent
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.VideoNoteContent
|
||||||
@@ -111,3 +114,130 @@ data class SendVideoNoteFiles internal constructor(
|
|||||||
videoNoteField to videoNote,
|
videoNoteField to videoNote,
|
||||||
thumbField to thumb
|
thumbField to thumb
|
||||||
)
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendVideoNote(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
videoNote: FileId,
|
||||||
|
thumb: FileId? = null,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
duration: Long? = null,
|
||||||
|
size: Int? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
SendVideoNoteData(
|
||||||
|
chatId,
|
||||||
|
videoNote.fileId,
|
||||||
|
thumb ?.fileId,
|
||||||
|
text,
|
||||||
|
parseMode,
|
||||||
|
duration,
|
||||||
|
size,
|
||||||
|
disableNotification,
|
||||||
|
replyToMessageId,
|
||||||
|
replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendVideoNote(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
videoNote: VideoFile,
|
||||||
|
thumb: PhotoSize? = videoNote.thumb,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendVideoNote(
|
||||||
|
chatId, videoNote.fileId, thumb ?.fileId, text, parseMode, videoNote.duration, videoNote.width, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendVideoNote(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
videoNote: MultipartFile,
|
||||||
|
thumb: FileId? = null,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
duration: Long? = null,
|
||||||
|
size: Int? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
MultipartRequestImpl(
|
||||||
|
SendVideoNoteData(
|
||||||
|
chatId, null, thumb ?.fileId, text, parseMode, duration, size, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
),
|
||||||
|
SendVideoNoteFiles(videoNote)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendVideoNote(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
videoNote: MultipartFile,
|
||||||
|
thumb: MultipartFile? = null,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
duration: Long? = null,
|
||||||
|
size: Int? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
MultipartRequestImpl(
|
||||||
|
SendVideoNoteData(
|
||||||
|
chatId, null, null, text, parseMode, duration, size, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
),
|
||||||
|
SendVideoNoteFiles(videoNote, thumb)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendVideoNote(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
videoNote: FileId,
|
||||||
|
thumb: MultipartFile,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
duration: Long? = null,
|
||||||
|
size: Int? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
MultipartRequestImpl(
|
||||||
|
SendVideoNoteData(
|
||||||
|
chatId, videoNote.fileId, null, text, parseMode, duration, size, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
),
|
||||||
|
SendVideoNoteFiles(null, thumb)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendVideoNote(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
videoNote: MultipartFile,
|
||||||
|
thumb: PhotoSize? = null,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
duration: Long? = null,
|
||||||
|
size: Int? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendVideoNote(
|
||||||
|
chatId, videoNote, thumb ?.fileId , text, parseMode, duration, size, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendVideoNote(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
videoNote: VideoFile,
|
||||||
|
thumb: MultipartFile,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendVideoNote(
|
||||||
|
chatId, videoNote.fileId, thumb, text, parseMode, videoNote.duration, videoNote.width, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.send.media
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.send.media
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.*
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.*
|
||||||
@@ -7,6 +8,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.KeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.AudioFile
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.PhotoSize
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.VoiceContent
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.VoiceContent
|
||||||
@@ -103,3 +106,125 @@ data class SendVoiceFiles internal constructor(
|
|||||||
voiceField to voice,
|
voiceField to voice,
|
||||||
thumbField to thumb
|
thumbField to thumb
|
||||||
)
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendVoice(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
voice: FileId,
|
||||||
|
thumb: FileId? = null,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
duration: Long? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
SendVoiceData(
|
||||||
|
chatId,
|
||||||
|
voice.fileId,
|
||||||
|
thumb ?.fileId,
|
||||||
|
text,
|
||||||
|
parseMode,
|
||||||
|
duration,
|
||||||
|
disableNotification,
|
||||||
|
replyToMessageId,
|
||||||
|
replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendVoice(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
voice: AudioFile,
|
||||||
|
thumb: PhotoSize? = voice.thumb,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendVoice(
|
||||||
|
chatId, voice.fileId, thumb ?.fileId, text, parseMode, voice.duration, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendVoice(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
voice: MultipartFile,
|
||||||
|
thumb: FileId? = null,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
duration: Long? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
MultipartRequestImpl(
|
||||||
|
SendVoiceData(
|
||||||
|
chatId, null, thumb ?.fileId, text, parseMode, duration, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
),
|
||||||
|
SendVoiceFiles(voice)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendVoice(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
voice: MultipartFile,
|
||||||
|
thumb: MultipartFile? = null,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
duration: Long? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
MultipartRequestImpl(
|
||||||
|
SendVoiceData(
|
||||||
|
chatId, null, null, text, parseMode, duration, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
),
|
||||||
|
SendVoiceFiles(voice, thumb)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendVoice(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
voice: FileId,
|
||||||
|
thumb: MultipartFile,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
duration: Long? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
MultipartRequestImpl(
|
||||||
|
SendVoiceData(
|
||||||
|
chatId, voice.fileId, null, text, parseMode, duration, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
),
|
||||||
|
SendVoiceFiles(null, thumb)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendVoice(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
voice: MultipartFile,
|
||||||
|
thumb: PhotoSize? = null,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
duration: Long? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendVoice(
|
||||||
|
chatId, voice, thumb ?.fileId , text, parseMode, duration, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendVoice(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
voice: AudioFile,
|
||||||
|
thumb: MultipartFile,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendVoice(
|
||||||
|
chatId, voice.fileId, thumb, text, parseMode, voice.duration, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,20 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.send.payments
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.send.payments
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendMessageRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendMessageRequest
|
||||||
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.abstracts.Message
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.payments.InvoiceContent
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.LabeledPrice
|
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.LabeledPrice
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.LabeledPricesSerializer
|
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.LabeledPricesSerializer
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.abstracts.*
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
|
private val invoiceMessageSerializer: DeserializationStrategy<ContentMessage<InvoiceContent>>
|
||||||
|
= TelegramBotAPIMessageDeserializationStrategyClass()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param providerData - JSON-ENCODED FIELD
|
* @param providerData - JSON-ENCODED FIELD
|
||||||
*/
|
*/
|
||||||
@@ -61,10 +65,10 @@ data class SendInvoice(
|
|||||||
DisableNotification,
|
DisableNotification,
|
||||||
ReplyMessageId,
|
ReplyMessageId,
|
||||||
ReplyMarkup,
|
ReplyMarkup,
|
||||||
SendMessageRequest<Message> {
|
SendMessageRequest<ContentMessage<InvoiceContent>> {
|
||||||
override fun method(): String = "sendInvoice"
|
override fun method(): String = "sendInvoice"
|
||||||
override val resultDeserializer: DeserializationStrategy<Message>
|
override val resultDeserializer: DeserializationStrategy<ContentMessage<InvoiceContent>>
|
||||||
get() = TelegramBotAPIMessageDeserializationStrategy
|
get() = invoiceMessageSerializer
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
|
|
||||||
@@ -100,4 +104,50 @@ data class SendInvoice(
|
|||||||
photoWidth = null
|
photoWidth = null
|
||||||
photoHeight = null
|
photoHeight = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendInvoice(
|
||||||
|
chatId: ChatId,
|
||||||
|
title: String,
|
||||||
|
description: String,
|
||||||
|
payload: String,
|
||||||
|
providerToken: String,
|
||||||
|
startParameter: StartParameter,
|
||||||
|
currency: Currency,
|
||||||
|
prices: List<LabeledPrice>,
|
||||||
|
providerData: String? = null,
|
||||||
|
requireName: Boolean = false,
|
||||||
|
requirePhoneNumber: Boolean = false,
|
||||||
|
requireEmail: Boolean = false,
|
||||||
|
requireShippingAddress: Boolean = false,
|
||||||
|
shouldSendPhoneNumberToProvider: Boolean = false,
|
||||||
|
shouldSendEmailToProvider: Boolean = false,
|
||||||
|
priceDependOnShipAddress: Boolean = false,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
SendInvoice(chatId, title, description, payload, providerToken, startParameter, currency, prices, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, disableNotification, replyToMessageId, replyMarkup)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendInvoice(
|
||||||
|
user: CommonUser,
|
||||||
|
title: String,
|
||||||
|
description: String,
|
||||||
|
payload: String,
|
||||||
|
providerToken: String,
|
||||||
|
startParameter: StartParameter,
|
||||||
|
currency: Currency,
|
||||||
|
prices: List<LabeledPrice>,
|
||||||
|
providerData: String? = null,
|
||||||
|
requireName: Boolean = false,
|
||||||
|
requirePhoneNumber: Boolean = false,
|
||||||
|
requireEmail: Boolean = false,
|
||||||
|
requireShippingAddress: Boolean = false,
|
||||||
|
shouldSendPhoneNumberToProvider: Boolean = false,
|
||||||
|
shouldSendEmailToProvider: Boolean = false,
|
||||||
|
priceDependOnShipAddress: Boolean = false,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = sendInvoice(user.id, title, description, payload, providerToken, startParameter, currency, prices, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, disableNotification, replyToMessageId, replyMarkup)
|
||||||
|
|||||||
@@ -0,0 +1,312 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.send.polls
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.ReplyingMarkupSendMessageRequest
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendMessageRequest
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.PollContent
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.polls.*
|
||||||
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
|
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<PollContent>> = TelegramBotAPIMessageDeserializationStrategyClass()
|
||||||
|
|
||||||
|
private fun checkPollInfo(
|
||||||
|
question: String,
|
||||||
|
options: List<String>
|
||||||
|
) {
|
||||||
|
if (question.length !in pollQuestionTextLength) {
|
||||||
|
throw IllegalArgumentException("The length of questions for polls must be in $pollQuestionTextLength range, but was ${question.length}")
|
||||||
|
}
|
||||||
|
options.forEach {
|
||||||
|
if (it.length !in pollOptionTextLength) {
|
||||||
|
throw IllegalArgumentException("The length of question option text for polls must be in $pollOptionTextLength range, but was ${it.length}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (options.size !in pollOptionsLimit) {
|
||||||
|
throw IllegalArgumentException("The amount of question options for polls must be in $pollOptionsLimit range, but was ${options.size}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun SendPoll(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
question: String,
|
||||||
|
options: List<String>,
|
||||||
|
isAnonymous: Boolean = true,
|
||||||
|
isClosed: Boolean = false,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = SendRegularPoll(
|
||||||
|
chatId,
|
||||||
|
question,
|
||||||
|
options,
|
||||||
|
isAnonymous,
|
||||||
|
isClosed,
|
||||||
|
disableNotification = disableNotification,
|
||||||
|
replyToMessageId = replyToMessageId,
|
||||||
|
replyMarkup = replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return [SendPoll] in case when all is right. It can return [SendRegularPoll] for [QuizPoll] in case if
|
||||||
|
* [QuizPoll.correctOptionId] equal to null
|
||||||
|
*/
|
||||||
|
fun Poll.createRequest(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = when (this) {
|
||||||
|
is RegularPoll -> SendRegularPoll(
|
||||||
|
chatId,
|
||||||
|
question,
|
||||||
|
options.map { it.text },
|
||||||
|
isAnonymous,
|
||||||
|
isClosed,
|
||||||
|
allowMultipleAnswers,
|
||||||
|
disableNotification,
|
||||||
|
replyToMessageId,
|
||||||
|
replyMarkup
|
||||||
|
)
|
||||||
|
is QuizPoll -> correctOptionId ?.let { correctOptionId ->
|
||||||
|
SendQuizPoll(
|
||||||
|
chatId,
|
||||||
|
question,
|
||||||
|
options.map { it.text },
|
||||||
|
correctOptionId,
|
||||||
|
isAnonymous,
|
||||||
|
isClosed,
|
||||||
|
disableNotification,
|
||||||
|
replyToMessageId,
|
||||||
|
replyMarkup
|
||||||
|
)
|
||||||
|
} ?: SendRegularPoll(
|
||||||
|
chatId,
|
||||||
|
question,
|
||||||
|
options.map { it.text },
|
||||||
|
isAnonymous,
|
||||||
|
isClosed,
|
||||||
|
false,
|
||||||
|
disableNotification,
|
||||||
|
replyToMessageId,
|
||||||
|
replyMarkup
|
||||||
|
)
|
||||||
|
is UnknownPollType -> SendRegularPoll(
|
||||||
|
chatId,
|
||||||
|
question,
|
||||||
|
options.map { it.text },
|
||||||
|
isAnonymous,
|
||||||
|
isClosed,
|
||||||
|
false,
|
||||||
|
disableNotification,
|
||||||
|
replyToMessageId,
|
||||||
|
replyMarkup
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
sealed class SendPoll : SendMessageRequest<ContentMessage<PollContent>>,
|
||||||
|
ReplyingMarkupSendMessageRequest<ContentMessage<PollContent>> {
|
||||||
|
abstract val question: String
|
||||||
|
abstract val options: List<String>
|
||||||
|
abstract val isAnonymous: Boolean
|
||||||
|
abstract val isClosed: Boolean
|
||||||
|
abstract val type: String
|
||||||
|
|
||||||
|
override fun method(): String = "sendPoll"
|
||||||
|
override val resultDeserializer: DeserializationStrategy<ContentMessage<PollContent>>
|
||||||
|
get() = commonResultDeserializer
|
||||||
|
}
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class SendRegularPoll(
|
||||||
|
@SerialName(chatIdField)
|
||||||
|
override val chatId: ChatIdentifier,
|
||||||
|
@SerialName(questionField)
|
||||||
|
override val question: String,
|
||||||
|
@SerialName(optionsField)
|
||||||
|
override val options: List<String>,
|
||||||
|
@SerialName(isAnonymousField)
|
||||||
|
override val isAnonymous: Boolean = true,
|
||||||
|
@SerialName(isClosedField)
|
||||||
|
override val isClosed: Boolean = false,
|
||||||
|
@SerialName(allowsMultipleAnswersField)
|
||||||
|
val allowMultipleAnswers: Boolean = false,
|
||||||
|
@SerialName(disableNotificationField)
|
||||||
|
override val disableNotification: Boolean = false,
|
||||||
|
@SerialName(replyToMessageIdField)
|
||||||
|
override val replyToMessageId: MessageIdentifier? = null,
|
||||||
|
@SerialName(replyMarkupField)
|
||||||
|
override val replyMarkup: KeyboardMarkup? = null
|
||||||
|
) : SendPoll() {
|
||||||
|
override val type: String = regularPollType
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
|
|
||||||
|
init {
|
||||||
|
checkPollInfo(question, options)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class SendQuizPoll(
|
||||||
|
@SerialName(chatIdField)
|
||||||
|
override val chatId: ChatIdentifier,
|
||||||
|
@SerialName(questionField)
|
||||||
|
override val question: String,
|
||||||
|
@SerialName(optionsField)
|
||||||
|
override val options: List<String>,
|
||||||
|
@SerialName(correctOptionIdField)
|
||||||
|
val correctOptionId: Int,
|
||||||
|
@SerialName(isAnonymousField)
|
||||||
|
override val isAnonymous: Boolean = true,
|
||||||
|
@SerialName(isClosedField)
|
||||||
|
override val isClosed: Boolean = false,
|
||||||
|
@SerialName(disableNotificationField)
|
||||||
|
override val disableNotification: Boolean = false,
|
||||||
|
@SerialName(replyToMessageIdField)
|
||||||
|
override val replyToMessageId: MessageIdentifier? = null,
|
||||||
|
@SerialName(replyMarkupField)
|
||||||
|
override val replyMarkup: KeyboardMarkup? = null
|
||||||
|
) : SendPoll() {
|
||||||
|
override val type: String = quizPollType
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
|
|
||||||
|
init {
|
||||||
|
checkPollInfo(question, options)
|
||||||
|
val correctOptionIdRange = 0 .. options.size
|
||||||
|
if (correctOptionId !in correctOptionIdRange) {
|
||||||
|
throw IllegalArgumentException("Correct option id must be in range of $correctOptionIdRange, but actual " +
|
||||||
|
"value is $correctOptionId")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendRegularPoll(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
question: String,
|
||||||
|
options: List<String>,
|
||||||
|
isAnonymous: Boolean = true,
|
||||||
|
isClosed: Boolean = false,
|
||||||
|
allowMultipleAnswers: Boolean = false,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
SendRegularPoll(
|
||||||
|
chatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
|
suspend fun RequestsExecutor.sendRegularPoll(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
poll: RegularPoll,
|
||||||
|
isClosed: Boolean = false,
|
||||||
|
question: String = poll.question,
|
||||||
|
options: List<String> = poll.options.map { it.text },
|
||||||
|
isAnonymous: Boolean = poll.isAnonymous,
|
||||||
|
allowMultipleAnswers: Boolean = poll.allowMultipleAnswers,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
SendRegularPoll(
|
||||||
|
chatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendRegularPoll(
|
||||||
|
chat: Chat,
|
||||||
|
question: String,
|
||||||
|
options: List<String>,
|
||||||
|
isAnonymous: Boolean = true,
|
||||||
|
isClosed: Boolean = false,
|
||||||
|
allowMultipleAnswers: Boolean = false,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendRegularPoll(
|
||||||
|
chat.id, question, options, isAnonymous, isClosed, allowMultipleAnswers, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendRegularPoll(
|
||||||
|
chat: Chat,
|
||||||
|
poll: RegularPoll,
|
||||||
|
isClosed: Boolean = false,
|
||||||
|
question: String = poll.question,
|
||||||
|
options: List<String> = poll.options.map { it.text },
|
||||||
|
isAnonymous: Boolean = poll.isAnonymous,
|
||||||
|
allowMultipleAnswers: Boolean = poll.allowMultipleAnswers,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendRegularPoll(
|
||||||
|
chat.id, question, options, isAnonymous, isClosed, allowMultipleAnswers, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendQuizPoll(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
question: String,
|
||||||
|
options: List<String>,
|
||||||
|
correctOptionId: Int,
|
||||||
|
isAnonymous: Boolean = true,
|
||||||
|
isClosed: Boolean = false,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
SendQuizPoll(
|
||||||
|
chatId, question, options, correctOptionId, isAnonymous, isClosed, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendQuizPoll(
|
||||||
|
chat: Chat,
|
||||||
|
question: String,
|
||||||
|
options: List<String>,
|
||||||
|
correctOptionId: Int,
|
||||||
|
isAnonymous: Boolean = true,
|
||||||
|
isClosed: Boolean = false,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendQuizPoll(
|
||||||
|
chat.id, question, options, correctOptionId, isAnonymous, isClosed, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendQuizPoll(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
isClosed: Boolean = false,
|
||||||
|
quizPoll: QuizPoll,
|
||||||
|
question: String = quizPoll.question,
|
||||||
|
options: List<String> = quizPoll.options.map { it.text },
|
||||||
|
correctOptionId: Int = quizPoll.correctOptionId ?: error("Correct option ID must be provided by income QuizPoll or by developer"),
|
||||||
|
isAnonymous: Boolean = quizPoll.isAnonymous,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
SendQuizPoll(
|
||||||
|
chatId, question, options, correctOptionId, isAnonymous, isClosed, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendQuizPoll(
|
||||||
|
chat: Chat,
|
||||||
|
isClosed: Boolean = false,
|
||||||
|
quizPoll: QuizPoll,
|
||||||
|
question: String = quizPoll.question,
|
||||||
|
options: List<String> = quizPoll.options.map { it.text },
|
||||||
|
correctOptionId: Int = quizPoll.correctOptionId ?: error("Correct option ID must be provided by income QuizPoll or by developer"),
|
||||||
|
isAnonymous: Boolean = quizPoll.isAnonymous,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendQuizPoll(
|
||||||
|
chat.id, question, options, correctOptionId, isAnonymous, isClosed, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
@@ -1,10 +1,12 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.stickers
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.stickers
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.common.CommonMultipartFileRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.common.CommonMultipartFileRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.abstracts.StickerSetAction
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.abstracts.StickerSetAction
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.MaskPosition
|
import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.MaskPosition
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.StickerSet
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
fun AddStickerToSet(
|
fun AddStickerToSet(
|
||||||
@@ -48,3 +50,90 @@ data class AddStickerToSet internal constructor(
|
|||||||
|
|
||||||
override fun method(): String = "addStickerToSet"
|
override fun method(): String = "addStickerToSet"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.addStickerToSet(
|
||||||
|
userId: UserId,
|
||||||
|
stickerSetName: String,
|
||||||
|
sticker: FileId,
|
||||||
|
emojis: String,
|
||||||
|
maskPosition: MaskPosition? = null
|
||||||
|
) = execute(
|
||||||
|
AddStickerToSet(
|
||||||
|
userId, stickerSetName, emojis, sticker, maskPosition
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.addStickerToSet(
|
||||||
|
userId: UserId,
|
||||||
|
stickerSetName: String,
|
||||||
|
sticker: MultipartFile,
|
||||||
|
emojis: String,
|
||||||
|
maskPosition: MaskPosition? = null
|
||||||
|
) = execute(
|
||||||
|
CommonMultipartFileRequest(
|
||||||
|
AddStickerToSet(
|
||||||
|
userId, stickerSetName, emojis, null, maskPosition
|
||||||
|
),
|
||||||
|
mapOf(pngStickerField to sticker)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.addStickerToSet(
|
||||||
|
user: CommonUser,
|
||||||
|
stickerSetName: String,
|
||||||
|
sticker: FileId,
|
||||||
|
emojis: String,
|
||||||
|
maskPosition: MaskPosition? = null
|
||||||
|
) = addStickerToSet(
|
||||||
|
user.id, stickerSetName, sticker, emojis, maskPosition
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.addStickerToSet(
|
||||||
|
user: CommonUser,
|
||||||
|
stickerSetName: String,
|
||||||
|
sticker: MultipartFile,
|
||||||
|
emojis: String,
|
||||||
|
maskPosition: MaskPosition? = null
|
||||||
|
) = addStickerToSet(
|
||||||
|
user.id, stickerSetName, sticker, emojis, maskPosition
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.addStickerToSet(
|
||||||
|
userId: UserId,
|
||||||
|
stickerSet: StickerSet,
|
||||||
|
sticker: FileId,
|
||||||
|
emojis: String,
|
||||||
|
maskPosition: MaskPosition? = null
|
||||||
|
) = addStickerToSet(
|
||||||
|
userId, stickerSet.name, sticker, emojis, maskPosition
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.addStickerToSet(
|
||||||
|
userId: UserId,
|
||||||
|
stickerSet: StickerSet,
|
||||||
|
sticker: MultipartFile,
|
||||||
|
emojis: String,
|
||||||
|
maskPosition: MaskPosition? = null
|
||||||
|
) = addStickerToSet(
|
||||||
|
userId, stickerSet.name, sticker, emojis, maskPosition
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.addStickerToSet(
|
||||||
|
user: CommonUser,
|
||||||
|
stickerSet: StickerSet,
|
||||||
|
sticker: FileId,
|
||||||
|
emojis: String,
|
||||||
|
maskPosition: MaskPosition? = null
|
||||||
|
) = addStickerToSet(
|
||||||
|
user.id, stickerSet.name, sticker, emojis, maskPosition
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.addStickerToSet(
|
||||||
|
user: CommonUser,
|
||||||
|
stickerSet: StickerSet,
|
||||||
|
sticker: MultipartFile,
|
||||||
|
emojis: String,
|
||||||
|
maskPosition: MaskPosition? = null
|
||||||
|
) = addStickerToSet(
|
||||||
|
user.id, stickerSet.name, sticker, emojis, maskPosition
|
||||||
|
)
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.stickers
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.stickers
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.common.CommonMultipartFileRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.common.CommonMultipartFileRequest
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.MultipartRequestImpl
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.abstracts.StickerSetAction
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.abstracts.StickerSetAction
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.MaskPosition
|
import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.MaskPosition
|
||||||
@@ -51,3 +53,52 @@ data class CreateNewStickerSet internal constructor(
|
|||||||
|
|
||||||
override fun method(): String = "createNewStickerSet"
|
override fun method(): String = "createNewStickerSet"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.createNewStickerSet(
|
||||||
|
userId: UserId,
|
||||||
|
name: String,
|
||||||
|
sticker: FileId,
|
||||||
|
emojis: String,
|
||||||
|
containsMasks: Boolean? = null,
|
||||||
|
maskPosition: MaskPosition? = null
|
||||||
|
) = execute(
|
||||||
|
CreateNewStickerSet(userId, name, emojis, sticker, containsMasks, maskPosition)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.createNewStickerSet(
|
||||||
|
userId: UserId,
|
||||||
|
name: String,
|
||||||
|
sticker: MultipartFile,
|
||||||
|
emojis: String,
|
||||||
|
containsMasks: Boolean? = null,
|
||||||
|
maskPosition: MaskPosition? = null
|
||||||
|
) = execute(
|
||||||
|
CommonMultipartFileRequest(
|
||||||
|
CreateNewStickerSet(userId, name, emojis, null, containsMasks, maskPosition),
|
||||||
|
mapOf(pngStickerField to sticker)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.createNewStickerSet(
|
||||||
|
user: CommonUser,
|
||||||
|
name: String,
|
||||||
|
sticker: FileId,
|
||||||
|
emojis: String,
|
||||||
|
containsMasks: Boolean? = null,
|
||||||
|
maskPosition: MaskPosition? = null
|
||||||
|
) = createNewStickerSet(
|
||||||
|
user.id, name, sticker, emojis, containsMasks, maskPosition
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.createNewStickerSet(
|
||||||
|
user: CommonUser,
|
||||||
|
name: String,
|
||||||
|
sticker: MultipartFile,
|
||||||
|
emojis: String,
|
||||||
|
containsMasks: Boolean? = null,
|
||||||
|
maskPosition: MaskPosition? = null
|
||||||
|
) = createNewStickerSet(
|
||||||
|
user.id, name, sticker, emojis, containsMasks, maskPosition
|
||||||
|
)
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.stickers
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.stickers
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.Sticker
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.stickerField
|
import com.github.insanusmokrassar.TelegramBotAPI.types.stickerField
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.BooleanSerializer
|
import kotlinx.serialization.internal.BooleanSerializer
|
||||||
@@ -17,3 +19,19 @@ data class DeleteStickerFromSet(
|
|||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.deleteStickerFromSet(
|
||||||
|
sticker: FileId
|
||||||
|
) = execute(
|
||||||
|
DeleteStickerFromSet(
|
||||||
|
sticker
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.deleteStickerFromSet(
|
||||||
|
sticker: Sticker
|
||||||
|
) = deleteStickerFromSet(
|
||||||
|
sticker.fileId
|
||||||
|
)
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.stickers
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.stickers
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.Sticker
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.positionField
|
import com.github.insanusmokrassar.TelegramBotAPI.types.positionField
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.stickerField
|
import com.github.insanusmokrassar.TelegramBotAPI.types.stickerField
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
@@ -26,3 +28,21 @@ data class SetStickerPositionInSet(
|
|||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setStickerPositionInSet(
|
||||||
|
sticker: FileId,
|
||||||
|
position: Int
|
||||||
|
) = execute(
|
||||||
|
SetStickerPositionInSet(
|
||||||
|
sticker,
|
||||||
|
position
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setStickerPositionInSet(
|
||||||
|
sticker: Sticker,
|
||||||
|
position: Int
|
||||||
|
) = setStickerPositionInSet(
|
||||||
|
sticker.fileId,
|
||||||
|
position
|
||||||
|
)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.stickers
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.stickers
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
@@ -27,3 +28,18 @@ data class UploadStickerFile(
|
|||||||
override val resultDeserializer: DeserializationStrategy<File>
|
override val resultDeserializer: DeserializationStrategy<File>
|
||||||
get() = File.serializer()
|
get() = File.serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.uploadStickerFile(
|
||||||
|
userId: UserId,
|
||||||
|
sticker: MultipartFile
|
||||||
|
) = execute(
|
||||||
|
UploadStickerFile(userId, sticker)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.uploadStickerFile(
|
||||||
|
user: CommonUser,
|
||||||
|
sticker: MultipartFile
|
||||||
|
) = execute(
|
||||||
|
UploadStickerFile(user.id, sticker)
|
||||||
|
)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.webhook
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.webhook
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.WebhookInfo
|
import com.github.insanusmokrassar.TelegramBotAPI.types.WebhookInfo
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
@@ -13,3 +14,5 @@ class GetWebhookInfo : SimpleRequest<WebhookInfo> {
|
|||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getWebhookInfo() = execute(GetWebhookInfo())
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.webhook
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.webhook
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.DataRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.DataRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.MultipartRequestImpl
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.MultipartRequestImpl
|
||||||
@@ -64,3 +65,28 @@ data class SetWebhook internal constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setWebhookInfo(
|
||||||
|
url: String,
|
||||||
|
certificate: FileId,
|
||||||
|
maxAllowedConnections: Int? = null,
|
||||||
|
allowedUpdates: List<String>? = null
|
||||||
|
) = execute(
|
||||||
|
SetWebhook(
|
||||||
|
url, certificate.fileId, maxAllowedConnections, allowedUpdates
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setWebhookInfo(
|
||||||
|
url: String,
|
||||||
|
certificate: MultipartFile,
|
||||||
|
maxAllowedConnections: Int? = null,
|
||||||
|
allowedUpdates: List<String>? = null
|
||||||
|
) = execute(
|
||||||
|
MultipartRequestImpl(
|
||||||
|
SetWebhook(
|
||||||
|
url, null, maxAllowedConnections, allowedUpdates
|
||||||
|
),
|
||||||
|
mapOf(certificateField to certificate)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|||||||
@@ -57,6 +57,9 @@ const val isBotField = "is_bot"
|
|||||||
const val firstNameField = "first_name"
|
const val firstNameField = "first_name"
|
||||||
const val lastNameField = "last_name"
|
const val lastNameField = "last_name"
|
||||||
const val languageCodeField = "language_code"
|
const val languageCodeField = "language_code"
|
||||||
|
const val canJoinGroupsField = "can_join_groups"
|
||||||
|
const val canReadAllGroupMessagesField = "can_read_all_group_messages"
|
||||||
|
const val supportInlineQueriesField = "supports_inline_queries"
|
||||||
const val textEntitiesField = "text_entities"
|
const val textEntitiesField = "text_entities"
|
||||||
const val stickerSetNameField = "set_name"
|
const val stickerSetNameField = "set_name"
|
||||||
const val stickerSetNameFullField = "sticker_set_name"
|
const val stickerSetNameFullField = "sticker_set_name"
|
||||||
@@ -90,6 +93,10 @@ const val lastErrorDateField = "last_error_date"
|
|||||||
const val lastErrorMessageField = "last_error_message"
|
const val lastErrorMessageField = "last_error_message"
|
||||||
const val votesCountField = "voter_count"
|
const val votesCountField = "voter_count"
|
||||||
const val isClosedField = "is_closed"
|
const val isClosedField = "is_closed"
|
||||||
|
const val totalVoterCountField = "total_voter_count"
|
||||||
|
const val correctOptionIdField = "correct_option_id"
|
||||||
|
const val allowsMultipleAnswersField = "allows_multiple_answers"
|
||||||
|
const val isAnonymousField = "is_anonymous"
|
||||||
const val loginUrlField = "login_url"
|
const val loginUrlField = "login_url"
|
||||||
const val forwardTextField = "forward_text"
|
const val forwardTextField = "forward_text"
|
||||||
const val botUsernameField = "bot_username"
|
const val botUsernameField = "bot_username"
|
||||||
@@ -99,6 +106,11 @@ const val isAnimatedField = "is_animated"
|
|||||||
const val inviteLinkField = "invite_link"
|
const val inviteLinkField = "invite_link"
|
||||||
const val pinnedMessageField = "pinned_message"
|
const val pinnedMessageField = "pinned_message"
|
||||||
const val customTitleField = "custom_title"
|
const val customTitleField = "custom_title"
|
||||||
|
const val optionIdsField = "option_ids"
|
||||||
|
|
||||||
|
const val requestContactField = "request_contact"
|
||||||
|
const val requestLocationField = "request_location"
|
||||||
|
const val requestPollField = "request_poll"
|
||||||
|
|
||||||
|
|
||||||
const val requestWriteAccessField = "request_write_access"
|
const val requestWriteAccessField = "request_write_access"
|
||||||
@@ -173,6 +185,7 @@ const val pngStickerField = "png_sticker"
|
|||||||
const val okField = "ok"
|
const val okField = "ok"
|
||||||
const val captionField = "caption"
|
const val captionField = "caption"
|
||||||
const val idField = "id"
|
const val idField = "id"
|
||||||
|
const val pollIdField = "poll_id"
|
||||||
const val textField = "text"
|
const val textField = "text"
|
||||||
const val thumbField = "thumb"
|
const val thumbField = "thumb"
|
||||||
const val emojiField = "emoji"
|
const val emojiField = "emoji"
|
||||||
@@ -273,3 +286,6 @@ const val mediaField = "media"
|
|||||||
const val disableEditMessageField = "disable_edit_message"
|
const val disableEditMessageField = "disable_edit_message"
|
||||||
const val scoreField = "score"
|
const val scoreField = "score"
|
||||||
const val forceField = "force"
|
const val forceField = "force"
|
||||||
|
|
||||||
|
const val regularPollType = "regular"
|
||||||
|
const val quizPollType = "quiz"
|
||||||
|
|||||||
@@ -13,7 +13,8 @@ internal data class RawMessageEntity(
|
|||||||
val offset: Int,
|
val offset: Int,
|
||||||
val length: Int,
|
val length: Int,
|
||||||
val url: String? = null,
|
val url: String? = null,
|
||||||
val user: User? = null
|
val user: User? = null,
|
||||||
|
val language: String? = null
|
||||||
)
|
)
|
||||||
|
|
||||||
internal fun RawMessageEntity.asTextParts(source: String, subParts: List<TextPart>): List<TextPart> {
|
internal fun RawMessageEntity.asTextParts(source: String, subParts: List<TextPart>): List<TextPart> {
|
||||||
@@ -31,7 +32,7 @@ internal fun RawMessageEntity.asTextParts(source: String, subParts: List<TextPar
|
|||||||
"bold" -> BoldTextSource(sourceSubstring, shiftedSubParts)
|
"bold" -> BoldTextSource(sourceSubstring, shiftedSubParts)
|
||||||
"italic" -> ItalicTextSource(sourceSubstring, shiftedSubParts)
|
"italic" -> ItalicTextSource(sourceSubstring, shiftedSubParts)
|
||||||
"code" -> CodeTextSource(sourceSubstring)
|
"code" -> CodeTextSource(sourceSubstring)
|
||||||
"pre" -> PreTextSource(sourceSubstring)
|
"pre" -> PreTextSource(sourceSubstring, language)
|
||||||
"text_link" -> TextLinkTextSource(sourceSubstring, url ?: throw IllegalStateException("URL must not be null for text link"))
|
"text_link" -> TextLinkTextSource(sourceSubstring, url ?: throw IllegalStateException("URL must not be null for text link"))
|
||||||
"text_mention" -> TextMentionTextSource(sourceSubstring, user ?: throw IllegalStateException("User must not be null for text mention"), shiftedSubParts)
|
"text_mention" -> TextMentionTextSource(sourceSubstring, user ?: throw IllegalStateException("User must not be null for text mention"), shiftedSubParts)
|
||||||
"underline" -> UnderlineTextSource(sourceSubstring, shiftedSubParts)
|
"underline" -> UnderlineTextSource(sourceSubstring, shiftedSubParts)
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ const val UPDATE_CALLBACK_QUERY = "callback_query"
|
|||||||
const val UPDATE_SHIPPING_QUERY = "shipping_query"
|
const val UPDATE_SHIPPING_QUERY = "shipping_query"
|
||||||
const val UPDATE_PRE_CHECKOUT_QUERY = "pre_checkout_query"
|
const val UPDATE_PRE_CHECKOUT_QUERY = "pre_checkout_query"
|
||||||
const val UPDATE_POLL = "poll"
|
const val UPDATE_POLL = "poll"
|
||||||
|
const val UPDATE_POLL_ANSWER = "poll_answer"
|
||||||
|
|
||||||
val ALL_UPDATES_LIST = listOf(
|
val ALL_UPDATES_LIST = listOf(
|
||||||
UPDATE_MESSAGE,
|
UPDATE_MESSAGE,
|
||||||
@@ -21,5 +22,6 @@ val ALL_UPDATES_LIST = listOf(
|
|||||||
UPDATE_CALLBACK_QUERY,
|
UPDATE_CALLBACK_QUERY,
|
||||||
UPDATE_SHIPPING_QUERY,
|
UPDATE_SHIPPING_QUERY,
|
||||||
UPDATE_PRE_CHECKOUT_QUERY,
|
UPDATE_PRE_CHECKOUT_QUERY,
|
||||||
UPDATE_POLL
|
UPDATE_POLL,
|
||||||
|
UPDATE_POLL_ANSWER
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,14 +1,16 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types
|
package com.github.insanusmokrassar.TelegramBotAPI.types
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PrivateChat
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PrivateChat
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.json.Json
|
||||||
|
import kotlinx.serialization.json.JsonObjectSerializer
|
||||||
|
|
||||||
|
@Serializable(UserSerializer::class)
|
||||||
|
sealed class User : PrivateChat
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class User(
|
data class CommonUser(
|
||||||
override val id: ChatId,
|
override val id: ChatId,
|
||||||
@SerialName(isBotField)
|
|
||||||
val isBot: Boolean = false,
|
|
||||||
@SerialName(firstNameField)
|
@SerialName(firstNameField)
|
||||||
override val firstName: String,
|
override val firstName: String,
|
||||||
@SerialName(lastNameField)
|
@SerialName(lastNameField)
|
||||||
@@ -17,4 +19,80 @@ data class User(
|
|||||||
override val username: Username? = null,
|
override val username: Username? = null,
|
||||||
@SerialName(languageCodeField)
|
@SerialName(languageCodeField)
|
||||||
val languageCode: String? = null
|
val languageCode: String? = null
|
||||||
) : PrivateChat
|
) : User()
|
||||||
|
|
||||||
|
@Serializable(UserSerializer::class)
|
||||||
|
sealed class Bot : User()
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class CommonBot(
|
||||||
|
override val id: ChatId,
|
||||||
|
@SerialName(firstNameField)
|
||||||
|
override val firstName: String,
|
||||||
|
@SerialName(lastNameField)
|
||||||
|
override val lastName: String = "",
|
||||||
|
@SerialName(usernameField)
|
||||||
|
override val username: Username? = null
|
||||||
|
) : Bot() {
|
||||||
|
@SerialName(isBotField)
|
||||||
|
private val isBot = true
|
||||||
|
}
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class ExtendedBot(
|
||||||
|
override val id: ChatId,
|
||||||
|
@SerialName(firstNameField)
|
||||||
|
override val firstName: String,
|
||||||
|
@SerialName(lastNameField)
|
||||||
|
override val lastName: String = "",
|
||||||
|
@SerialName(usernameField)
|
||||||
|
override val username: Username? = null,
|
||||||
|
@SerialName(canJoinGroupsField)
|
||||||
|
val canJoinGroups: Boolean = false,
|
||||||
|
@SerialName(canReadAllGroupMessagesField)
|
||||||
|
val canReadAllGroupMessages: Boolean = false,
|
||||||
|
@SerialName(supportInlineQueriesField)
|
||||||
|
val supportsInlineQueries: Boolean = false
|
||||||
|
) : Bot() {
|
||||||
|
@SerialName(isBotField)
|
||||||
|
private val isBot = true
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Serializer(User::class)
|
||||||
|
internal object UserSerializer : KSerializer<User> {
|
||||||
|
override fun deserialize(decoder: Decoder): User {
|
||||||
|
val asJson = JsonObjectSerializer.deserialize(decoder)
|
||||||
|
|
||||||
|
return when {
|
||||||
|
asJson.getPrimitiveOrNull(isBotField) ?.booleanOrNull != true -> Json.nonstrict.fromJson(
|
||||||
|
CommonUser.serializer(),
|
||||||
|
asJson
|
||||||
|
)
|
||||||
|
else -> {
|
||||||
|
if ((asJson.get(canJoinGroupsField)
|
||||||
|
?: asJson.get(canReadAllGroupMessagesField)
|
||||||
|
?: asJson.get(supportInlineQueriesField)) != null
|
||||||
|
) {
|
||||||
|
Json.nonstrict.fromJson(
|
||||||
|
ExtendedBot.serializer(),
|
||||||
|
asJson
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
Json.nonstrict.fromJson(
|
||||||
|
CommonBot.serializer(),
|
||||||
|
asJson
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun serialize(encoder: Encoder, obj: User) {
|
||||||
|
when (obj) {
|
||||||
|
is CommonUser -> CommonUser.serializer().serialize(encoder, obj)
|
||||||
|
is CommonBot -> CommonBot.serializer().serialize(encoder, obj)
|
||||||
|
is ExtendedBot -> ExtendedBot.serializer().serialize(encoder, obj)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ internal object BotActionSerializer: KSerializer<BotAction> {
|
|||||||
UploadAudioAction.actionName -> UploadAudioAction
|
UploadAudioAction.actionName -> UploadAudioAction
|
||||||
UploadDocumentAction.actionName -> UploadDocumentAction
|
UploadDocumentAction.actionName -> UploadDocumentAction
|
||||||
FindLocationAction.actionName -> FindLocationAction
|
FindLocationAction.actionName -> FindLocationAction
|
||||||
|
RecordVideoNoteAction.actionName -> RecordVideoNoteAction
|
||||||
|
UploadVideoNoteAction.actionName -> UploadVideoNoteAction
|
||||||
else -> throw IllegalStateException("Unknown action type: $actionName")
|
else -> throw IllegalStateException("Unknown action type: $actionName")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -71,3 +73,13 @@ object UploadDocumentAction : BotAction() {
|
|||||||
object FindLocationAction : BotAction() {
|
object FindLocationAction : BotAction() {
|
||||||
override val actionName: String = "find_location"
|
override val actionName: String = "find_location"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Serializable(BotActionSerializer::class)
|
||||||
|
object RecordVideoNoteAction : BotAction() {
|
||||||
|
override val actionName: String = "record_video_note"
|
||||||
|
}
|
||||||
|
|
||||||
|
@Serializable(BotActionSerializer::class)
|
||||||
|
object UploadVideoNoteAction : BotAction() {
|
||||||
|
override val actionName: String = "upload_video_note"
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,13 +1,88 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.buttons
|
package com.github.insanusmokrassar.TelegramBotAPI.types.buttons
|
||||||
|
|
||||||
import kotlinx.serialization.SerialName
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.*
|
||||||
|
import kotlinx.serialization.internal.StringDescriptor
|
||||||
|
import kotlinx.serialization.json.*
|
||||||
|
|
||||||
|
@Serializable(KeyboardButtonSerializer::class)
|
||||||
|
sealed class KeyboardButton {
|
||||||
|
abstract val text: String
|
||||||
|
}
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class KeyboardButton(
|
data class SimpleKeyboardButton(
|
||||||
val text: String,
|
override val text: String
|
||||||
@SerialName("request_contact")
|
) : KeyboardButton()
|
||||||
val requestContact: Boolean? = null,
|
|
||||||
@SerialName("request_location")
|
@Serializable
|
||||||
val requestLocation: Boolean? = null
|
data class UnknownKeyboardButton internal constructor(
|
||||||
)
|
override val text: String,
|
||||||
|
val raw: String
|
||||||
|
) : KeyboardButton()
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class RequestContactKeyboardButton(
|
||||||
|
override val text: String
|
||||||
|
) : KeyboardButton() {
|
||||||
|
@SerialName(requestContactField)
|
||||||
|
val requestContact: Boolean = true
|
||||||
|
}
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class RequestLocationKeyboardButton(
|
||||||
|
override val text: String
|
||||||
|
) : KeyboardButton() {
|
||||||
|
@SerialName(requestLocationField)
|
||||||
|
val requestLocation: Boolean = true
|
||||||
|
}
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class RequestPollKeyboardButton(
|
||||||
|
override val text: String,
|
||||||
|
@SerialName(requestPollField)
|
||||||
|
val requestPoll: KeyboardButtonPollType
|
||||||
|
) : KeyboardButton()
|
||||||
|
|
||||||
|
@Serializer(KeyboardButton::class)
|
||||||
|
internal object KeyboardButtonSerializer : KSerializer<KeyboardButton> {
|
||||||
|
override fun deserialize(decoder: Decoder): KeyboardButton {
|
||||||
|
val asJson = JsonElementSerializer.deserialize(decoder)
|
||||||
|
|
||||||
|
return when {
|
||||||
|
asJson is JsonPrimitive -> SimpleKeyboardButton(asJson.content)
|
||||||
|
asJson is JsonObject && asJson.getPrimitiveOrNull(requestContactField) != null -> RequestContactKeyboardButton(
|
||||||
|
asJson.getPrimitive(textField).content
|
||||||
|
)
|
||||||
|
asJson is JsonObject && asJson.getPrimitiveOrNull(requestLocationField) != null -> RequestLocationKeyboardButton(
|
||||||
|
asJson.getPrimitive(textField).content
|
||||||
|
)
|
||||||
|
asJson is JsonObject && asJson.getObjectOrNull(requestPollField) != null -> RequestPollKeyboardButton(
|
||||||
|
asJson.getPrimitive(textField).content,
|
||||||
|
Json.nonstrict.fromJson(
|
||||||
|
KeyboardButtonPollType.serializer(),
|
||||||
|
asJson.getObject(requestPollField)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
else -> UnknownKeyboardButton(
|
||||||
|
when (asJson) {
|
||||||
|
is JsonObject -> asJson.getPrimitive(textField).content
|
||||||
|
is JsonArray -> ""
|
||||||
|
is JsonPrimitive -> asJson.content
|
||||||
|
},
|
||||||
|
asJson.toString()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun serialize(encoder: Encoder, obj: KeyboardButton) {
|
||||||
|
when (obj) {
|
||||||
|
is RequestContactKeyboardButton -> RequestContactKeyboardButton.serializer().serialize(encoder, obj)
|
||||||
|
is RequestLocationKeyboardButton -> RequestLocationKeyboardButton.serializer().serialize(encoder, obj)
|
||||||
|
is RequestPollKeyboardButton -> RequestPollKeyboardButton.serializer().serialize(encoder, obj)
|
||||||
|
is SimpleKeyboardButton -> encoder.encodeString(obj.text)
|
||||||
|
is UnknownKeyboardButton -> JsonElementSerializer.serialize(encoder, Json.nonstrict.parseJson(obj.raw))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.types.buttons
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
|
import kotlinx.serialization.*
|
||||||
|
import kotlinx.serialization.json.*
|
||||||
|
|
||||||
|
@Serializable(KeyboardButtonPollTypeSerializer::class)
|
||||||
|
sealed class KeyboardButtonPollType {
|
||||||
|
abstract val type: String
|
||||||
|
}
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
class UnknownKeyboardButtonPollType internal constructor(override val type: String): KeyboardButtonPollType()
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
object RegularKeyboardButtonPollType : KeyboardButtonPollType() {
|
||||||
|
override val type: String = regularPollType
|
||||||
|
}
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
object QuizKeyboardButtonPollType : KeyboardButtonPollType() {
|
||||||
|
override val type: String = quizPollType
|
||||||
|
}
|
||||||
|
|
||||||
|
@Serializer(KeyboardButtonPollType::class)
|
||||||
|
internal object KeyboardButtonPollTypeSerializer : KSerializer<KeyboardButtonPollType> {
|
||||||
|
override fun deserialize(decoder: Decoder): KeyboardButtonPollType {
|
||||||
|
val asJson = JsonElementSerializer.deserialize(decoder)
|
||||||
|
|
||||||
|
val type = when (asJson) {
|
||||||
|
is JsonPrimitive -> asJson.content
|
||||||
|
else -> asJson.jsonObject.getPrimitive(typeField).content
|
||||||
|
}
|
||||||
|
|
||||||
|
return when (type) {
|
||||||
|
regularPollType -> RegularKeyboardButtonPollType
|
||||||
|
quizPollType -> QuizKeyboardButtonPollType
|
||||||
|
else -> UnknownKeyboardButtonPollType(type)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Crutch due to the fact that direct serialization of objects currently does not work perfectly
|
||||||
|
*/
|
||||||
|
override fun serialize(encoder: Encoder, obj: KeyboardButtonPollType) {
|
||||||
|
JsonObjectSerializer.serialize(
|
||||||
|
encoder,
|
||||||
|
JsonObject(
|
||||||
|
mapOf(
|
||||||
|
typeField to JsonPrimitive(obj.type)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.message.ChatEvents
|
package com.github.insanusmokrassar.TelegramBotAPI.types.message.ChatEvents
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.Photo
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.files.PhotoSize
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.PhotoSize
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.ChatEvents.abstracts.CommonEvent
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.ChatEvents.abstracts.CommonEvent
|
||||||
|
|
||||||
data class NewChatPhoto(
|
data class NewChatPhoto(
|
||||||
val photo: List<PhotoSize>
|
val photo: Photo
|
||||||
): CommonEvent
|
): CommonEvent
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMa
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.payments.SuccessfulPaymentInfo
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.payments.abstracts.PaymentInfo
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.payments.abstracts.PaymentInfo
|
||||||
import com.soywiz.klock.DateTime
|
import com.soywiz.klock.DateTime
|
||||||
|
|
||||||
@@ -19,5 +20,5 @@ data class CommonMessageImpl<T: MessageContent>(
|
|||||||
override val forwardInfo: ForwardInfo?,
|
override val forwardInfo: ForwardInfo?,
|
||||||
override val replyTo: Message?,
|
override val replyTo: Message?,
|
||||||
override val replyMarkup: InlineKeyboardMarkup?,
|
override val replyMarkup: InlineKeyboardMarkup?,
|
||||||
val paymentInfo: PaymentInfo?
|
val paymentInfo: SuccessfulPaymentInfo?
|
||||||
) : Message, CommonMessage<T>, FromUserMessage
|
) : Message, CommonMessage<T>, FromUserMessage
|
||||||
@@ -14,9 +14,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Unknow
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.payments.InvoiceOfPayment
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.payments.InvoiceContent
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.payments.SuccessfulPaymentInfo
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.payments.SuccessfulPaymentInfo
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.payments.abstracts.PaymentInfo
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.Invoice
|
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.Invoice
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.SuccessfulPayment
|
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.SuccessfulPayment
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.polls.Poll
|
import com.github.insanusmokrassar.TelegramBotAPI.types.polls.Poll
|
||||||
@@ -130,6 +129,7 @@ internal data class RawMessage(
|
|||||||
location != null -> LocationContent(location)
|
location != null -> LocationContent(location)
|
||||||
venue != null -> VenueContent(venue)
|
venue != null -> VenueContent(venue)
|
||||||
poll != null -> PollContent(poll)
|
poll != null -> PollContent(poll)
|
||||||
|
invoice != null -> InvoiceContent(invoice)
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -175,9 +175,8 @@ internal data class RawMessage(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val paymentInfo: PaymentInfo? by lazy {
|
private val paymentInfo: SuccessfulPaymentInfo? by lazy {
|
||||||
when {
|
when {
|
||||||
invoice != null -> InvoiceOfPayment(invoice)
|
|
||||||
successful_payment != null -> SuccessfulPaymentInfo(successful_payment)
|
successful_payment != null -> SuccessfulPaymentInfo(successful_payment)
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,15 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.message.content
|
package com.github.insanusmokrassar.TelegramBotAPI.types.message.content
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.SendPoll
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.polls.SendPoll
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.polls.createRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.polls.Poll
|
import com.github.insanusmokrassar.TelegramBotAPI.types.polls.Poll
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.polls.RegularPoll
|
||||||
|
|
||||||
data class PollContent(
|
data class PollContent(
|
||||||
val poll: Poll
|
val poll: Poll
|
||||||
@@ -17,10 +19,8 @@ data class PollContent(
|
|||||||
disableNotification: Boolean,
|
disableNotification: Boolean,
|
||||||
replyToMessageId: MessageIdentifier?,
|
replyToMessageId: MessageIdentifier?,
|
||||||
replyMarkup: KeyboardMarkup?
|
replyMarkup: KeyboardMarkup?
|
||||||
): Request<ContentMessage<PollContent>> = SendPoll(
|
): Request<ContentMessage<PollContent>> = poll.createRequest(
|
||||||
chatId,
|
chatId,
|
||||||
poll.question,
|
|
||||||
poll.options.map { it.text },
|
|
||||||
disableNotification,
|
disableNotification,
|
||||||
replyToMessageId,
|
replyToMessageId,
|
||||||
replyMarkup
|
replyMarkup
|
||||||
|
|||||||
@@ -10,8 +10,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.HTMLParseMode
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.HTMLParseMode
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.MarkdownV2
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.MarkdownV2
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.files.PhotoSize
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.files.biggest
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaCollectionContent
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaCollectionContent
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaGroupContent
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaGroupContent
|
||||||
@@ -19,7 +18,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.utils.toHtmlCaptions
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownV2Captions
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownV2Captions
|
||||||
|
|
||||||
data class PhotoContent(
|
data class PhotoContent(
|
||||||
override val mediaCollection: List<PhotoSize>,
|
override val mediaCollection: Photo,
|
||||||
override val caption: String? = null,
|
override val caption: String? = null,
|
||||||
override val captionEntities: List<TextPart> = emptyList()
|
override val captionEntities: List<TextPart> = emptyList()
|
||||||
) : MediaCollectionContent<PhotoSize>, MediaGroupContent {
|
) : MediaCollectionContent<PhotoSize>, MediaGroupContent {
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.types.message.payments
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.Invoice
|
||||||
|
|
||||||
|
data class InvoiceContent(
|
||||||
|
val invoice: Invoice
|
||||||
|
) : MessageContent {
|
||||||
|
override fun createResend(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
disableNotification: Boolean,
|
||||||
|
replyToMessageId: MessageIdentifier?,
|
||||||
|
replyMarkup: KeyboardMarkup?
|
||||||
|
): Request<ContentMessage<InvoiceContent>> {
|
||||||
|
error("Unfortunately, currently InvoiceOfPayment can not be resend due to requirement of additional parameters," +
|
||||||
|
" which can't be provided during the call of this method")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.message.payments
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.payments.abstracts.PaymentInfo
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.Invoice
|
|
||||||
|
|
||||||
data class InvoiceOfPayment(
|
|
||||||
val invoice: Invoice
|
|
||||||
) : PaymentInfo
|
|
||||||
@@ -1,17 +1,119 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.polls
|
package com.github.insanusmokrassar.TelegramBotAPI.types.polls
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.internal.ArrayListSerializer
|
||||||
|
import kotlinx.serialization.json.*
|
||||||
|
|
||||||
|
@Serializable(PollSerializer::class)
|
||||||
|
sealed class Poll {
|
||||||
|
abstract val id: PollIdentifier
|
||||||
|
abstract val question: String
|
||||||
|
abstract val options: List<PollOption>
|
||||||
|
abstract val votesCount: Int
|
||||||
|
abstract val isClosed: Boolean
|
||||||
|
abstract val isAnonymous: Boolean
|
||||||
|
}
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class Poll(
|
data class UnknownPollType internal constructor(
|
||||||
@SerialName(idField)
|
@SerialName(idField)
|
||||||
val id: PollIdentifier,
|
override val id: PollIdentifier,
|
||||||
@SerialName(questionField)
|
@SerialName(questionField)
|
||||||
val question: String,
|
override val question: String,
|
||||||
@SerialName(optionsField)
|
@SerialName(optionsField)
|
||||||
val options: List<PollOption>,
|
override val options: List<PollOption>,
|
||||||
|
@SerialName(totalVoterCountField)
|
||||||
|
override val votesCount: Int,
|
||||||
@SerialName(isClosedField)
|
@SerialName(isClosedField)
|
||||||
val closed: Boolean = false
|
override val isClosed: Boolean = false,
|
||||||
)
|
@SerialName(isAnonymousField)
|
||||||
|
override val isAnonymous: Boolean = false,
|
||||||
|
val raw: String
|
||||||
|
) : Poll()
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class RegularPoll(
|
||||||
|
@SerialName(idField)
|
||||||
|
override val id: PollIdentifier,
|
||||||
|
@SerialName(questionField)
|
||||||
|
override val question: String,
|
||||||
|
@SerialName(optionsField)
|
||||||
|
override val options: List<PollOption>,
|
||||||
|
@SerialName(totalVoterCountField)
|
||||||
|
override val votesCount: Int,
|
||||||
|
@SerialName(isClosedField)
|
||||||
|
override val isClosed: Boolean = false,
|
||||||
|
@SerialName(isAnonymousField)
|
||||||
|
override val isAnonymous: Boolean = false,
|
||||||
|
@SerialName(allowsMultipleAnswersField)
|
||||||
|
val allowMultipleAnswers: Boolean = false
|
||||||
|
) : Poll()
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class QuizPoll(
|
||||||
|
@SerialName(idField)
|
||||||
|
override val id: PollIdentifier,
|
||||||
|
@SerialName(questionField)
|
||||||
|
override val question: String,
|
||||||
|
@SerialName(optionsField)
|
||||||
|
override val options: List<PollOption>,
|
||||||
|
@SerialName(totalVoterCountField)
|
||||||
|
override val votesCount: Int,
|
||||||
|
/**
|
||||||
|
* Nullable due to documentation (https://core.telegram.org/bots/api#poll)
|
||||||
|
*/
|
||||||
|
@SerialName(correctOptionIdField)
|
||||||
|
val correctOptionId: Int? = null,
|
||||||
|
@SerialName(isClosedField)
|
||||||
|
override val isClosed: Boolean = false,
|
||||||
|
@SerialName(isAnonymousField)
|
||||||
|
override val isAnonymous: Boolean = false
|
||||||
|
) : Poll()
|
||||||
|
|
||||||
|
@Serializer(Poll::class)
|
||||||
|
internal object PollSerializer : KSerializer<Poll> {
|
||||||
|
private val pollOptionsSerializer = ArrayListSerializer(PollOption.serializer())
|
||||||
|
override fun deserialize(decoder: Decoder): Poll {
|
||||||
|
val asJson = JsonObjectSerializer.deserialize(decoder)
|
||||||
|
|
||||||
|
return when (asJson.getPrimitive(typeField).content) {
|
||||||
|
regularPollType -> Json.nonstrict.fromJson(
|
||||||
|
RegularPoll.serializer(),
|
||||||
|
asJson
|
||||||
|
)
|
||||||
|
quizPollType -> Json.nonstrict.fromJson(
|
||||||
|
QuizPoll.serializer(),
|
||||||
|
asJson
|
||||||
|
)
|
||||||
|
else -> UnknownPollType(
|
||||||
|
asJson.getPrimitive(idField).content,
|
||||||
|
asJson.getPrimitive(questionField).content,
|
||||||
|
Json.nonstrict.fromJson(
|
||||||
|
pollOptionsSerializer,
|
||||||
|
asJson.getArray(optionsField)
|
||||||
|
),
|
||||||
|
asJson.getPrimitive(totalVoterCountField).int,
|
||||||
|
asJson.getPrimitiveOrNull(isClosedField) ?.booleanOrNull ?: false,
|
||||||
|
asJson.getPrimitiveOrNull(isAnonymousField) ?.booleanOrNull ?: true,
|
||||||
|
asJson.toString()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun serialize(encoder: Encoder, obj: Poll) {
|
||||||
|
val asJson = when (obj) {
|
||||||
|
is RegularPoll -> Json.nonstrict.toJson(RegularPoll.serializer(), obj)
|
||||||
|
is QuizPoll -> Json.nonstrict.toJson(QuizPoll.serializer(), obj)
|
||||||
|
is UnknownPollType -> throw IllegalArgumentException("Currently unable to correctly serialize object of poll $obj")
|
||||||
|
}
|
||||||
|
val resultJson = JsonObject(
|
||||||
|
asJson.jsonObject + (typeField to when (obj) {
|
||||||
|
is RegularPoll -> JsonPrimitive(regularPollType)
|
||||||
|
is QuizPoll -> JsonPrimitive(quizPollType)
|
||||||
|
is UnknownPollType -> throw IllegalArgumentException("Currently unable to correctly serialize object of poll $obj")
|
||||||
|
})
|
||||||
|
)
|
||||||
|
JsonObjectSerializer.serialize(encoder, resultJson)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.types.polls
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class PollAnswer(
|
||||||
|
@SerialName(pollIdField)
|
||||||
|
val pollId: PollIdentifier,
|
||||||
|
@SerialName(userField)
|
||||||
|
val user: User,
|
||||||
|
@SerialName(optionIdsField)
|
||||||
|
val chosen: List<Int>
|
||||||
|
)
|
||||||
@@ -12,7 +12,7 @@ sealed class PollOption {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class AnonymousPollOption (
|
data class SimplePollOption (
|
||||||
@SerialName(textField)
|
@SerialName(textField)
|
||||||
override val text: String,
|
override val text: String,
|
||||||
@SerialName(votesCountField)
|
@SerialName(votesCountField)
|
||||||
@@ -22,13 +22,13 @@ data class AnonymousPollOption (
|
|||||||
internal object PollOptionSerializer : KSerializer<PollOption> {
|
internal object PollOptionSerializer : KSerializer<PollOption> {
|
||||||
override val descriptor: SerialDescriptor = StringDescriptor.withName(PollOption::class.simpleName ?: "PollOption")
|
override val descriptor: SerialDescriptor = StringDescriptor.withName(PollOption::class.simpleName ?: "PollOption")
|
||||||
|
|
||||||
override fun deserialize(decoder: Decoder): PollOption = AnonymousPollOption.serializer().deserialize(
|
override fun deserialize(decoder: Decoder): PollOption = SimplePollOption.serializer().deserialize(
|
||||||
decoder
|
decoder
|
||||||
)
|
)
|
||||||
|
|
||||||
override fun serialize(encoder: Encoder, obj: PollOption) {
|
override fun serialize(encoder: Encoder, obj: PollOption) {
|
||||||
when (obj) {
|
when (obj) {
|
||||||
is AnonymousPollOption -> AnonymousPollOption.serializer().serialize(
|
is SimplePollOption -> SimplePollOption.serializer().serialize(
|
||||||
encoder,
|
encoder,
|
||||||
obj
|
obj
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.types.update
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.polls.PollAnswer
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update
|
||||||
|
|
||||||
|
data class PollAnswerUpdate(
|
||||||
|
override val updateId: UpdateIdentifier,
|
||||||
|
override val data: PollAnswer
|
||||||
|
) : Update
|
||||||
@@ -9,6 +9,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Telegr
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.PreCheckoutQuery
|
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.PreCheckoutQuery
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.ShippingQuery
|
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.ShippingQuery
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.polls.Poll
|
import com.github.insanusmokrassar.TelegramBotAPI.types.polls.Poll
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.polls.PollAnswer
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.UnknownUpdateType
|
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.UnknownUpdateType
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update
|
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.updateIdField
|
import com.github.insanusmokrassar.TelegramBotAPI.types.updateIdField
|
||||||
@@ -33,7 +34,8 @@ internal data class RawUpdate constructor(
|
|||||||
private val callback_query: RawCallbackQuery? = null,
|
private val callback_query: RawCallbackQuery? = null,
|
||||||
private val shipping_query: ShippingQuery? = null,
|
private val shipping_query: ShippingQuery? = null,
|
||||||
private val pre_checkout_query: PreCheckoutQuery? = null,
|
private val pre_checkout_query: PreCheckoutQuery? = null,
|
||||||
private val poll: Poll? = null
|
private val poll: Poll? = null,
|
||||||
|
private val poll_answer: PollAnswer? = null
|
||||||
) {
|
) {
|
||||||
private var initedUpdate: Update? = null
|
private var initedUpdate: Update? = null
|
||||||
/**
|
/**
|
||||||
@@ -55,6 +57,7 @@ internal data class RawUpdate constructor(
|
|||||||
shipping_query != null -> ShippingQueryUpdate(updateId, shipping_query)
|
shipping_query != null -> ShippingQueryUpdate(updateId, shipping_query)
|
||||||
pre_checkout_query != null -> PreCheckoutQueryUpdate(updateId, pre_checkout_query)
|
pre_checkout_query != null -> PreCheckoutQueryUpdate(updateId, pre_checkout_query)
|
||||||
poll != null -> PollUpdate(updateId, poll)
|
poll != null -> PollUpdate(updateId, poll)
|
||||||
|
poll_answer != null -> PollAnswerUpdate(updateId, poll_answer)
|
||||||
else -> UnknownUpdateType(
|
else -> UnknownUpdateType(
|
||||||
updateId,
|
updateId,
|
||||||
raw.toString()
|
raw.toString()
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ data class UpdatesFilter(
|
|||||||
private val shippingQueryCallback: UpdateReceiver<ShippingQueryUpdate>? = null,
|
private val shippingQueryCallback: UpdateReceiver<ShippingQueryUpdate>? = null,
|
||||||
private val preCheckoutQueryCallback: UpdateReceiver<PreCheckoutQueryUpdate>? = null,
|
private val preCheckoutQueryCallback: UpdateReceiver<PreCheckoutQueryUpdate>? = null,
|
||||||
private val pollUpdateCallback: UpdateReceiver<PollUpdate>? = null,
|
private val pollUpdateCallback: UpdateReceiver<PollUpdate>? = null,
|
||||||
|
private val pollAnswerUpdateCallback: UpdateReceiver<PollAnswerUpdate>? = null,
|
||||||
private val unknownUpdateTypeCallback: UpdateReceiver<UnknownUpdateType>? = null
|
private val unknownUpdateTypeCallback: UpdateReceiver<UnknownUpdateType>? = null
|
||||||
) {
|
) {
|
||||||
val asUpdateReceiver: UpdateReceiver<Update> = this::invoke
|
val asUpdateReceiver: UpdateReceiver<Update> = this::invoke
|
||||||
@@ -35,7 +36,8 @@ data class UpdatesFilter(
|
|||||||
callbackQueryCallback ?.let { UPDATE_CALLBACK_QUERY },
|
callbackQueryCallback ?.let { UPDATE_CALLBACK_QUERY },
|
||||||
shippingQueryCallback ?.let { UPDATE_SHIPPING_QUERY },
|
shippingQueryCallback ?.let { UPDATE_SHIPPING_QUERY },
|
||||||
preCheckoutQueryCallback ?.let { UPDATE_PRE_CHECKOUT_QUERY },
|
preCheckoutQueryCallback ?.let { UPDATE_PRE_CHECKOUT_QUERY },
|
||||||
pollUpdateCallback ?.let { UPDATE_POLL }
|
pollUpdateCallback ?.let { UPDATE_POLL },
|
||||||
|
pollAnswerUpdateCallback ?.let { UPDATE_POLL_ANSWER }
|
||||||
)
|
)
|
||||||
|
|
||||||
suspend fun invoke(update: Update) {
|
suspend fun invoke(update: Update) {
|
||||||
@@ -74,6 +76,7 @@ data class UpdatesFilter(
|
|||||||
is ShippingQueryUpdate -> shippingQueryCallback ?.invoke(update)
|
is ShippingQueryUpdate -> shippingQueryCallback ?.invoke(update)
|
||||||
is PreCheckoutQueryUpdate -> preCheckoutQueryCallback ?.invoke(update)
|
is PreCheckoutQueryUpdate -> preCheckoutQueryCallback ?.invoke(update)
|
||||||
is PollUpdate -> pollUpdateCallback ?.invoke(update)
|
is PollUpdate -> pollUpdateCallback ?.invoke(update)
|
||||||
|
is PollAnswerUpdate -> pollAnswerUpdateCallback ?.invoke(update)
|
||||||
is UnknownUpdateType -> unknownUpdateTypeCallback ?.invoke(update)
|
is UnknownUpdateType -> unknownUpdateTypeCallback ?.invoke(update)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -91,6 +94,7 @@ fun createSimpleUpdateFilter(
|
|||||||
shippingQueryCallback: UpdateReceiver<ShippingQueryUpdate>? = null,
|
shippingQueryCallback: UpdateReceiver<ShippingQueryUpdate>? = null,
|
||||||
preCheckoutQueryCallback: UpdateReceiver<PreCheckoutQueryUpdate>? = null,
|
preCheckoutQueryCallback: UpdateReceiver<PreCheckoutQueryUpdate>? = null,
|
||||||
pollCallback: UpdateReceiver<PollUpdate>? = null,
|
pollCallback: UpdateReceiver<PollUpdate>? = null,
|
||||||
|
pollAnswerCallback: UpdateReceiver<PollAnswerUpdate>? = null,
|
||||||
unknownCallback: UpdateReceiver<UnknownUpdateType>? = null
|
unknownCallback: UpdateReceiver<UnknownUpdateType>? = null
|
||||||
): UpdatesFilter = UpdatesFilter(
|
): UpdatesFilter = UpdatesFilter(
|
||||||
messageCallback = messageCallback,
|
messageCallback = messageCallback,
|
||||||
@@ -107,5 +111,6 @@ fun createSimpleUpdateFilter(
|
|||||||
shippingQueryCallback = shippingQueryCallback,
|
shippingQueryCallback = shippingQueryCallback,
|
||||||
preCheckoutQueryCallback = preCheckoutQueryCallback,
|
preCheckoutQueryCallback = preCheckoutQueryCallback,
|
||||||
pollUpdateCallback = pollCallback,
|
pollUpdateCallback = pollCallback,
|
||||||
|
pollAnswerUpdateCallback = pollAnswerCallback,
|
||||||
unknownUpdateTypeCallback = unknownCallback
|
unknownUpdateTypeCallback = unknownCallback
|
||||||
)
|
)
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user