mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-12-30 18:09:25 +00:00
Compare commits
4 Commits
b843fd9188
...
13.0.0
| Author | SHA1 | Date | |
|---|---|---|---|
| fe4be69051 | |||
| 06ba14e8be | |||
| ca1b196942 | |||
| dc5d8afe32 |
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
## 13.0.0
|
## 13.0.0
|
||||||
|
|
||||||
|
**Add support of [Telegram Bots API 7.3](https://core.telegram.org/bots/api-changelog#may-6-2024)**
|
||||||
|
|
||||||
**THIS UPDATE CONTAINS BREAKING CHANGES**
|
**THIS UPDATE CONTAINS BREAKING CHANGES**
|
||||||
|
|
||||||
* `Core`:
|
* `Core`:
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# TelegramBotAPI [](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) [](https://core.telegram.org/bots/api-changelog#march-31-2024)
|
# TelegramBotAPI [](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) [](https://core.telegram.org/bots/api-changelog#may-6-2024)
|
||||||
|
|
||||||
| Docs | [](https://tgbotapi.inmo.dev/index.html) [](https://docs.inmo.dev/tgbotapi/index.html) |
|
| Docs | [](https://tgbotapi.inmo.dev/index.html) [](https://docs.inmo.dev/tgbotapi/index.html) |
|
||||||
|:----------------------:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
|
|:----------------------:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
|
||||||
|
|||||||
@@ -171,7 +171,8 @@ public final class dev/inmo/tgbotapi/extensions/api/LiveLocationProvider : java/
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final class dev/inmo/tgbotapi/extensions/api/LiveLocationProviderKt {
|
public final class dev/inmo/tgbotapi/extensions/api/LiveLocationProviderKt {
|
||||||
public static final fun getDefaultLivePeriodDelayMillis ()J
|
public static final field defaultLivePeriodDelayMillis J
|
||||||
|
public static final field indefiniteLivePeriodDelayMillis J
|
||||||
public static final fun replyWithLiveLocation-036Eddc (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/message/abstracts/AccessibleMessage;Lkotlinx/coroutines/CoroutineScope;DDJLjava/lang/Float;Ljava/lang/Integer;Ljava/lang/Float;Ldev/inmo/tgbotapi/types/MessageThreadId;Ljava/lang/String;ZZLjava/lang/Boolean;Ldev/inmo/tgbotapi/types/buttons/KeyboardMarkup;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
public static final fun replyWithLiveLocation-036Eddc (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/message/abstracts/AccessibleMessage;Lkotlinx/coroutines/CoroutineScope;DDJLjava/lang/Float;Ljava/lang/Integer;Ljava/lang/Float;Ldev/inmo/tgbotapi/types/MessageThreadId;Ljava/lang/String;ZZLjava/lang/Boolean;Ldev/inmo/tgbotapi/types/buttons/KeyboardMarkup;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||||
public static synthetic fun replyWithLiveLocation-036Eddc$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/message/abstracts/AccessibleMessage;Lkotlinx/coroutines/CoroutineScope;DDJLjava/lang/Float;Ljava/lang/Integer;Ljava/lang/Float;Ldev/inmo/tgbotapi/types/MessageThreadId;Ljava/lang/String;ZZLjava/lang/Boolean;Ldev/inmo/tgbotapi/types/buttons/KeyboardMarkup;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
public static synthetic fun replyWithLiveLocation-036Eddc$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/message/abstracts/AccessibleMessage;Lkotlinx/coroutines/CoroutineScope;DDJLjava/lang/Float;Ljava/lang/Integer;Ljava/lang/Float;Ldev/inmo/tgbotapi/types/MessageThreadId;Ljava/lang/String;ZZLjava/lang/Boolean;Ldev/inmo/tgbotapi/types/buttons/KeyboardMarkup;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||||
public static final fun replyWithLiveLocation-bUFzSfA (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/message/abstracts/AccessibleMessage;Lkotlinx/coroutines/CoroutineScope;Ldev/inmo/tgbotapi/types/location/StaticLocation;JLjava/lang/Float;Ljava/lang/Integer;Ljava/lang/Float;Ldev/inmo/tgbotapi/types/MessageThreadId;Ljava/lang/String;ZZLjava/lang/Boolean;Ldev/inmo/tgbotapi/types/buttons/KeyboardMarkup;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
public static final fun replyWithLiveLocation-bUFzSfA (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/message/abstracts/AccessibleMessage;Lkotlinx/coroutines/CoroutineScope;Ldev/inmo/tgbotapi/types/location/StaticLocation;JLjava/lang/Float;Ljava/lang/Integer;Ljava/lang/Float;Ldev/inmo/tgbotapi/types/MessageThreadId;Ljava/lang/String;ZZLjava/lang/Boolean;Ldev/inmo/tgbotapi/types/buttons/KeyboardMarkup;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||||
|
|||||||
@@ -50,22 +50,30 @@ suspend fun TelegramBot.handleLiveLocation(
|
|||||||
sentMessageFlow: FlowCollector<ContentMessage<LocationContent>>? = null
|
sentMessageFlow: FlowCollector<ContentMessage<LocationContent>>? = null
|
||||||
) {
|
) {
|
||||||
var currentLiveLocationMessage: ContentMessage<LocationContent>? = null
|
var currentLiveLocationMessage: ContentMessage<LocationContent>? = null
|
||||||
val updateMessageJob = CoroutineScope(currentCoroutineContext().LinkedSupervisorJob()).launchSafelyWithoutExceptions(start = CoroutineStart.LAZY) {
|
val updateMessageJob = if (liveTimeMillis == indefiniteLivePeriodDelayMillis) { // do not launch refreshing of message for indefinite live locations
|
||||||
while (isActive) {
|
null
|
||||||
delay(liveTimeMillis)
|
} else {
|
||||||
// Remove previous location message info to resend live location message
|
CoroutineScope(currentCoroutineContext().LinkedSupervisorJob()).launchSafelyWithoutExceptions(start = CoroutineStart.LAZY) {
|
||||||
currentLiveLocationMessage = null
|
while (isActive) {
|
||||||
|
delay(liveTimeMillis)
|
||||||
|
// Remove previous location message info to resend live location message
|
||||||
|
currentLiveLocationMessage = null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
locationsFlow.collect {
|
locationsFlow.collect {
|
||||||
val capturedLiveLocationMessage = currentLiveLocationMessage
|
val capturedLiveLocationMessage = currentLiveLocationMessage
|
||||||
if (capturedLiveLocationMessage == null) {
|
if (capturedLiveLocationMessage == null) {
|
||||||
updateMessageJob.start()
|
updateMessageJob ?.start()
|
||||||
currentLiveLocationMessage = send(
|
currentLiveLocationMessage = send(
|
||||||
chatId,
|
chatId,
|
||||||
it.latitude,
|
it.latitude,
|
||||||
it.longitude,
|
it.longitude,
|
||||||
ceil(liveTimeMillis.toDouble() / 1000).toInt(),
|
if (liveTimeMillis == indefiniteLivePeriodDelayMillis) {
|
||||||
|
LiveLocation.INDEFINITE_LIVE_PERIOD
|
||||||
|
} else {
|
||||||
|
ceil(liveTimeMillis.toDouble() / 1000).toInt()
|
||||||
|
},
|
||||||
it.horizontalAccuracy,
|
it.horizontalAccuracy,
|
||||||
it.heading,
|
it.heading,
|
||||||
it.proximityAlertRadius,
|
it.proximityAlertRadius,
|
||||||
@@ -83,7 +91,6 @@ suspend fun TelegramBot.handleLiveLocation(
|
|||||||
message = capturedLiveLocationMessage,
|
message = capturedLiveLocationMessage,
|
||||||
latitude = it.latitude,
|
latitude = it.latitude,
|
||||||
longitude = it.longitude,
|
longitude = it.longitude,
|
||||||
livePeriod = null,
|
|
||||||
horizontalAccuracy = it.horizontalAccuracy,
|
horizontalAccuracy = it.horizontalAccuracy,
|
||||||
heading = it.heading,
|
heading = it.heading,
|
||||||
proximityAlertRadius = it.proximityAlertRadius,
|
proximityAlertRadius = it.proximityAlertRadius,
|
||||||
|
|||||||
@@ -23,7 +23,8 @@ import kotlinx.coroutines.CoroutineScope
|
|||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlin.math.ceil
|
import kotlin.math.ceil
|
||||||
|
|
||||||
val defaultLivePeriodDelayMillis = (livePeriodLimit.last - 60L) * 1000L
|
const val indefiniteLivePeriodDelayMillis = LiveLocation.INDEFINITE_LIVE_PERIOD * 1000L
|
||||||
|
const val defaultLivePeriodDelayMillis = indefiniteLivePeriodDelayMillis
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see startLiveLocation
|
* @see startLiveLocation
|
||||||
|
|||||||
@@ -13541,7 +13541,7 @@ public final class dev/inmo/tgbotapi/types/chat/Chat$Companion {
|
|||||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final class dev/inmo/tgbotapi/types/chat/ChatBackground : dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/CommonEvent {
|
public final class dev/inmo/tgbotapi/types/chat/ChatBackground : dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/PublicChatEvent {
|
||||||
public static final field Companion Ldev/inmo/tgbotapi/types/chat/ChatBackground$Companion;
|
public static final field Companion Ldev/inmo/tgbotapi/types/chat/ChatBackground$Companion;
|
||||||
public fun <init> (Ldev/inmo/tgbotapi/types/BackgroundType;)V
|
public fun <init> (Ldev/inmo/tgbotapi/types/BackgroundType;)V
|
||||||
public final fun component1 ()Ldev/inmo/tgbotapi/types/BackgroundType;
|
public final fun component1 ()Ldev/inmo/tgbotapi/types/BackgroundType;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package dev.inmo.tgbotapi.types
|
package dev.inmo.tgbotapi.types
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.types.location.LiveLocation
|
||||||
import dev.inmo.tgbotapi.utils.BuiltinMimeTypes
|
import dev.inmo.tgbotapi.utils.BuiltinMimeTypes
|
||||||
|
|
||||||
typealias ForwardSignature = String
|
typealias ForwardSignature = String
|
||||||
@@ -47,7 +48,7 @@ val pollOptionTextLength = 1 .. 100
|
|||||||
val pollQuestionTextLength = 1 .. 300
|
val pollQuestionTextLength = 1 .. 300
|
||||||
val pollOptionsLimit = 2 .. 10
|
val pollOptionsLimit = 2 .. 10
|
||||||
|
|
||||||
val livePeriodLimit = 60 .. 86400
|
val livePeriodLimit = 60 .. LiveLocation.INDEFINITE_LIVE_PERIOD
|
||||||
|
|
||||||
val inlineQueryAnswerResultsLimit = 0 .. 50
|
val inlineQueryAnswerResultsLimit = 0 .. 50
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package dev.inmo.tgbotapi.types.chat
|
|||||||
|
|
||||||
import dev.inmo.tgbotapi.types.BackgroundType
|
import dev.inmo.tgbotapi.types.BackgroundType
|
||||||
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.CommonEvent
|
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.CommonEvent
|
||||||
|
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.PublicChatEvent
|
||||||
import dev.inmo.tgbotapi.types.typeField
|
import dev.inmo.tgbotapi.types.typeField
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
@@ -10,4 +11,4 @@ import kotlinx.serialization.Serializable
|
|||||||
data class ChatBackground(
|
data class ChatBackground(
|
||||||
@SerialName(typeField)
|
@SerialName(typeField)
|
||||||
val type: BackgroundType
|
val type: BackgroundType
|
||||||
) : CommonEvent
|
) : PublicChatEvent
|
||||||
|
|||||||
Reference in New Issue
Block a user