mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 16:23:48 +00:00
add LocationContent#copy
This commit is contained in:
parent
94ad758814
commit
aeb6fad409
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user