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