mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-12-31 10:29:21 +00:00
Compare commits
11 Commits
v2.2.2
...
d8f6429385
| Author | SHA1 | Date | |
|---|---|---|---|
| d8f6429385 | |||
| be74249b67 | |||
| 69f658e4a8 | |||
| 8c51ca9d72 | |||
| 48c4a3156b | |||
| 92407c9010 | |||
| 86937cc096 | |||
| ea614b790b | |||
| c994332cb9 | |||
| 9d893ffa48 | |||
| 57d2fe85c5 |
@@ -1,7 +1,13 @@
|
|||||||
# TelegramBotAPI changelog
|
# TelegramBotAPI changelog
|
||||||
|
|
||||||
|
## 3.0.0
|
||||||
|
|
||||||
## 2.2.2
|
## 2.2.2
|
||||||
|
|
||||||
|
* `Core`:
|
||||||
|
* Interface `ReplyMakrup` has been renamed to `WithReplyMarkup` to correspond its purpose
|
||||||
|
* `API`:
|
||||||
|
* New API (`handleLiveLocation`) for live location streaming using `Flow`
|
||||||
* `Utils`:
|
* `Utils`:
|
||||||
* `buildEntities` now is inline
|
* `buildEntities` now is inline
|
||||||
* `Behaviour Builder`:
|
* `Behaviour Builder`:
|
||||||
|
|||||||
16
README.md
16
README.md
@@ -1,9 +1,17 @@
|
|||||||
# TelegramBotAPI [](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) [](https://core.telegram.org/bots/api-changelog#june-20-2022)
|
# TelegramBotAPI [](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) [](https://core.telegram.org/bots/api-changelog#june-20-2022)
|
||||||
|
|
||||||
| [](https://github.com/KotlinBy/awesome-kotlin) [](https://github.com/InsanusMokrassar/TelegramBotAPI/actions) [](https://docs.google.com/forms/d/e/1FAIpQLSctdJHT_aEniyYT0-IUAEfo1hsIlezX2owlkEAYX4KPl2V2_A/viewform?usp=sf_link) [](https://t.me/InMoTelegramBotAPI) |
|
| Docs | [](https://tgbotapi.inmo.dev/index.html) [](https://bookstack.inmo.dev/books/telegrambotapi/chapter/introduction-tutorial) |
|
||||||
|:---:|
|
|:---:|:---:|
|
||||||
| [](https://github.com/InsanusMokrassar/TelegramBotAPI-bot_template/generate) [](https://github.com/InsanusMokrassar/TelegramBotAPI-examples/) [](https://tgbotapi.inmo.dev/index.html) [](https://bookstack.inmo.dev/books/telegrambotapi/chapter/introduction-tutorial) |
|
| Useful repos | [](https://github.com/InsanusMokrassar/TelegramBotAPI-bot_template/generate) [](https://github.com/InsanusMokrassar/TelegramBotAPI-examples/) |
|
||||||
| [](https://t.me/InMoTelegramBotAPI) |
|
| Misc | [](https://github.com/KotlinBy/awesome-kotlin) [](https://docs.google.com/forms/d/e/1FAIpQLSctdJHT_aEniyYT0-IUAEfo1hsIlezX2owlkEAYX4KPl2V2_A/viewform?usp=sf_link) |
|
||||||
|
|
||||||
|
<!--- [](https://t.me/InMoTelegramBotAPI) --->
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://t.me/InMoTelegramBotAPI">
|
||||||
|
<img src="./resources/tg_channel_qr.jpg">
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
Hello! This is a set of libraries for working with Telegram Bot API.
|
Hello! This is a set of libraries for working with Telegram Bot API.
|
||||||
|
|
||||||
|
|||||||
@@ -6,4 +6,4 @@ kotlin.incremental=true
|
|||||||
kotlin.incremental.js=true
|
kotlin.incremental.js=true
|
||||||
|
|
||||||
library_group=dev.inmo
|
library_group=dev.inmo
|
||||||
library_version=2.2.2
|
library_version=3.0.0
|
||||||
|
|||||||
@@ -1,17 +1,16 @@
|
|||||||
[versions]
|
[versions]
|
||||||
|
|
||||||
kotlin = "1.6.21"
|
kotlin = "1.7.10"
|
||||||
kotlin-serialization = "1.3.3"
|
kotlin-serialization = "1.4.0-RC"
|
||||||
kotlin-coroutines = "1.6.4"
|
kotlin-coroutines = "1.6.4"
|
||||||
kotlin-gradle-plugin = "7.0.4"
|
|
||||||
|
|
||||||
javax-activation = "1.1.1"
|
javax-activation = "1.1.1"
|
||||||
|
|
||||||
korlibs = "2.7.0"
|
korlibs = "3.0.0"
|
||||||
uuid = "0.4.1"
|
uuid = "0.5.0"
|
||||||
ktor = "2.0.3"
|
ktor = "2.0.3"
|
||||||
|
|
||||||
microutils = "0.11.13"
|
microutils = "0.12.0"
|
||||||
|
|
||||||
github-release-plugin = "2.4.1"
|
github-release-plugin = "2.4.1"
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,151 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.api
|
||||||
|
|
||||||
|
import dev.inmo.micro_utils.coroutines.LinkedSupervisorJob
|
||||||
|
import dev.inmo.micro_utils.coroutines.launchSafelyWithoutExceptions
|
||||||
|
import dev.inmo.tgbotapi.abstracts.*
|
||||||
|
import dev.inmo.tgbotapi.abstracts.types.WithReplyMarkup
|
||||||
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
|
import dev.inmo.tgbotapi.extensions.api.edit.location.live.editLiveLocation
|
||||||
|
import dev.inmo.tgbotapi.extensions.api.send.sendLiveLocation
|
||||||
|
import dev.inmo.tgbotapi.types.*
|
||||||
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||||
|
import dev.inmo.tgbotapi.types.location.LiveLocation
|
||||||
|
import dev.inmo.tgbotapi.types.location.Location
|
||||||
|
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||||
|
import dev.inmo.tgbotapi.types.message.content.LocationContent
|
||||||
|
import kotlinx.coroutines.*
|
||||||
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
import kotlinx.coroutines.flow.map
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
import kotlin.js.JsName
|
||||||
|
import kotlin.jvm.JvmName
|
||||||
|
import kotlin.math.ceil
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class EditLiveLocationInfo(
|
||||||
|
override val latitude: Double,
|
||||||
|
override val longitude: Double,
|
||||||
|
override val horizontalAccuracy: Meters? = null,
|
||||||
|
override val heading: Degrees? = null,
|
||||||
|
override val proximityAlertRadius: Meters? = null,
|
||||||
|
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) : Locationed, HorizontallyAccured, ProximityAlertable, Headed, WithReplyMarkup
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Will [sendLiveLocation] with the first [EditLiveLocationInfo] data and update than. Each [liveTimeMillis] passing,
|
||||||
|
* the message will be sent again and new edits will be applied to the new message
|
||||||
|
*/
|
||||||
|
suspend fun TelegramBot.handleLiveLocation(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
locationsFlow: Flow<EditLiveLocationInfo>,
|
||||||
|
liveTimeMillis: Long = defaultLivePeriodDelayMillis,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
protectContent: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
allowSendingWithoutReply: Boolean? = null
|
||||||
|
) {
|
||||||
|
var currentLiveLocationMessage: ContentMessage<LocationContent>? = null
|
||||||
|
val updateMessageJob = CoroutineScope(currentCoroutineContext().LinkedSupervisorJob()).launchSafelyWithoutExceptions(start = CoroutineStart.LAZY) {
|
||||||
|
while (isActive) {
|
||||||
|
delay(liveTimeMillis)
|
||||||
|
// Remove previous location message info to resend live location message
|
||||||
|
currentLiveLocationMessage = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
locationsFlow.collect {
|
||||||
|
val capturedLiveLocationMessage = currentLiveLocationMessage
|
||||||
|
if (capturedLiveLocationMessage == null) {
|
||||||
|
updateMessageJob.start()
|
||||||
|
currentLiveLocationMessage = sendLiveLocation(
|
||||||
|
chatId,
|
||||||
|
it.latitude,
|
||||||
|
it.longitude,
|
||||||
|
ceil(liveTimeMillis.toDouble() / 1000).toInt(),
|
||||||
|
it.horizontalAccuracy,
|
||||||
|
it.heading,
|
||||||
|
it.proximityAlertRadius,
|
||||||
|
disableNotification,
|
||||||
|
protectContent,
|
||||||
|
replyToMessageId,
|
||||||
|
allowSendingWithoutReply,
|
||||||
|
it.replyMarkup
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
editLiveLocation(
|
||||||
|
capturedLiveLocationMessage,
|
||||||
|
it.latitude,
|
||||||
|
it.longitude,
|
||||||
|
it.horizontalAccuracy,
|
||||||
|
it.heading,
|
||||||
|
it.proximityAlertRadius,
|
||||||
|
it.replyMarkup
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Will apply [Flow.map] to the [locationsFlow] to create [EditLiveLocationInfo] and pass the result flow to the
|
||||||
|
* [handleLiveLocation] with [Flow] typed by [EditLiveLocationInfo]
|
||||||
|
*/
|
||||||
|
@JvmName("handleLiveLocationWithLocation")
|
||||||
|
@JsName("handleLiveLocationWithLocation")
|
||||||
|
suspend fun TelegramBot.handleLiveLocation(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
locationsFlow: Flow<Location>,
|
||||||
|
liveTimeMillis: Long = defaultLivePeriodDelayMillis,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
protectContent: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
allowSendingWithoutReply: Boolean? = null
|
||||||
|
) {
|
||||||
|
handleLiveLocation(
|
||||||
|
chatId,
|
||||||
|
locationsFlow.map {
|
||||||
|
EditLiveLocationInfo(
|
||||||
|
it.latitude,
|
||||||
|
it.longitude,
|
||||||
|
it.horizontalAccuracy,
|
||||||
|
(it as? LiveLocation) ?.heading,
|
||||||
|
(it as? LiveLocation) ?.proximityAlertRadius,
|
||||||
|
(it as? WithReplyMarkup) ?.replyMarkup as? InlineKeyboardMarkup
|
||||||
|
)
|
||||||
|
},
|
||||||
|
liveTimeMillis,
|
||||||
|
disableNotification,
|
||||||
|
protectContent,
|
||||||
|
replyToMessageId,
|
||||||
|
allowSendingWithoutReply
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Will apply [Flow.map] to the [locationsFlow] to create [EditLiveLocationInfo] and pass the result flow to the
|
||||||
|
* [handleLiveLocation] with [Flow] typed by [EditLiveLocationInfo]
|
||||||
|
*/
|
||||||
|
@JvmName("handleLiveLocationWithLatLong")
|
||||||
|
@JsName("handleLiveLocationWithLatLong")
|
||||||
|
suspend fun TelegramBot.handleLiveLocation(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
locationsFlow: Flow<Pair<Double, Double>>,
|
||||||
|
liveTimeMillis: Long = defaultLivePeriodDelayMillis,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
protectContent: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
allowSendingWithoutReply: Boolean? = null
|
||||||
|
) {
|
||||||
|
handleLiveLocation(
|
||||||
|
chatId,
|
||||||
|
locationsFlow.map { (lat, long) ->
|
||||||
|
EditLiveLocationInfo(
|
||||||
|
lat,
|
||||||
|
long
|
||||||
|
)
|
||||||
|
},
|
||||||
|
liveTimeMillis,
|
||||||
|
disableNotification,
|
||||||
|
protectContent,
|
||||||
|
replyToMessageId,
|
||||||
|
allowSendingWithoutReply
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -229,3 +229,224 @@ suspend inline fun TelegramBot.copyMessage(
|
|||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = copyMessage(message.chat, message.messageId, toChat, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
) = copyMessage(message.chat, message.messageId, toChat, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||||
|
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||||
|
*/
|
||||||
|
suspend inline fun TelegramBot.copyMessage(
|
||||||
|
toChatId: ChatIdentifier,
|
||||||
|
fromChatId: ChatIdentifier,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
protectContent: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
CopyMessage(
|
||||||
|
fromChatId,
|
||||||
|
messageId,
|
||||||
|
toChatId,
|
||||||
|
text,
|
||||||
|
parseMode,
|
||||||
|
disableNotification,
|
||||||
|
protectContent,
|
||||||
|
replyToMessageId,
|
||||||
|
allowSendingWithoutReply,
|
||||||
|
replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||||
|
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||||
|
*/
|
||||||
|
suspend inline fun TelegramBot.copyMessage(
|
||||||
|
toChatId: ChatIdentifier,
|
||||||
|
fromChat: Chat,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
protectContent: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = copyMessage(
|
||||||
|
toChatId,
|
||||||
|
fromChat.id,
|
||||||
|
messageId,
|
||||||
|
text,
|
||||||
|
parseMode,
|
||||||
|
disableNotification,
|
||||||
|
protectContent,
|
||||||
|
replyToMessageId,
|
||||||
|
allowSendingWithoutReply,
|
||||||
|
replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||||
|
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||||
|
*/
|
||||||
|
suspend inline fun TelegramBot.copyMessage(
|
||||||
|
toChat: Chat,
|
||||||
|
fromChatId: ChatIdentifier,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
protectContent: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = copyMessage(
|
||||||
|
toChat.id,
|
||||||
|
fromChatId,
|
||||||
|
messageId,
|
||||||
|
text,
|
||||||
|
parseMode,
|
||||||
|
disableNotification,
|
||||||
|
protectContent,
|
||||||
|
replyToMessageId,
|
||||||
|
allowSendingWithoutReply,
|
||||||
|
replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||||
|
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||||
|
*/
|
||||||
|
suspend inline fun TelegramBot.copyMessage(
|
||||||
|
toChat: Chat,
|
||||||
|
fromChat: Chat,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
protectContent: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = copyMessage(
|
||||||
|
toChat.id,
|
||||||
|
fromChat.id,
|
||||||
|
messageId,
|
||||||
|
text,
|
||||||
|
parseMode,
|
||||||
|
disableNotification,
|
||||||
|
protectContent,
|
||||||
|
replyToMessageId,
|
||||||
|
allowSendingWithoutReply,
|
||||||
|
replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||||
|
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||||
|
*/
|
||||||
|
suspend inline fun TelegramBot.copyMessage(
|
||||||
|
toChatId: ChatIdentifier,
|
||||||
|
fromChatId: ChatIdentifier,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
entities: TextSourcesList,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
protectContent: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
CopyMessage(
|
||||||
|
fromChatId,
|
||||||
|
messageId,
|
||||||
|
toChatId,
|
||||||
|
entities,
|
||||||
|
disableNotification,
|
||||||
|
protectContent,
|
||||||
|
replyToMessageId,
|
||||||
|
allowSendingWithoutReply,
|
||||||
|
replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||||
|
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||||
|
*/
|
||||||
|
suspend inline fun TelegramBot.copyMessage(
|
||||||
|
toChatId: ChatIdentifier,
|
||||||
|
fromChat: Chat,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
entities: TextSourcesList,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
protectContent: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = copyMessage(
|
||||||
|
toChatId,
|
||||||
|
fromChat.id,
|
||||||
|
messageId,
|
||||||
|
entities,
|
||||||
|
disableNotification,
|
||||||
|
protectContent,
|
||||||
|
replyToMessageId,
|
||||||
|
allowSendingWithoutReply,
|
||||||
|
replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||||
|
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||||
|
*/
|
||||||
|
suspend inline fun TelegramBot.copyMessage(
|
||||||
|
toChat: Chat,
|
||||||
|
fromChatId: ChatIdentifier,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
entities: TextSourcesList,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
protectContent: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = copyMessage(
|
||||||
|
toChat.id,
|
||||||
|
fromChatId,
|
||||||
|
messageId,
|
||||||
|
entities,
|
||||||
|
disableNotification,
|
||||||
|
protectContent,
|
||||||
|
replyToMessageId,
|
||||||
|
allowSendingWithoutReply,
|
||||||
|
replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||||
|
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||||
|
*/
|
||||||
|
suspend inline fun TelegramBot.copyMessage(
|
||||||
|
toChat: Chat,
|
||||||
|
fromChat: Chat,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
entities: TextSourcesList,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
protectContent: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = copyMessage(
|
||||||
|
toChat.id,
|
||||||
|
fromChat.id,
|
||||||
|
messageId,
|
||||||
|
entities,
|
||||||
|
disableNotification,
|
||||||
|
protectContent,
|
||||||
|
replyToMessageId,
|
||||||
|
allowSendingWithoutReply,
|
||||||
|
replyMarkup
|
||||||
|
)
|
||||||
|
|||||||
@@ -1,180 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.send
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.send.CopyMessage
|
|
||||||
import dev.inmo.tgbotapi.requests.send.OrderChangingDeprecationWarn
|
|
||||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
|
||||||
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
|
||||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
|
||||||
import dev.inmo.tgbotapi.types.message.ParseMode
|
|
||||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
|
||||||
import dev.inmo.tgbotapi.types.chat.Chat
|
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
|
||||||
|
|
||||||
// TODO:: Swap fromChatId and toChatId for more correct order of parameters
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
|
||||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
|
||||||
*/
|
|
||||||
@Deprecated(OrderChangingDeprecationWarn)
|
|
||||||
suspend inline fun TelegramBot.copyMessage(
|
|
||||||
fromChatId: ChatIdentifier,
|
|
||||||
toChatId: ChatIdentifier,
|
|
||||||
messageId: MessageIdentifier,
|
|
||||||
text: String? = null,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = execute(
|
|
||||||
CopyMessage(
|
|
||||||
fromChatId,
|
|
||||||
messageId,
|
|
||||||
toChatId,
|
|
||||||
text,
|
|
||||||
parseMode,
|
|
||||||
disableNotification,
|
|
||||||
protectContent,
|
|
||||||
replyToMessageId,
|
|
||||||
allowSendingWithoutReply,
|
|
||||||
replyMarkup
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
|
||||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
|
||||||
*/
|
|
||||||
@Deprecated(OrderChangingDeprecationWarn)
|
|
||||||
suspend inline fun TelegramBot.copyMessage(
|
|
||||||
fromChat: Chat,
|
|
||||||
toChatId: ChatIdentifier,
|
|
||||||
messageId: MessageIdentifier,
|
|
||||||
text: String? = null,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = copyMessage(fromChat.id, toChatId, messageId, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
|
||||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
|
||||||
*/
|
|
||||||
@Deprecated(OrderChangingDeprecationWarn)
|
|
||||||
suspend inline fun TelegramBot.copyMessage(
|
|
||||||
fromChatId: ChatIdentifier,
|
|
||||||
toChat: Chat,
|
|
||||||
messageId: MessageIdentifier,
|
|
||||||
text: String? = null,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = copyMessage(fromChatId, toChat.id, messageId, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
|
||||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
|
||||||
*/
|
|
||||||
@Deprecated(OrderChangingDeprecationWarn)
|
|
||||||
suspend inline fun TelegramBot.copyMessage(
|
|
||||||
fromChat: Chat,
|
|
||||||
toChat: Chat,
|
|
||||||
messageId: MessageIdentifier,
|
|
||||||
text: String? = null,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = copyMessage(fromChat.id, toChat.id, messageId, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
|
||||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
|
||||||
*/
|
|
||||||
@Deprecated(OrderChangingDeprecationWarn)
|
|
||||||
suspend inline fun TelegramBot.copyMessage(
|
|
||||||
fromChatId: ChatIdentifier,
|
|
||||||
toChatId: ChatIdentifier,
|
|
||||||
messageId: MessageIdentifier,
|
|
||||||
entities: TextSourcesList,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = execute(
|
|
||||||
CopyMessage(
|
|
||||||
fromChatId,
|
|
||||||
messageId,
|
|
||||||
toChatId,
|
|
||||||
entities,
|
|
||||||
disableNotification,
|
|
||||||
protectContent,
|
|
||||||
replyToMessageId,
|
|
||||||
allowSendingWithoutReply,
|
|
||||||
replyMarkup
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
|
||||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
|
||||||
*/
|
|
||||||
@Deprecated(OrderChangingDeprecationWarn)
|
|
||||||
suspend inline fun TelegramBot.copyMessage(
|
|
||||||
fromChat: Chat,
|
|
||||||
toChatId: ChatIdentifier,
|
|
||||||
messageId: MessageIdentifier,
|
|
||||||
entities: TextSourcesList,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = copyMessage(fromChat.id, toChatId, messageId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
|
||||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
|
||||||
*/
|
|
||||||
@Deprecated(OrderChangingDeprecationWarn)
|
|
||||||
suspend inline fun TelegramBot.copyMessage(
|
|
||||||
fromChatId: ChatIdentifier,
|
|
||||||
toChat: Chat,
|
|
||||||
messageId: MessageIdentifier,
|
|
||||||
entities: TextSourcesList,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = copyMessage(fromChatId, toChat.id, messageId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
|
||||||
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
|
||||||
*/
|
|
||||||
@Deprecated(OrderChangingDeprecationWarn)
|
|
||||||
suspend inline fun TelegramBot.copyMessage(
|
|
||||||
fromChat: Chat,
|
|
||||||
toChat: Chat,
|
|
||||||
messageId: MessageIdentifier,
|
|
||||||
entities: TextSourcesList,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = copyMessage(fromChat.id, toChat.id, messageId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.send
|
package dev.inmo.tgbotapi.extensions.api.send
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.abstracts.types.WithReplyMarkup
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
|
import dev.inmo.tgbotapi.extensions.api.*
|
||||||
import dev.inmo.tgbotapi.extensions.api.send.games.sendGame
|
import dev.inmo.tgbotapi.extensions.api.send.games.sendGame
|
||||||
import dev.inmo.tgbotapi.extensions.api.send.media.*
|
import dev.inmo.tgbotapi.extensions.api.send.media.*
|
||||||
import dev.inmo.tgbotapi.extensions.api.send.payments.sendInvoice
|
import dev.inmo.tgbotapi.extensions.api.send.payments.sendInvoice
|
||||||
@@ -29,6 +31,10 @@ import dev.inmo.tgbotapi.types.payments.abstracts.Currency
|
|||||||
import dev.inmo.tgbotapi.types.polls.*
|
import dev.inmo.tgbotapi.types.polls.*
|
||||||
import dev.inmo.tgbotapi.types.venue.Venue
|
import dev.inmo.tgbotapi.types.venue.Venue
|
||||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||||
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
import kotlinx.coroutines.flow.map
|
||||||
|
import kotlin.js.JsName
|
||||||
|
import kotlin.jvm.JvmName
|
||||||
|
|
||||||
|
|
||||||
// Contact
|
// Contact
|
||||||
@@ -950,7 +956,18 @@ suspend inline fun TelegramBot.reply(
|
|||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = copyMessage(fromChatId, to.chat.id, messageId, text, parseMode, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
|
) = copyMessage(
|
||||||
|
to.chat.id,
|
||||||
|
fromChatId,
|
||||||
|
messageId,
|
||||||
|
text,
|
||||||
|
parseMode,
|
||||||
|
disableNotification,
|
||||||
|
protectContent,
|
||||||
|
to.messageId,
|
||||||
|
allowSendingWithoutReply,
|
||||||
|
replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
suspend inline fun TelegramBot.reply(
|
suspend inline fun TelegramBot.reply(
|
||||||
to: Message,
|
to: Message,
|
||||||
@@ -995,6 +1012,80 @@ suspend fun TelegramBot.reply(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Will use [handleLiveLocation] with replying to [message] each time new message will be sent by live location update
|
||||||
|
*
|
||||||
|
* @see handleLiveLocation
|
||||||
|
*/
|
||||||
|
suspend fun TelegramBot.reply(
|
||||||
|
message: Message,
|
||||||
|
locationsFlow: Flow<EditLiveLocationInfo>,
|
||||||
|
liveTimeMillis: Long = defaultLivePeriodDelayMillis,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
protectContent: Boolean = false,
|
||||||
|
allowSendingWithoutReply: Boolean? = null
|
||||||
|
) = handleLiveLocation(
|
||||||
|
message.chat.id,
|
||||||
|
locationsFlow,
|
||||||
|
liveTimeMillis,
|
||||||
|
disableNotification,
|
||||||
|
protectContent,
|
||||||
|
message.messageId,
|
||||||
|
allowSendingWithoutReply
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Will use [handleLiveLocation] with replying to [message] each time new message will be sent by live location update
|
||||||
|
*
|
||||||
|
* @see handleLiveLocation
|
||||||
|
*/
|
||||||
|
@JvmName("replyLiveLocationWithLocation")
|
||||||
|
@JsName("replyLiveLocationWithLocation")
|
||||||
|
suspend fun TelegramBot.reply(
|
||||||
|
message: Message,
|
||||||
|
locationsFlow: Flow<Location>,
|
||||||
|
liveTimeMillis: Long = defaultLivePeriodDelayMillis,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
protectContent: Boolean = false,
|
||||||
|
allowSendingWithoutReply: Boolean? = null
|
||||||
|
) {
|
||||||
|
handleLiveLocation(
|
||||||
|
message.chat.id,
|
||||||
|
locationsFlow,
|
||||||
|
liveTimeMillis,
|
||||||
|
disableNotification,
|
||||||
|
protectContent,
|
||||||
|
message.messageId,
|
||||||
|
allowSendingWithoutReply
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Will use [handleLiveLocation] with replying to [message] each time new message will be sent by live location update
|
||||||
|
*
|
||||||
|
* @see handleLiveLocation
|
||||||
|
*/
|
||||||
|
@JvmName("replyLiveLocationWithLatLong")
|
||||||
|
@JsName("replyLiveLocationWithLatLong")
|
||||||
|
suspend fun TelegramBot.reply(
|
||||||
|
message: Message,
|
||||||
|
locationsFlow: Flow<Pair<Double, Double>>,
|
||||||
|
liveTimeMillis: Long = defaultLivePeriodDelayMillis,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
protectContent: Boolean = false,
|
||||||
|
allowSendingWithoutReply: Boolean? = null
|
||||||
|
) {
|
||||||
|
handleLiveLocation(
|
||||||
|
message.chat.id,
|
||||||
|
locationsFlow,
|
||||||
|
liveTimeMillis,
|
||||||
|
disableNotification,
|
||||||
|
protectContent,
|
||||||
|
message.messageId,
|
||||||
|
allowSendingWithoutReply
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
suspend fun TelegramBot.reply(
|
suspend fun TelegramBot.reply(
|
||||||
to: Message,
|
to: Message,
|
||||||
mediaFile: TelegramMediaFile,
|
mediaFile: TelegramMediaFile,
|
||||||
|
|||||||
@@ -0,0 +1,212 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.api.send
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
|
import dev.inmo.tgbotapi.requests.send.SendLiveLocation
|
||||||
|
import dev.inmo.tgbotapi.requests.send.SendStaticLocation
|
||||||
|
import dev.inmo.tgbotapi.types.*
|
||||||
|
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||||
|
import dev.inmo.tgbotapi.types.chat.Chat
|
||||||
|
import dev.inmo.tgbotapi.types.location.Location
|
||||||
|
import dev.inmo.tgbotapi.types.location.StaticLocation
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||||
|
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||||
|
*/
|
||||||
|
suspend fun TelegramBot.sendLocation(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
latitude: Double,
|
||||||
|
longitude: Double,
|
||||||
|
livePeriod: Seconds,
|
||||||
|
horizontalAccuracy: Meters? = null,
|
||||||
|
heading: Degrees? = null,
|
||||||
|
proximityAlertRadius: Meters? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
protectContent: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
SendLiveLocation(
|
||||||
|
chatId,
|
||||||
|
latitude,
|
||||||
|
longitude,
|
||||||
|
livePeriod,
|
||||||
|
horizontalAccuracy,
|
||||||
|
heading,
|
||||||
|
proximityAlertRadius,
|
||||||
|
disableNotification,
|
||||||
|
protectContent,
|
||||||
|
replyToMessageId,
|
||||||
|
allowSendingWithoutReply,
|
||||||
|
replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||||
|
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||||
|
*/
|
||||||
|
suspend fun TelegramBot.sendLocation(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
location: Location,
|
||||||
|
livePeriod: Seconds,
|
||||||
|
horizontalAccuracy: Meters? = null,
|
||||||
|
heading: Degrees? = null,
|
||||||
|
proximityAlertRadius: Meters? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
protectContent: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendLocation(
|
||||||
|
chatId,
|
||||||
|
location.latitude,
|
||||||
|
location.longitude,
|
||||||
|
livePeriod,
|
||||||
|
horizontalAccuracy,
|
||||||
|
heading,
|
||||||
|
proximityAlertRadius,
|
||||||
|
disableNotification,
|
||||||
|
protectContent,
|
||||||
|
replyToMessageId,
|
||||||
|
allowSendingWithoutReply,
|
||||||
|
replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||||
|
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||||
|
*/
|
||||||
|
suspend fun TelegramBot.sendLocation(
|
||||||
|
chat: Chat,
|
||||||
|
latitude: Double,
|
||||||
|
longitude: Double,
|
||||||
|
livePeriod: Seconds,
|
||||||
|
horizontalAccuracy: Meters? = null,
|
||||||
|
heading: Degrees? = null,
|
||||||
|
proximityAlertRadius: Meters? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
protectContent: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendLocation(
|
||||||
|
chat.id,
|
||||||
|
latitude,
|
||||||
|
longitude,
|
||||||
|
livePeriod,
|
||||||
|
horizontalAccuracy,
|
||||||
|
heading,
|
||||||
|
proximityAlertRadius,
|
||||||
|
disableNotification,
|
||||||
|
protectContent,
|
||||||
|
replyToMessageId,
|
||||||
|
allowSendingWithoutReply,
|
||||||
|
replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||||
|
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||||
|
*/
|
||||||
|
suspend fun TelegramBot.sendLocation(
|
||||||
|
chat: Chat,
|
||||||
|
location: Location,
|
||||||
|
livePeriod: Seconds,
|
||||||
|
horizontalAccuracy: Meters? = null,
|
||||||
|
heading: Degrees? = null,
|
||||||
|
proximityAlertRadius: Meters? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
protectContent: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendLocation(
|
||||||
|
chat.id,
|
||||||
|
location.latitude,
|
||||||
|
location.longitude,
|
||||||
|
livePeriod,
|
||||||
|
horizontalAccuracy,
|
||||||
|
heading,
|
||||||
|
proximityAlertRadius,
|
||||||
|
disableNotification,
|
||||||
|
protectContent,
|
||||||
|
replyToMessageId,
|
||||||
|
allowSendingWithoutReply,
|
||||||
|
replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||||
|
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||||
|
*/
|
||||||
|
suspend fun TelegramBot.sendLiveLocation(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
latitude: Double,
|
||||||
|
longitude: Double,
|
||||||
|
livePeriod: Seconds,
|
||||||
|
horizontalAccuracy: Meters? = null,
|
||||||
|
heading: Degrees? = null,
|
||||||
|
proximityAlertRadius: Meters? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
protectContent: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendLocation(chatId, latitude, longitude, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||||
|
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||||
|
*/
|
||||||
|
suspend fun TelegramBot.sendLiveLocation(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
location: Location,
|
||||||
|
livePeriod: Seconds,
|
||||||
|
horizontalAccuracy: Meters? = null,
|
||||||
|
heading: Degrees? = null,
|
||||||
|
proximityAlertRadius: Meters? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
protectContent: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendLocation(chatId, location.latitude, location.longitude, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||||
|
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||||
|
*/
|
||||||
|
suspend fun TelegramBot.sendLiveLocation(
|
||||||
|
chat: Chat,
|
||||||
|
latitude: Double,
|
||||||
|
longitude: Double,
|
||||||
|
livePeriod: Seconds,
|
||||||
|
horizontalAccuracy: Meters? = null,
|
||||||
|
heading: Degrees? = null,
|
||||||
|
proximityAlertRadius: Meters? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
protectContent: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendLocation(chat.id, latitude, longitude, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||||
|
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
||||||
|
*/
|
||||||
|
suspend fun TelegramBot.sendLiveLocation(
|
||||||
|
chat: Chat,
|
||||||
|
location: Location,
|
||||||
|
livePeriod: Seconds,
|
||||||
|
horizontalAccuracy: Meters? = null,
|
||||||
|
heading: Degrees? = null,
|
||||||
|
proximityAlertRadius: Meters? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
protectContent: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendLocation(chat.id, location.latitude, location.longitude, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
@@ -6,6 +6,7 @@ import dev.inmo.tgbotapi.types.ChatIdentifier
|
|||||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||||
import dev.inmo.tgbotapi.types.chat.Chat
|
import dev.inmo.tgbotapi.types.chat.Chat
|
||||||
|
import dev.inmo.tgbotapi.types.location.Location
|
||||||
import dev.inmo.tgbotapi.types.location.StaticLocation
|
import dev.inmo.tgbotapi.types.location.StaticLocation
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -40,7 +41,7 @@ suspend fun TelegramBot.sendLocation(
|
|||||||
*/
|
*/
|
||||||
suspend fun TelegramBot.sendLocation(
|
suspend fun TelegramBot.sendLocation(
|
||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
location: StaticLocation,
|
location: Location,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
@@ -87,7 +88,7 @@ suspend fun TelegramBot.sendLocation(
|
|||||||
*/
|
*/
|
||||||
suspend fun TelegramBot.sendLocation(
|
suspend fun TelegramBot.sendLocation(
|
||||||
chat: Chat,
|
chat: Chat,
|
||||||
location: StaticLocation,
|
location: Location,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
@@ -125,7 +126,7 @@ suspend fun TelegramBot.sendStaticLocation(
|
|||||||
*/
|
*/
|
||||||
suspend fun TelegramBot.sendStaticLocation(
|
suspend fun TelegramBot.sendStaticLocation(
|
||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
location: StaticLocation,
|
location: Location,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
@@ -154,7 +155,7 @@ suspend fun TelegramBot.sendStaticLocation(
|
|||||||
*/
|
*/
|
||||||
suspend fun TelegramBot.sendStaticLocation(
|
suspend fun TelegramBot.sendStaticLocation(
|
||||||
chat: Chat,
|
chat: Chat,
|
||||||
location: StaticLocation,
|
location: Location,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
@@ -57,20 +57,6 @@ interface BehaviourContext : FlowsUpdatesFilter, TelegramBot, CoroutineScope {
|
|||||||
upstreamUpdatesFlow: Flow<Update>? = null,
|
upstreamUpdatesFlow: Flow<Update>? = null,
|
||||||
triggersHolder: TriggersHolder = TriggersHolder()
|
triggersHolder: TriggersHolder = TriggersHolder()
|
||||||
): BehaviourContext
|
): BehaviourContext
|
||||||
|
|
||||||
/**
|
|
||||||
* @param updatesFilter unused
|
|
||||||
*/
|
|
||||||
@Deprecated("Do not use this method")
|
|
||||||
fun copy(
|
|
||||||
bot: TelegramBot = this.bot,
|
|
||||||
scope: CoroutineScope = this.scope,
|
|
||||||
broadcastChannelsSize: Int = 100,
|
|
||||||
onBufferOverflow: BufferOverflow = BufferOverflow.SUSPEND,
|
|
||||||
upstreamUpdatesFlow: Flow<Update>? = null,
|
|
||||||
triggersHolder: TriggersHolder = TriggersHolder(),
|
|
||||||
updatesFilter: BehaviourContextAndTypeReceiver<Boolean, Update>? = null
|
|
||||||
): BehaviourContext = copy(bot, scope, broadcastChannelsSize, onBufferOverflow, upstreamUpdatesFlow, triggersHolder)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class DefaultBehaviourContext(
|
class DefaultBehaviourContext(
|
||||||
@@ -79,9 +65,7 @@ class DefaultBehaviourContext(
|
|||||||
broadcastChannelsSize: Int = 100,
|
broadcastChannelsSize: Int = 100,
|
||||||
onBufferOverflow: BufferOverflow = BufferOverflow.SUSPEND,
|
onBufferOverflow: BufferOverflow = BufferOverflow.SUSPEND,
|
||||||
private val upstreamUpdatesFlow: Flow<Update>? = null,
|
private val upstreamUpdatesFlow: Flow<Update>? = null,
|
||||||
override val triggersHolder: TriggersHolder = TriggersHolder(),
|
override val triggersHolder: TriggersHolder = TriggersHolder()
|
||||||
@Deprecated("This parameter is not used anymore")
|
|
||||||
private val updatesFilter: BehaviourContextAndTypeReceiver<Boolean, Update>? = null
|
|
||||||
) : AbstractFlowsUpdatesFilter(), TelegramBot by bot, CoroutineScope by scope, BehaviourContext {
|
) : AbstractFlowsUpdatesFilter(), TelegramBot by bot, CoroutineScope by scope, BehaviourContext {
|
||||||
|
|
||||||
private val additionalUpdatesSharedFlow = MutableSharedFlow<Update>(0, broadcastChannelsSize, onBufferOverflow)
|
private val additionalUpdatesSharedFlow = MutableSharedFlow<Update>(0, broadcastChannelsSize, onBufferOverflow)
|
||||||
@@ -137,19 +121,6 @@ fun <BC : BehaviourContext> BC.createSubContext(
|
|||||||
triggersHolder = triggersHolder
|
triggersHolder = triggersHolder
|
||||||
) as BC
|
) as BC
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates new [BehaviourContext] using its [BehaviourContext.copy] method
|
|
||||||
*
|
|
||||||
* @param updatesFilter This param will not be used anymore
|
|
||||||
*/
|
|
||||||
@Deprecated("It is not recommended to use updates filter anymore")
|
|
||||||
fun <BC : BehaviourContext> BC.createSubContext(
|
|
||||||
scope: CoroutineScope = LinkedSupervisorScope(),
|
|
||||||
triggersHolder: TriggersHolder = this.triggersHolder,
|
|
||||||
updatesUpstreamFlow: Flow<Update> = allUpdatesFlow,
|
|
||||||
updatesFilter: CustomBehaviourContextAndTypeReceiver<BC, Boolean, Update>?,
|
|
||||||
) = createSubContext(scope, triggersHolder, updatesUpstreamFlow)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Launch [behaviourContextReceiver] in context of [this] as [BehaviourContext] and as [kotlin.coroutines.CoroutineContext]
|
* Launch [behaviourContextReceiver] in context of [this] as [BehaviourContext] and as [kotlin.coroutines.CoroutineContext]
|
||||||
*
|
*
|
||||||
@@ -187,27 +158,6 @@ suspend fun <T, BC : BehaviourContext> BC.createSubContextAndDoWithUpdatesFilter
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates new one [BehaviourContext] using [createSubContext] and launches [behaviourContextReceiver] in a new context
|
|
||||||
* using [doInContext]
|
|
||||||
*
|
|
||||||
* @param stopOnCompletion ___TRUE BY DEFAULT___
|
|
||||||
* @param updatesFilter Is not used anymore
|
|
||||||
*/
|
|
||||||
@Deprecated("It is not recommended to use updates filter anymore")
|
|
||||||
suspend fun <T, BC : BehaviourContext> BC.createSubContextAndDoWithUpdatesFilter(
|
|
||||||
scope: CoroutineScope = LinkedSupervisorScope(),
|
|
||||||
triggersHolder: TriggersHolder = this.triggersHolder,
|
|
||||||
updatesUpstreamFlow: Flow<Update> = allUpdatesFlow,
|
|
||||||
updatesFilter: CustomBehaviourContextAndTypeReceiver<BC, Boolean, Update>?,
|
|
||||||
stopOnCompletion: Boolean = true,
|
|
||||||
behaviourContextReceiver: CustomBehaviourContextReceiver<BC, T>
|
|
||||||
): T {
|
|
||||||
return createSubContextAndDoWithUpdatesFilter(
|
|
||||||
scope, triggersHolder, updatesUpstreamFlow, stopOnCompletion, behaviourContextReceiver
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method will cancel ALL subsequent contexts, expectations and waiters
|
* This method will cancel ALL subsequent contexts, expectations and waiters
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.abstracts.types
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
|
||||||
|
|
||||||
interface ReplyMarkup {
|
|
||||||
val replyMarkup: KeyboardMarkup?
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package dev.inmo.tgbotapi.abstracts.types
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||||
|
|
||||||
|
interface WithReplyMarkup {
|
||||||
|
val replyMarkup: KeyboardMarkup?
|
||||||
|
}
|
||||||
|
@Deprecated("Renamed", ReplaceWith("WithReplyMarkup", "dev.inmo.tgbotapi.abstracts.types.WithReplyMarkup"))
|
||||||
|
typealias ReplyMarkup = WithReplyMarkup
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.requests
|
package dev.inmo.tgbotapi.requests
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.abstracts.types.MessageAction
|
import dev.inmo.tgbotapi.abstracts.types.MessageAction
|
||||||
import dev.inmo.tgbotapi.abstracts.types.ReplyMarkup
|
import dev.inmo.tgbotapi.abstracts.types.WithReplyMarkup
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||||
@@ -17,7 +17,7 @@ data class StopPoll(
|
|||||||
override val messageId: MessageIdentifier,
|
override val messageId: MessageIdentifier,
|
||||||
@SerialName(replyMarkupField)
|
@SerialName(replyMarkupField)
|
||||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) : MessageAction, SimpleRequest<Poll>, ReplyMarkup {
|
) : MessageAction, SimpleRequest<Poll>, WithReplyMarkup {
|
||||||
override fun method(): String = "stopPoll"
|
override fun method(): String = "stopPoll"
|
||||||
override val resultDeserializer: DeserializationStrategy<Poll>
|
override val resultDeserializer: DeserializationStrategy<Poll>
|
||||||
get() = PollSerializer
|
get() = PollSerializer
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package dev.inmo.tgbotapi.requests.edit.abstracts
|
package dev.inmo.tgbotapi.requests.edit.abstracts
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.abstracts.types.ReplyMarkup
|
import dev.inmo.tgbotapi.abstracts.types.WithReplyMarkup
|
||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||||
|
|
||||||
interface EditReplyMessage : ReplyMarkup {
|
interface EditReplyMessage : WithReplyMarkup {
|
||||||
override val replyMarkup: InlineKeyboardMarkup?
|
override val replyMarkup: InlineKeyboardMarkup?
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,10 +20,9 @@ import kotlinx.serialization.*
|
|||||||
|
|
||||||
const val OrderChangingDeprecationWarn = "The order of parameters in this factory will be changed soon. To avoid unexpected behaviour, swap message id and target chat id parameters"
|
const val OrderChangingDeprecationWarn = "The order of parameters in this factory will be changed soon. To avoid unexpected behaviour, swap message id and target chat id parameters"
|
||||||
|
|
||||||
@Deprecated(OrderChangingDeprecationWarn)
|
|
||||||
fun CopyMessage(
|
fun CopyMessage(
|
||||||
fromChatId: ChatIdentifier,
|
|
||||||
toChatId: ChatIdentifier,
|
toChatId: ChatIdentifier,
|
||||||
|
fromChatId: ChatIdentifier,
|
||||||
messageId: MessageIdentifier,
|
messageId: MessageIdentifier,
|
||||||
text: String? = null,
|
text: String? = null,
|
||||||
parseMode: ParseMode? = null,
|
parseMode: ParseMode? = null,
|
||||||
@@ -46,10 +45,9 @@ fun CopyMessage(
|
|||||||
replyMarkup
|
replyMarkup
|
||||||
)
|
)
|
||||||
|
|
||||||
@Deprecated(OrderChangingDeprecationWarn)
|
|
||||||
fun CopyMessage(
|
fun CopyMessage(
|
||||||
fromChatId: ChatIdentifier,
|
|
||||||
toChatId: ChatIdentifier,
|
toChatId: ChatIdentifier,
|
||||||
|
fromChatId: ChatIdentifier,
|
||||||
messageId: MessageIdentifier,
|
messageId: MessageIdentifier,
|
||||||
entities: List<TextSource>,
|
entities: List<TextSource>,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
package dev.inmo.tgbotapi.requests.send.abstracts
|
package dev.inmo.tgbotapi.requests.send.abstracts
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.abstracts.types.ReplyMarkup
|
import dev.inmo.tgbotapi.abstracts.types.WithReplyMarkup
|
||||||
|
|
||||||
interface ReplyingMarkupSendMessageRequest<T: Any>: SendMessageRequest<T>, ReplyMarkup
|
interface ReplyingMarkupSendMessageRequest<T: Any>: SendMessageRequest<T>, WithReplyMarkup
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package dev.inmo.tgbotapi.requests.send.games
|
package dev.inmo.tgbotapi.requests.send.games
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.abstracts.types.ReplyMarkup
|
import dev.inmo.tgbotapi.abstracts.types.WithReplyMarkup
|
||||||
import dev.inmo.tgbotapi.requests.send.abstracts.SendMessageRequest
|
import dev.inmo.tgbotapi.requests.send.abstracts.SendMessageRequest
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||||
@@ -29,7 +29,7 @@ data class SendGame (
|
|||||||
@SerialName(replyMarkupField)
|
@SerialName(replyMarkupField)
|
||||||
override val replyMarkup: KeyboardMarkup? = null
|
override val replyMarkup: KeyboardMarkup? = null
|
||||||
) : SendMessageRequest<ContentMessage<GameContent>>,
|
) : SendMessageRequest<ContentMessage<GameContent>>,
|
||||||
ReplyMarkup {
|
WithReplyMarkup {
|
||||||
override fun method(): String = "sendGame"
|
override fun method(): String = "sendGame"
|
||||||
override val resultDeserializer: DeserializationStrategy<ContentMessage<GameContent>>
|
override val resultDeserializer: DeserializationStrategy<ContentMessage<GameContent>>
|
||||||
get() = commonResultDeserializer
|
get() = commonResultDeserializer
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ data class SendInvoice(
|
|||||||
ChatRequest,
|
ChatRequest,
|
||||||
DisableNotification,
|
DisableNotification,
|
||||||
ReplyMessageId,
|
ReplyMessageId,
|
||||||
ReplyMarkup,
|
WithReplyMarkup,
|
||||||
SendMessageRequest<ContentMessage<InvoiceContent>> {
|
SendMessageRequest<ContentMessage<InvoiceContent>> {
|
||||||
override fun method(): String = "sendInvoice"
|
override fun method(): String = "sendInvoice"
|
||||||
override val resultDeserializer: DeserializationStrategy<ContentMessage<InvoiceContent>>
|
override val resultDeserializer: DeserializationStrategy<ContentMessage<InvoiceContent>>
|
||||||
|
|||||||
@@ -39,19 +39,6 @@ val UserId.userLink: String
|
|||||||
val User.link: String
|
val User.link: String
|
||||||
get() = id.userLink
|
get() = id.userLink
|
||||||
|
|
||||||
/**
|
|
||||||
* https://core.telegram.org/bots/api#formatting-options
|
|
||||||
*/
|
|
||||||
@Deprecated("Renamed", ReplaceWith("userLink", "dev.inmo.tgbotapi.types.userLink"))
|
|
||||||
val Identifier.link: String
|
|
||||||
get() = "tg://user?id=$this"
|
|
||||||
/**
|
|
||||||
* https://core.telegram.org/bots/api#formatting-options
|
|
||||||
*/
|
|
||||||
@Deprecated("Renamed", ReplaceWith("userLink", "dev.inmo.tgbotapi.types.userLink"))
|
|
||||||
val ChatId.link: String
|
|
||||||
get() = chatId.link
|
|
||||||
|
|
||||||
typealias UserId = ChatId
|
typealias UserId = ChatId
|
||||||
|
|
||||||
fun Identifier.toChatId(): ChatId = ChatId(this)
|
fun Identifier.toChatId(): ChatId = ChatId(this)
|
||||||
|
|||||||
@@ -19,15 +19,6 @@ data class ReplyForce(
|
|||||||
val Selective = Selective()
|
val Selective = Selective()
|
||||||
val NonSelective = NonSelective()
|
val NonSelective = NonSelective()
|
||||||
val Default = ReplyForce()
|
val Default = ReplyForce()
|
||||||
|
|
||||||
@Deprecated("Renamed", ReplaceWith("ReplyForce.Selective"))
|
|
||||||
inline val ReplyForceSelective
|
|
||||||
get() = Selective
|
|
||||||
@Deprecated("Renamed", ReplaceWith("ReplyForce.NonSelective"))
|
|
||||||
inline val ReplyForceNonSelective
|
|
||||||
get() = NonSelective
|
|
||||||
@Deprecated("Renamed", ReplaceWith("ReplyForce.Default"))
|
|
||||||
val ReplyForceDefault = ReplyForce()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
|||||||
@@ -38,6 +38,3 @@ data class OwnerChatMember(
|
|||||||
@Required
|
@Required
|
||||||
private val type: String = "creator"
|
private val type: String = "creator"
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated("Renamed", ReplaceWith("OwnerChatMember", "dev.inmo.tgbotapi.types.chat.member.OwnerChatMember"))
|
|
||||||
typealias CreatorChatMember = OwnerChatMember
|
|
||||||
|
|||||||
@@ -5,38 +5,68 @@ import dev.inmo.tgbotapi.types.*
|
|||||||
import dev.inmo.tgbotapi.types.chat.*
|
import dev.inmo.tgbotapi.types.chat.*
|
||||||
import dev.inmo.tgbotapi.types.chat.User
|
import dev.inmo.tgbotapi.types.chat.User
|
||||||
|
|
||||||
sealed class ForwardInfo {
|
sealed interface ForwardInfo {
|
||||||
abstract val dateOfOriginal: TelegramDate
|
abstract val dateOfOriginal: TelegramDate
|
||||||
|
|
||||||
|
data class ByAnonymous(
|
||||||
|
override val dateOfOriginal: TelegramDate,
|
||||||
|
val senderName: String
|
||||||
|
) : ForwardInfo
|
||||||
|
|
||||||
|
data class ByUser(
|
||||||
|
override val dateOfOriginal: TelegramDate,
|
||||||
|
override val from: User
|
||||||
|
) : ForwardInfo, FromUser
|
||||||
|
|
||||||
|
sealed interface PublicChat : ForwardInfo {
|
||||||
|
val chat: dev.inmo.tgbotapi.types.chat.PublicChat
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represent forward info for the message sent by [channelChat] into some group
|
||||||
|
*/
|
||||||
|
data class SentByChannel(
|
||||||
|
override val dateOfOriginal: TelegramDate,
|
||||||
|
val channelChat: ChannelChat,
|
||||||
|
val signature: String? = null
|
||||||
|
) : PublicChat {
|
||||||
|
override val chat: dev.inmo.tgbotapi.types.chat.PublicChat
|
||||||
|
get() = channelChat
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represent forward info for the message sent by [channelChat] into that channel
|
||||||
|
*/
|
||||||
|
data class FromChannel(
|
||||||
|
override val dateOfOriginal: TelegramDate,
|
||||||
|
val messageId: MessageIdentifier,
|
||||||
|
val channelChat: ChannelChat,
|
||||||
|
val signature: String? = null
|
||||||
|
) : PublicChat {
|
||||||
|
override val chat: dev.inmo.tgbotapi.types.chat.PublicChat
|
||||||
|
get() = channelChat
|
||||||
|
}
|
||||||
|
|
||||||
|
data class FromSupergroup(
|
||||||
|
override val dateOfOriginal: TelegramDate,
|
||||||
|
val group: SupergroupChat
|
||||||
|
) : PublicChat {
|
||||||
|
override val chat: dev.inmo.tgbotapi.types.chat.PublicChat
|
||||||
|
get() = group
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
data class AnonymousForwardInfo(
|
@Deprecated("Replaced", ReplaceWith("ForwardInfo.ByAnonymous", "dev.inmo.tgbotapi.types.message.ForwardInfo"))
|
||||||
override val dateOfOriginal: TelegramDate,
|
typealias AnonymousForwardInfo = ForwardInfo.ByAnonymous
|
||||||
val senderName: String
|
|
||||||
) : ForwardInfo()
|
|
||||||
|
|
||||||
data class UserForwardInfo(
|
@Deprecated("Replaced", ReplaceWith("ForwardInfo.ByUser", "dev.inmo.tgbotapi.types.message.ForwardInfo"))
|
||||||
override val dateOfOriginal: TelegramDate,
|
typealias UserForwardInfo = ForwardInfo.ByUser
|
||||||
override val from: User
|
|
||||||
) : ForwardInfo(), FromUser
|
|
||||||
|
|
||||||
sealed class ForwardFromPublicChatInfo : ForwardInfo() {
|
@Deprecated("Replaced", ReplaceWith("ForwardInfo.PublicChat", "dev.inmo.tgbotapi.types.message.ForwardInfo"))
|
||||||
abstract val chat: PublicChat
|
typealias ForwardFromPublicChatInfo = ForwardInfo.PublicChat
|
||||||
}
|
|
||||||
|
|
||||||
data class ForwardFromChannelInfo(
|
@Deprecated("Replaced", ReplaceWith("ForwardInfo.PublicChat.FromChannel", "dev.inmo.tgbotapi.types.message.ForwardInfo"))
|
||||||
override val dateOfOriginal: TelegramDate,
|
typealias ForwardFromChannelInfo = ForwardInfo.PublicChat.FromChannel
|
||||||
val messageId: MessageIdentifier,
|
|
||||||
val channelChat: ChannelChat,
|
|
||||||
val signature: String? = null
|
|
||||||
) : ForwardFromPublicChatInfo() {
|
|
||||||
override val chat: PublicChat
|
|
||||||
get() = channelChat
|
|
||||||
}
|
|
||||||
|
|
||||||
data class ForwardFromSupergroupInfo(
|
@Deprecated("Replaced", ReplaceWith("ForwardInfo.PublicChat.FromSupergroup", "dev.inmo.tgbotapi.types.message.ForwardInfo"))
|
||||||
override val dateOfOriginal: TelegramDate,
|
typealias ForwardFromSupergroupInfo = ForwardInfo.PublicChat.FromSupergroup
|
||||||
val group: SupergroupChat
|
|
||||||
) : ForwardFromPublicChatInfo() {
|
|
||||||
override val chat: PublicChat
|
|
||||||
get() = group
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -156,26 +156,39 @@ internal data class RawMessage(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private val forwarded: ForwardInfo? by lazy {
|
private val forwarded: ForwardInfo? by lazy {
|
||||||
forward_date ?: return@lazy null // According to the documentation, now any forwarded message contains this field
|
forward_date
|
||||||
|
?: return@lazy null // According to the documentation, now any forwarded message contains this field
|
||||||
when {
|
when {
|
||||||
forward_sender_name != null -> AnonymousForwardInfo(
|
forward_sender_name != null -> ForwardInfo.ByAnonymous(
|
||||||
forward_date,
|
forward_date,
|
||||||
forward_sender_name
|
forward_sender_name
|
||||||
)
|
)
|
||||||
forward_from_chat is ChannelChat -> ForwardFromChannelInfo(
|
|
||||||
forward_date,
|
forward_from_chat is ChannelChat -> if (forward_from_message_id == null) {
|
||||||
forward_from_message_id ?: error("Channel forwarded message must contain message id, but was not"),
|
ForwardInfo.PublicChat.SentByChannel(
|
||||||
forward_from_chat,
|
forward_date,
|
||||||
forward_signature
|
forward_from_chat,
|
||||||
)
|
forward_signature
|
||||||
forward_from_chat is SupergroupChat -> ForwardFromSupergroupInfo(
|
)
|
||||||
|
} else {
|
||||||
|
ForwardInfo.PublicChat.FromChannel(
|
||||||
|
forward_date,
|
||||||
|
forward_from_message_id,
|
||||||
|
forward_from_chat,
|
||||||
|
forward_signature
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
forward_from_chat is SupergroupChat -> ForwardInfo.PublicChat.FromSupergroup(
|
||||||
forward_date,
|
forward_date,
|
||||||
forward_from_chat
|
forward_from_chat
|
||||||
)
|
)
|
||||||
forward_from != null -> UserForwardInfo(
|
|
||||||
|
forward_from != null -> ForwardInfo.ByUser(
|
||||||
forward_date,
|
forward_date,
|
||||||
forward_from
|
forward_from
|
||||||
)
|
)
|
||||||
|
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.utils.internal
|
package dev.inmo.tgbotapi.utils.internal
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.message.textsources.MultilevelTextSource
|
import dev.inmo.tgbotapi.types.message.textsources.MultilevelTextSource
|
||||||
import dev.inmo.tgbotapi.types.UserId
|
|
||||||
import dev.inmo.tgbotapi.types.link
|
|
||||||
import dev.inmo.tgbotapi.utils.extensions.*
|
import dev.inmo.tgbotapi.utils.extensions.*
|
||||||
|
|
||||||
internal fun MultilevelTextSource.markdownV2Default(
|
internal fun MultilevelTextSource.markdownV2Default(
|
||||||
@@ -61,8 +60,8 @@ internal fun MultilevelTextSource.underlineMarkdownV2(): String = markdownV2Defa
|
|||||||
internal fun MultilevelTextSource.underlineHTML(): String = htmlDefault(htmlUnderlineControl)
|
internal fun MultilevelTextSource.underlineHTML(): String = htmlDefault(htmlUnderlineControl)
|
||||||
|
|
||||||
|
|
||||||
internal fun MultilevelTextSource.textMentionMarkdownV2(userId: UserId): String = linkMarkdownV2(userId.link)
|
internal fun MultilevelTextSource.textMentionMarkdownV2(userId: UserId): String = linkMarkdownV2(userId.userLink)
|
||||||
internal fun MultilevelTextSource.textMentionHTML(userId: UserId): String = linkHTML(userId.link)
|
internal fun MultilevelTextSource.textMentionHTML(userId: UserId): String = linkHTML(userId.userLink)
|
||||||
|
|
||||||
internal fun MultilevelTextSource.mentionMarkdownV2(): String = optionalPrefix("@") + subsources.makeMarkdownV2String()
|
internal fun MultilevelTextSource.mentionMarkdownV2(): String = optionalPrefix("@") + subsources.makeMarkdownV2String()
|
||||||
internal fun MultilevelTextSource.mentionHTML(): String = optionalPrefix("@") + subsources.makeHtmlString()
|
internal fun MultilevelTextSource.mentionHTML(): String = optionalPrefix("@") + subsources.makeHtmlString()
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package dev.inmo.tgbotapi.utils.internal
|
package dev.inmo.tgbotapi.utils.internal
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.types.UserId
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.link
|
|
||||||
import dev.inmo.tgbotapi.types.message.*
|
import dev.inmo.tgbotapi.types.message.*
|
||||||
import dev.inmo.tgbotapi.utils.extensions.*
|
import dev.inmo.tgbotapi.utils.extensions.*
|
||||||
|
|
||||||
@@ -102,7 +101,7 @@ private inline fun String.hashTag(adapt: String.() -> String): String = if (star
|
|||||||
"#${adapt()}"
|
"#${adapt()}"
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun String.textMentionMarkdown(userId: UserId): String = linkMarkdown(userId.link)
|
internal fun String.textMentionMarkdown(userId: UserId): String = linkMarkdown(userId.userLink)
|
||||||
|
|
||||||
internal fun String.mentionMarkdown(): String = mention(String::toMarkdown)
|
internal fun String.mentionMarkdown(): String = mention(String::toMarkdown)
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.requests.abstracts
|
|
||||||
|
|
||||||
import java.io.File
|
|
||||||
|
|
||||||
@Deprecated("Duplacation of asMultipartFile", ReplaceWith("asMultipartFile", "dev.inmo.tgbotapi.requests.abstracts.asMultipartFile"))
|
|
||||||
fun File.toInputFile() = asMultipartFile()
|
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -30,9 +30,6 @@ fun <T> Flow<Iterable<T>>.flatten(): Flow<T> = flow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated("Renamed", ReplaceWith("flatten", "dev.inmo.tgbotapi.extensions.utils.flatten"))
|
|
||||||
fun <T> Flow<Iterable<T>>.flatMap(): Flow<T> = flatten()
|
|
||||||
|
|
||||||
fun <T, R> Flow<T>.flatMap(mapper: (T) -> Iterable<R>): Flow<R> = flow {
|
fun <T, R> Flow<T>.flatMap(mapper: (T) -> Iterable<R>): Flow<R> = flow {
|
||||||
collect {
|
collect {
|
||||||
mapper(it).forEach {
|
mapper(it).forEach {
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ val Chat.link: String?
|
|||||||
inviteLink ?.let { return it }
|
inviteLink ?.let { return it }
|
||||||
}
|
}
|
||||||
if (this is PrivateChat) {
|
if (this is PrivateChat) {
|
||||||
return id.link
|
return id.userLink
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,9 +109,9 @@ private inline fun String.hashTag(adapt: String.() -> String): String = if (star
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun String.textMentionMarkdown(userId: UserId): String = linkMarkdown(userId.link)
|
fun String.textMentionMarkdown(userId: UserId): String = linkMarkdown(userId.userLink)
|
||||||
fun String.textMentionMarkdownV2(userId: UserId): String = linkMarkdownV2(userId.link)
|
fun String.textMentionMarkdownV2(userId: UserId): String = linkMarkdownV2(userId.userLink)
|
||||||
fun String.textMentionHTML(userId: UserId): String = linkHTML(userId.link)
|
fun String.textMentionHTML(userId: UserId): String = linkHTML(userId.userLink)
|
||||||
|
|
||||||
|
|
||||||
fun String.mentionMarkdown(): String = mention(String::toMarkdown)
|
fun String.mentionMarkdown(): String = mention(String::toMarkdown)
|
||||||
|
|||||||
Reference in New Issue
Block a user