mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-12-23 00:57:13 +00:00
commit
94e88ddc37
@ -23,6 +23,11 @@
|
||||
* Separated execute extensions (now they are in file `Executes`) and poller creating extensions
|
||||
* `BaseMessageUpdate#toMediaGroupUpdate()` will also check condition when update-receiver already is `MediaGroupUpdate`
|
||||
|
||||
### 0.12.1 Hotfix for media groups
|
||||
|
||||
* Added additional media group types (like `MessageMediaGroupUpdate`)
|
||||
* Fixed handling of media group updates in `UpdatesFilter`
|
||||
|
||||
## 0.11.0
|
||||
|
||||
* Kotlin `1.3.11` -> `1.3.21`
|
||||
|
@ -1,4 +1,4 @@
|
||||
project.version = "0.12.0"
|
||||
project.version = "0.12.1"
|
||||
project.group = "com.github.insanusmokrassar"
|
||||
|
||||
buildscript {
|
||||
|
@ -1,10 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.types.update
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.MediaGroupMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.BaseMessageUpdate
|
||||
|
||||
data class MediaGroupUpdate(
|
||||
override val updateId: UpdateIdentifier,
|
||||
override val data: MediaGroupMessage
|
||||
) : BaseMessageUpdate
|
@ -0,0 +1,16 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.types.update.MediaGroupUpdates
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.MediaGroupMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.ChannelPostUpdate
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.MessageUpdate
|
||||
|
||||
data class ChannelPostMediaGroupUpdate(
|
||||
override val updateId: UpdateIdentifier,
|
||||
override val data: MediaGroupMessage
|
||||
) : MediaGroupUpdate {
|
||||
constructor(sourceUpdate: ChannelPostUpdate) : this(
|
||||
sourceUpdate.updateId,
|
||||
sourceUpdate.data as MediaGroupMessage
|
||||
)
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.types.update.MediaGroupUpdates
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.MediaGroupMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.*
|
||||
|
||||
data class EditChannelPostMediaGroupUpdate(
|
||||
override val updateId: UpdateIdentifier,
|
||||
override val data: MediaGroupMessage
|
||||
) : MediaGroupUpdate {
|
||||
constructor(sourceUpdate: EditChannelPostUpdate) : this(
|
||||
sourceUpdate.updateId,
|
||||
sourceUpdate.data as MediaGroupMessage
|
||||
)
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.types.update.MediaGroupUpdates
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.MediaGroupMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.EditMessageUpdate
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.MessageUpdate
|
||||
|
||||
data class EditMessageMediaGroupUpdate(
|
||||
override val updateId: UpdateIdentifier,
|
||||
override val data: MediaGroupMessage
|
||||
) : MediaGroupUpdate {
|
||||
constructor(sourceUpdate: EditMessageUpdate) : this(
|
||||
sourceUpdate.updateId,
|
||||
sourceUpdate.data as MediaGroupMessage
|
||||
)
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.types.update.MediaGroupUpdates
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.MediaGroupMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.BaseMessageUpdate
|
||||
|
||||
interface MediaGroupUpdate: BaseMessageUpdate {
|
||||
override val data: MediaGroupMessage
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.types.update.MediaGroupUpdates
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.MediaGroupMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.MessageUpdate
|
||||
|
||||
data class MessageMediaGroupUpdate(
|
||||
override val updateId: UpdateIdentifier,
|
||||
override val data: MediaGroupMessage
|
||||
) : MediaGroupUpdate {
|
||||
constructor(sourceUpdate: MessageUpdate) : this(
|
||||
sourceUpdate.updateId,
|
||||
sourceUpdate.data as MediaGroupMessage
|
||||
)
|
||||
}
|
@ -1,9 +1,16 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.utils
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.MediaGroupMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.MediaGroupUpdate
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.MediaGroupUpdates.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.BaseMessageUpdate
|
||||
|
||||
fun BaseMessageUpdate.toMediaGroupUpdate(): MediaGroupUpdate? = (this as? MediaGroupUpdate) ?: ((data as? MediaGroupMessage) ?.let {
|
||||
MediaGroupUpdate(updateId, it)
|
||||
when (this) {
|
||||
is MessageUpdate -> MessageMediaGroupUpdate(this)
|
||||
is EditMessageUpdate -> EditMessageMediaGroupUpdate(this)
|
||||
is ChannelPostUpdate -> ChannelPostMediaGroupUpdate(this)
|
||||
is EditChannelPostUpdate -> EditChannelPostMediaGroupUpdate(this)
|
||||
else -> null
|
||||
}
|
||||
})
|
||||
|
@ -4,7 +4,6 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.MediaGroupIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.Chat
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.ForwardedMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.MediaGroupUpdate
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.BaseMessageUpdate
|
||||
|
||||
val List<BaseMessageUpdate>.forwarded: ForwardedMessage?
|
||||
|
@ -2,6 +2,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.utils.extensions
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.MediaGroupUpdates.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.BaseMessageUpdate
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toMediaGroupUpdate
|
||||
|
||||
@ -37,28 +38,28 @@ data class UpdatesFilter(
|
||||
when (update) {
|
||||
is MessageUpdate -> messageCallback ?.invoke(update)
|
||||
is List<*> -> when (update.firstOrNull()) {
|
||||
is MessageUpdate -> update.mapNotNull { it as? MessageUpdate }.let { mappedList ->
|
||||
is MessageUpdate, is MessageMediaGroupUpdate -> update.mapNotNull { it as? MessageUpdate }.let { mappedList ->
|
||||
messageMediaGroupCallback ?.also { receiver ->
|
||||
receiver(mappedList.mapNotNull { it.toMediaGroupUpdate() })
|
||||
} ?: messageCallback ?.also { receiver ->
|
||||
mappedList.forEach { receiver(it) }
|
||||
}
|
||||
}
|
||||
is EditMessageUpdate -> update.mapNotNull { it as? EditMessageUpdate }.let { mappedList ->
|
||||
is EditMessageUpdate, is EditMessageMediaGroupUpdate -> update.mapNotNull { it as? EditMessageUpdate }.let { mappedList ->
|
||||
editedMessageMediaGroupCallback ?.also { receiver ->
|
||||
receiver(mappedList.mapNotNull { it.toMediaGroupUpdate() })
|
||||
} ?: editedMessageCallback ?.also { receiver ->
|
||||
mappedList.forEach { receiver(it) }
|
||||
}
|
||||
}
|
||||
is ChannelPostUpdate -> update.mapNotNull { it as? ChannelPostUpdate }.let { mappedList ->
|
||||
is ChannelPostUpdate, is ChannelPostMediaGroupUpdate -> update.mapNotNull { it as? ChannelPostUpdate }.let { mappedList ->
|
||||
channelPostMediaGroupCallback ?.also { receiver ->
|
||||
receiver(mappedList.mapNotNull { it.toMediaGroupUpdate() })
|
||||
} ?: channelPostCallback ?.also { receiver ->
|
||||
mappedList.forEach { receiver(it) }
|
||||
}
|
||||
}
|
||||
is EditChannelPostUpdate -> update.mapNotNull { it as? EditChannelPostUpdate }.let { mappedList ->
|
||||
is EditChannelPostUpdate, is EditChannelPostMediaGroupUpdate -> update.mapNotNull { it as? EditChannelPostUpdate }.let { mappedList ->
|
||||
editedChannelPostMediaGroupCallback ?.also { receiver ->
|
||||
receiver(mappedList.mapNotNull { it.toMediaGroupUpdate() })
|
||||
} ?: editedChannelPostCallback ?.also { receiver ->
|
||||
|
@ -3,7 +3,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.utils.extensions
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.GetUpdates
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.MediaGroupUpdate
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.MediaGroupUpdates.MediaGroupUpdate
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.BaseMessageUpdate
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.mediaGroupId
|
||||
|
@ -2,6 +2,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.utils.extensions
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.MediaGroupUpdates.MediaGroupUpdate
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.BaseMessageUpdate
|
||||
import kotlinx.coroutines.*
|
||||
import java.util.concurrent.Executors
|
||||
|
Loading…
Reference in New Issue
Block a user