mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 08:13:47 +00:00
class casts for ResendableContent and TextSource
This commit is contained in:
parent
c5ada8cea0
commit
6bd423dc11
@ -2,6 +2,10 @@
|
||||
|
||||
## 0.30.13
|
||||
|
||||
* `Utils`:
|
||||
* Extensions for `ResendableContent` has been added
|
||||
* Extensions for `TextSource` has been added
|
||||
|
||||
## 0.30.12
|
||||
|
||||
* `Utils`:
|
||||
|
@ -40,6 +40,48 @@ import dev.inmo.tgbotapi.types.update.*
|
||||
import dev.inmo.tgbotapi.types.update.MediaGroupUpdates.*
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.*
|
||||
import dev.inmo.tgbotapi.utils.PreviewFeature
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.ResendableContent
|
||||
import dev.inmo.tgbotapi.types.message.content.ContactContent
|
||||
import dev.inmo.tgbotapi.types.message.content.DiceContent
|
||||
import dev.inmo.tgbotapi.types.message.content.GameContent
|
||||
import dev.inmo.tgbotapi.types.message.content.LocationContent
|
||||
import dev.inmo.tgbotapi.types.message.content.PollContent
|
||||
import dev.inmo.tgbotapi.types.message.content.TextContent
|
||||
import dev.inmo.tgbotapi.types.message.content.VenueContent
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.AudioMediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.DocumentMediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.MediaCollectionContent
|
||||
import dev.inmo.tgbotapi.types.files.abstracts.TelegramMediaFile
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.MediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.VisualMediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.message.content.media.AnimationContent
|
||||
import dev.inmo.tgbotapi.types.message.content.media.AudioContent
|
||||
import dev.inmo.tgbotapi.types.message.content.media.DocumentContent
|
||||
import dev.inmo.tgbotapi.types.message.content.media.PhotoContent
|
||||
import dev.inmo.tgbotapi.types.message.content.media.StickerContent
|
||||
import dev.inmo.tgbotapi.types.message.content.media.VideoContent
|
||||
import dev.inmo.tgbotapi.types.message.content.media.VideoNoteContent
|
||||
import dev.inmo.tgbotapi.types.message.content.media.VoiceContent
|
||||
import dev.inmo.tgbotapi.types.message.payments.InvoiceContent
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.TextSource
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.MultilevelTextSource
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.BoldTextSource
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.BotCommandTextSource
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.CashTagTextSource
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.CodeTextSource
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.EMailTextSource
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.HashTagTextSource
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.ItalicTextSource
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.MentionTextSource
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.PhoneNumberTextSource
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.PreTextSource
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.RegularTextSource
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.StrikethroughTextSource
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextLinkTextSource
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextMentionTextSource
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.URLTextSource
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.UnderlineTextSource
|
||||
|
||||
@PreviewFeature
|
||||
inline fun Chat.asBot(): Bot? = this as? Bot
|
||||
@ -753,3 +795,163 @@ inline fun Poll.requireRegularPoll(): RegularPoll = this as RegularPoll
|
||||
inline fun Poll.asUnknownPollType(): UnknownPollType? = this as? UnknownPollType
|
||||
@PreviewFeature
|
||||
inline fun Poll.requireUnknownPollType(): UnknownPollType = this as UnknownPollType
|
||||
@PreviewFeature
|
||||
inline fun ResendableContent.asContactContent(): ContactContent? = this as? ContactContent
|
||||
@PreviewFeature
|
||||
inline fun ResendableContent.requireContactContent(): ContactContent = this as ContactContent
|
||||
@PreviewFeature
|
||||
inline fun ResendableContent.asDiceContent(): DiceContent? = this as? DiceContent
|
||||
@PreviewFeature
|
||||
inline fun ResendableContent.requireDiceContent(): DiceContent = this as DiceContent
|
||||
@PreviewFeature
|
||||
inline fun ResendableContent.asGameContent(): GameContent? = this as? GameContent
|
||||
@PreviewFeature
|
||||
inline fun ResendableContent.requireGameContent(): GameContent = this as GameContent
|
||||
@PreviewFeature
|
||||
inline fun ResendableContent.asLocationContent(): LocationContent? = this as? LocationContent
|
||||
@PreviewFeature
|
||||
inline fun ResendableContent.requireLocationContent(): LocationContent = this as LocationContent
|
||||
@PreviewFeature
|
||||
inline fun ResendableContent.asPollContent(): PollContent? = this as? PollContent
|
||||
@PreviewFeature
|
||||
inline fun ResendableContent.requirePollContent(): PollContent = this as PollContent
|
||||
@PreviewFeature
|
||||
inline fun ResendableContent.asTextContent(): TextContent? = this as? TextContent
|
||||
@PreviewFeature
|
||||
inline fun ResendableContent.requireTextContent(): TextContent = this as TextContent
|
||||
@PreviewFeature
|
||||
inline fun ResendableContent.asVenueContent(): VenueContent? = this as? VenueContent
|
||||
@PreviewFeature
|
||||
inline fun ResendableContent.requireVenueContent(): VenueContent = this as VenueContent
|
||||
@PreviewFeature
|
||||
inline fun ResendableContent.asAudioMediaGroupContent(): AudioMediaGroupContent? = this as? AudioMediaGroupContent
|
||||
@PreviewFeature
|
||||
inline fun ResendableContent.requireAudioMediaGroupContent(): AudioMediaGroupContent = this as AudioMediaGroupContent
|
||||
@PreviewFeature
|
||||
inline fun ResendableContent.asDocumentMediaGroupContent(): DocumentMediaGroupContent? = this as? DocumentMediaGroupContent
|
||||
@PreviewFeature
|
||||
inline fun ResendableContent.requireDocumentMediaGroupContent(): DocumentMediaGroupContent = this as DocumentMediaGroupContent
|
||||
@PreviewFeature
|
||||
inline fun ResendableContent.asMediaCollectionContent(): MediaCollectionContent<TelegramMediaFile>? = this as? MediaCollectionContent<TelegramMediaFile>
|
||||
@PreviewFeature
|
||||
inline fun ResendableContent.requireMediaCollectionContent(): MediaCollectionContent<TelegramMediaFile> = this as MediaCollectionContent<TelegramMediaFile>
|
||||
@PreviewFeature
|
||||
inline fun ResendableContent.asMediaContent(): MediaContent? = this as? MediaContent
|
||||
@PreviewFeature
|
||||
inline fun ResendableContent.requireMediaContent(): MediaContent = this as MediaContent
|
||||
@PreviewFeature
|
||||
inline fun ResendableContent.asMediaGroupContent(): MediaGroupContent? = this as? MediaGroupContent
|
||||
@PreviewFeature
|
||||
inline fun ResendableContent.requireMediaGroupContent(): MediaGroupContent = this as MediaGroupContent
|
||||
@PreviewFeature
|
||||
inline fun ResendableContent.asMessageContent(): MessageContent? = this as? MessageContent
|
||||
@PreviewFeature
|
||||
inline fun ResendableContent.requireMessageContent(): MessageContent = this as MessageContent
|
||||
@PreviewFeature
|
||||
inline fun ResendableContent.asVisualMediaGroupContent(): VisualMediaGroupContent? = this as? VisualMediaGroupContent
|
||||
@PreviewFeature
|
||||
inline fun ResendableContent.requireVisualMediaGroupContent(): VisualMediaGroupContent = this as VisualMediaGroupContent
|
||||
@PreviewFeature
|
||||
inline fun ResendableContent.asAnimationContent(): AnimationContent? = this as? AnimationContent
|
||||
@PreviewFeature
|
||||
inline fun ResendableContent.requireAnimationContent(): AnimationContent = this as AnimationContent
|
||||
@PreviewFeature
|
||||
inline fun ResendableContent.asAudioContent(): AudioContent? = this as? AudioContent
|
||||
@PreviewFeature
|
||||
inline fun ResendableContent.requireAudioContent(): AudioContent = this as AudioContent
|
||||
@PreviewFeature
|
||||
inline fun ResendableContent.asDocumentContent(): DocumentContent? = this as? DocumentContent
|
||||
@PreviewFeature
|
||||
inline fun ResendableContent.requireDocumentContent(): DocumentContent = this as DocumentContent
|
||||
@PreviewFeature
|
||||
inline fun ResendableContent.asPhotoContent(): PhotoContent? = this as? PhotoContent
|
||||
@PreviewFeature
|
||||
inline fun ResendableContent.requirePhotoContent(): PhotoContent = this as PhotoContent
|
||||
@PreviewFeature
|
||||
inline fun ResendableContent.asStickerContent(): StickerContent? = this as? StickerContent
|
||||
@PreviewFeature
|
||||
inline fun ResendableContent.requireStickerContent(): StickerContent = this as StickerContent
|
||||
@PreviewFeature
|
||||
inline fun ResendableContent.asVideoContent(): VideoContent? = this as? VideoContent
|
||||
@PreviewFeature
|
||||
inline fun ResendableContent.requireVideoContent(): VideoContent = this as VideoContent
|
||||
@PreviewFeature
|
||||
inline fun ResendableContent.asVideoNoteContent(): VideoNoteContent? = this as? VideoNoteContent
|
||||
@PreviewFeature
|
||||
inline fun ResendableContent.requireVideoNoteContent(): VideoNoteContent = this as VideoNoteContent
|
||||
@PreviewFeature
|
||||
inline fun ResendableContent.asVoiceContent(): VoiceContent? = this as? VoiceContent
|
||||
@PreviewFeature
|
||||
inline fun ResendableContent.requireVoiceContent(): VoiceContent = this as VoiceContent
|
||||
@PreviewFeature
|
||||
inline fun ResendableContent.asInvoiceContent(): InvoiceContent? = this as? InvoiceContent
|
||||
@PreviewFeature
|
||||
inline fun ResendableContent.requireInvoiceContent(): InvoiceContent = this as InvoiceContent
|
||||
@PreviewFeature
|
||||
inline fun TextSource.asMultilevelTextSource(): MultilevelTextSource? = this as? MultilevelTextSource
|
||||
@PreviewFeature
|
||||
inline fun TextSource.requireMultilevelTextSource(): MultilevelTextSource = this as MultilevelTextSource
|
||||
@PreviewFeature
|
||||
inline fun TextSource.asBoldTextSource(): BoldTextSource? = this as? BoldTextSource
|
||||
@PreviewFeature
|
||||
inline fun TextSource.requireBoldTextSource(): BoldTextSource = this as BoldTextSource
|
||||
@PreviewFeature
|
||||
inline fun TextSource.asBotCommandTextSource(): BotCommandTextSource? = this as? BotCommandTextSource
|
||||
@PreviewFeature
|
||||
inline fun TextSource.requireBotCommandTextSource(): BotCommandTextSource = this as BotCommandTextSource
|
||||
@PreviewFeature
|
||||
inline fun TextSource.asCashTagTextSource(): CashTagTextSource? = this as? CashTagTextSource
|
||||
@PreviewFeature
|
||||
inline fun TextSource.requireCashTagTextSource(): CashTagTextSource = this as CashTagTextSource
|
||||
@PreviewFeature
|
||||
inline fun TextSource.asCodeTextSource(): CodeTextSource? = this as? CodeTextSource
|
||||
@PreviewFeature
|
||||
inline fun TextSource.requireCodeTextSource(): CodeTextSource = this as CodeTextSource
|
||||
@PreviewFeature
|
||||
inline fun TextSource.asEMailTextSource(): EMailTextSource? = this as? EMailTextSource
|
||||
@PreviewFeature
|
||||
inline fun TextSource.requireEMailTextSource(): EMailTextSource = this as EMailTextSource
|
||||
@PreviewFeature
|
||||
inline fun TextSource.asHashTagTextSource(): HashTagTextSource? = this as? HashTagTextSource
|
||||
@PreviewFeature
|
||||
inline fun TextSource.requireHashTagTextSource(): HashTagTextSource = this as HashTagTextSource
|
||||
@PreviewFeature
|
||||
inline fun TextSource.asItalicTextSource(): ItalicTextSource? = this as? ItalicTextSource
|
||||
@PreviewFeature
|
||||
inline fun TextSource.requireItalicTextSource(): ItalicTextSource = this as ItalicTextSource
|
||||
@PreviewFeature
|
||||
inline fun TextSource.asMentionTextSource(): MentionTextSource? = this as? MentionTextSource
|
||||
@PreviewFeature
|
||||
inline fun TextSource.requireMentionTextSource(): MentionTextSource = this as MentionTextSource
|
||||
@PreviewFeature
|
||||
inline fun TextSource.asPhoneNumberTextSource(): PhoneNumberTextSource? = this as? PhoneNumberTextSource
|
||||
@PreviewFeature
|
||||
inline fun TextSource.requirePhoneNumberTextSource(): PhoneNumberTextSource = this as PhoneNumberTextSource
|
||||
@PreviewFeature
|
||||
inline fun TextSource.asPreTextSource(): PreTextSource? = this as? PreTextSource
|
||||
@PreviewFeature
|
||||
inline fun TextSource.requirePreTextSource(): PreTextSource = this as PreTextSource
|
||||
@PreviewFeature
|
||||
inline fun TextSource.asRegularTextSource(): RegularTextSource? = this as? RegularTextSource
|
||||
@PreviewFeature
|
||||
inline fun TextSource.requireRegularTextSource(): RegularTextSource = this as RegularTextSource
|
||||
@PreviewFeature
|
||||
inline fun TextSource.asStrikethroughTextSource(): StrikethroughTextSource? = this as? StrikethroughTextSource
|
||||
@PreviewFeature
|
||||
inline fun TextSource.requireStrikethroughTextSource(): StrikethroughTextSource = this as StrikethroughTextSource
|
||||
@PreviewFeature
|
||||
inline fun TextSource.asTextLinkTextSource(): TextLinkTextSource? = this as? TextLinkTextSource
|
||||
@PreviewFeature
|
||||
inline fun TextSource.requireTextLinkTextSource(): TextLinkTextSource = this as TextLinkTextSource
|
||||
@PreviewFeature
|
||||
inline fun TextSource.asTextMentionTextSource(): TextMentionTextSource? = this as? TextMentionTextSource
|
||||
@PreviewFeature
|
||||
inline fun TextSource.requireTextMentionTextSource(): TextMentionTextSource = this as TextMentionTextSource
|
||||
@PreviewFeature
|
||||
inline fun TextSource.asURLTextSource(): URLTextSource? = this as? URLTextSource
|
||||
@PreviewFeature
|
||||
inline fun TextSource.requireURLTextSource(): URLTextSource = this as URLTextSource
|
||||
@PreviewFeature
|
||||
inline fun TextSource.asUnderlineTextSource(): UnderlineTextSource? = this as? UnderlineTextSource
|
||||
@PreviewFeature
|
||||
inline fun TextSource.requireUnderlineTextSource(): UnderlineTextSource = this as UnderlineTextSource
|
||||
|
Loading…
Reference in New Issue
Block a user