mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-26 03:58:44 +00:00
add asFromUserMessage calls to Update#sourceUser
This commit is contained in:
parent
919b1590e3
commit
30c138029e
@ -1,5 +1,6 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.utils.extensions
|
package dev.inmo.tgbotapi.extensions.utils.extensions
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.extensions.utils.asFromUserMessage
|
||||||
import dev.inmo.tgbotapi.extensions.utils.asUser
|
import dev.inmo.tgbotapi.extensions.utils.asUser
|
||||||
import dev.inmo.tgbotapi.extensions.utils.shortcuts.chat
|
import dev.inmo.tgbotapi.extensions.utils.shortcuts.chat
|
||||||
import dev.inmo.tgbotapi.types.User
|
import dev.inmo.tgbotapi.types.User
|
||||||
@ -30,11 +31,11 @@ fun Update.sourceChat(): Chat? = when (this) {
|
|||||||
@PreviewFeature
|
@PreviewFeature
|
||||||
fun Update.sourceUser(): User? = when (this) {
|
fun Update.sourceUser(): User? = when (this) {
|
||||||
is MediaGroupUpdate -> when (this) {
|
is MediaGroupUpdate -> when (this) {
|
||||||
is SentMediaGroupUpdate -> data.chat?.asUser()
|
is SentMediaGroupUpdate -> data.chat?.asUser() ?: data.first().asFromUserMessage()?.user
|
||||||
is EditMediaGroupUpdate -> data.chat.asUser()
|
is EditMediaGroupUpdate -> data.chat.asUser() ?: data.asFromUserMessage()?.user
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
is BaseMessageUpdate -> data.chat.asUser()
|
is BaseMessageUpdate -> data.chat.asUser() ?: data.asFromUserMessage()?.user
|
||||||
is InlineQueryUpdate -> data.from
|
is InlineQueryUpdate -> data.from
|
||||||
is ChosenInlineResultUpdate -> data.user
|
is ChosenInlineResultUpdate -> data.user
|
||||||
is CallbackQueryUpdate -> data.user
|
is CallbackQueryUpdate -> data.user
|
||||||
|
Loading…
Reference in New Issue
Block a user