mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 00:03:48 +00:00
improve ChannelContentMessage
This commit is contained in:
parent
b7ff6a3061
commit
1dc9dc42fb
@ -1,6 +1,5 @@
|
||||
package dev.inmo.tgbotapi.types.message.abstracts
|
||||
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
import dev.inmo.tgbotapi.types.chat.PreviewChat
|
||||
|
||||
interface WithSenderChatMessage {
|
||||
|
@ -17,8 +17,8 @@ fun <T : MediaGroupPartContent> List<PossiblySentViaBotCommonMessage<T>>.asMedia
|
||||
return when (sourceMessage) {
|
||||
is ChannelContentMessage -> ChannelContentMessageImpl(
|
||||
messageId = sourceMessage.messageId,
|
||||
from = sourceMessage.from,
|
||||
chat = sourceMessage.chat,
|
||||
senderChat = sourceMessage.senderChat,
|
||||
content = content,
|
||||
date = sourceMessage.date,
|
||||
editDate = sourceMessage.editDate,
|
||||
|
@ -7,6 +7,7 @@ import dev.inmo.tgbotapi.abstracts.OptionallyFromUser
|
||||
import dev.inmo.tgbotapi.abstracts.OptionallyWithUser
|
||||
import dev.inmo.tgbotapi.abstracts.WithUser
|
||||
import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.WithSenderChatMessage
|
||||
import dev.inmo.tgbotapi.utils.PreviewFeature
|
||||
|
||||
@PreviewFeature
|
||||
@ -54,3 +55,13 @@ inline fun Any.withOptionalLanguageCodeOrNull(): WithOptionalLanguageCode? = thi
|
||||
|
||||
@PreviewFeature
|
||||
inline fun Any.withOptionalLanguageCodeOrThrow(): WithOptionalLanguageCode = this as WithOptionalLanguageCode
|
||||
|
||||
@PreviewFeature
|
||||
inline fun <T> Any.ifWithSenderChatMessage(block: (WithSenderChatMessage) -> T) =
|
||||
withSenderChatMessageOrNull()?.let(block)
|
||||
|
||||
@PreviewFeature
|
||||
inline fun Any.withSenderChatMessageOrNull(): WithSenderChatMessage? = this as? WithSenderChatMessage
|
||||
|
||||
@PreviewFeature
|
||||
inline fun Any.withSenderChatMessageOrThrow(): WithSenderChatMessage = this as WithSenderChatMessage
|
||||
|
@ -25,8 +25,8 @@ import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
inline val Message.from: User?
|
||||
get() = optionallyFromUserMessageOrNull() ?.from
|
||||
@RiskFeature(RawFieldsUsageWarning)
|
||||
inline val Message.sender_chat: PublicChat?
|
||||
get() = asFromChannelGroupContentMessage() ?.senderChat
|
||||
inline val Message.sender_chat: PreviewChat?
|
||||
get() = withSenderChatMessageOrNull() ?.senderChat
|
||||
@RiskFeature(RawFieldsUsageWarning)
|
||||
inline val Message.forward_from: User?
|
||||
get() = asPossiblyForwardedMessage() ?.forwardInfo ?.asUserForwardInfo() ?.from
|
||||
|
Loading…
Reference in New Issue
Block a user