1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-26 03:58:44 +00:00

add LocationContent#copy

This commit is contained in:
InsanusMokrassar 2021-09-21 18:49:29 +06:00
parent 94ad758814
commit aeb6fad409

View File

@ -19,6 +19,25 @@ import kotlinx.serialization.encoding.*
sealed interface LocationContent : MessageContent {
val location: Location
fun copy(location: Location = this.location) {
when (this) {
is LiveLocationContent -> LiveLocationContent(
(location as? LiveLocation) ?: this.location.copy(
longitude = location.longitude,
latitude = location.latitude,
horizontalAccuracy = location.horizontalAccuracy
)
)
is StaticLocationContent -> StaticLocationContent(
(location as? StaticLocation) ?: this.location.copy(
longitude = location.longitude,
latitude = location.latitude,
horizontalAccuracy = location.horizontalAccuracy
)
)
}
}
companion object {
operator fun invoke(location: Location): LocationContent {
return when (location) {