Package dev.inmo.tgbotapi.extensions.utils.updates

Functions

asCommonMessagesFlow
Link copied to clipboard
common
fun <T : BaseSentMessageUpdate> Flow<T>.asCommonMessagesFlow(): Flow<CommonMessage<*>>

Will map incoming BaseSentMessageUpdates to CommonMessage from BaseSentMessageUpdate.data

asContentMessagesFlow
Link copied to clipboard
common
fun <T : BaseSentMessageUpdate> Flow<T>.asContentMessagesFlow(): Flow<ContentMessage<*>>

Will map incoming BaseSentMessageUpdates to ContentMessage from BaseSentMessageUpdate.data

asDataCallbackQueryFlow
Link copied to clipboard
common
fun Flow<CallbackQueryUpdate>.asDataCallbackQueryFlow(): Flow<DataCallbackQuery>
asGameShortNameCallbackQueryFlow
Link copied to clipboard
common
asUnknownCallbackQueryFlow
Link copied to clipboard
common
fun Flow<CallbackQueryUpdate>.asUnknownCallbackQueryFlow(): Flow<UnknownCallbackQueryType>
asUnknownMessagesFlow
Link copied to clipboard
common
fun <T : BaseSentMessageUpdate> Flow<T>.asUnknownMessagesFlow(): Flow<UnknownMessageType>

Will map incoming BaseSentMessageUpdates to UnknownMessageType from BaseSentMessageUpdate.data

chatEvents
Link copied to clipboard
common
inline fun <T : BaseSentMessageUpdate> Flow<T>.chatEvents(): Flow<ChatEventMessage<*>>
convertWithMediaGroupUpdates
Link copied to clipboard
common
fun List<Update>.convertWithMediaGroupUpdates(): List<Update>

Will convert incoming list of updates to list with MediaGroupUpdates

filterBaseMessageUpdatesByChat
Link copied to clipboard
common
fun <T : BaseMessageUpdate> Flow<T>.filterBaseMessageUpdatesByChat(chat: Chat): Flow<T>

Flow.filter incoming BaseMessageUpdates by their ChatId using Chat.id of chat

filterBaseMessageUpdatesByChatId
Link copied to clipboard
common
fun <T : BaseMessageUpdate> Flow<T>.filterBaseMessageUpdatesByChatId(chatId: ChatId): Flow<T>

Flow.filter incoming BaseMessageUpdates by their ChatId

filterCommandsInsideTextMessages
Link copied to clipboard
common
fun <T : BaseSentMessageUpdate> Flow<T>.filterCommandsInsideTextMessages(commandRegex: Regex): Flow<ContentMessage<TextContent>>

Convert incoming dev.inmo.tgbotapi.types.message.abstracts.ContentMessage.content of messages with fullEntitiesList and check that incoming message contains BotCommandTextSource. Besides, it is checking that BotCommandTextSource.command with incoming commandRegex

filterCommandsWithArgs
Link copied to clipboard
common
fun <T : BaseSentMessageUpdate> Flow<T>.filterCommandsWithArgs(commandRegex: Regex): Flow<Pair<ContentMessage<TextContent>, TextSourcesList>>

Convert incoming dev.inmo.tgbotapi.types.message.abstracts.ContentMessage.content of messages with fullEntitiesList and check that incoming message contains first TextSource as BotCommandTextSource. Besides, it is checking that BotCommandTextSource.command with incoming commandRegex and for other TextSource objects used next rules: all incoming text sources will be passed as is, RegularTextSource will be split by " " for several RegularTextSource which will contains not empty args without spaces.

filterExactCommands
Link copied to clipboard
common
fun <T : BaseSentMessageUpdate> Flow<T>.filterExactCommands(commandRegex: Regex): Flow<ContentMessage<TextContent>>

Convert incoming dev.inmo.tgbotapi.types.message.abstracts.ContentMessage.content of messages with fullEntitiesList and check that incoming message contains ONLY ONE TextSource and that is BotCommandTextSource. Besides, it is checking that BotCommandTextSource.command with incoming commandRegex

filterSentMediaGroupUpdatesByChat
Link copied to clipboard
common
fun <T : SentMediaGroupUpdate> Flow<T>.filterSentMediaGroupUpdatesByChat(chat: Chat): Flow<T>

Flow.filter incoming SentMediaGroupUpdates by their ChatId using Chat.id of chat

filterSentMediaGroupUpdatesByChatId
Link copied to clipboard
common
fun <T : SentMediaGroupUpdate> Flow<T>.filterSentMediaGroupUpdatesByChatId(chatId: ChatId): Flow<T>

Flow.filter incoming SentMediaGroupUpdates by their ChatId

flowsUpdatesFilter
Link copied to clipboard
common
inline fun flowsUpdatesFilter(internalChannelsSizes: Int = 100, block: FlowsUpdatesFilter.() -> Unit): FlowsUpdatesFilter

Non-suspendable function for easy-to-use creating of FlowsUpdatesFilter and applying the block to it

lastUpdateIdentifier
Link copied to clipboard
common
fun Update.lastUpdateIdentifier(): UpdateIdentifier
fun List<Update>.lastUpdateIdentifier(): UpdateIdentifier?
onlyBaseChosenInlineResults
Link copied to clipboard
common
onlyBaseInlineQueries
Link copied to clipboard
common
fun Flow<InlineQueryUpdate>.onlyBaseInlineQueries(): Flow<BaseInlineQuery>
onlyBaseInlineQueriesWithUpdates
Link copied to clipboard
common
onlyBaseMessageUpdates
Link copied to clipboard
common
fun Flow<Update>.onlyBaseMessageUpdates(): Flow<BaseMessageUpdate>
onlyEditMediaGroupUpdates
Link copied to clipboard
common
fun Flow<MediaGroupUpdate>.onlyEditMediaGroupUpdates(): Flow<EditMediaGroupUpdate>

Converts flow to Flow of EditMediaGroupUpdate

onlyEditMessageUpdates
Link copied to clipboard
common
fun Flow<BaseMessageUpdate>.onlyEditMessageUpdates(): Flow<BaseEditMessageUpdate>

Converts flow to Flow of BaseSentMessageUpdate

onlyLocationChosenInlineResults
Link copied to clipboard
common
onlyLocationInlineQueries
Link copied to clipboard
common
fun Flow<InlineQueryUpdate>.onlyLocationInlineQueries(): Flow<LocationInlineQuery>
onlyLocationInlineQueriesWithUpdates
Link copied to clipboard
onlyMediaGroupsUpdates
Link copied to clipboard
common
fun Flow<BaseMessageUpdate>.onlyMediaGroupsUpdates(): Flow<MediaGroupUpdate>

Converts flow to Flow of MediaGroupUpdate. Please, remember that it could be either EditMediaGroupUpdate or SentMediaGroupUpdate

onlySentMediaGroupUpdates
Link copied to clipboard
common
fun Flow<MediaGroupUpdate>.onlySentMediaGroupUpdates(): Flow<SentMediaGroupUpdate>

Converts flow to Flow of SentMediaGroupUpdate

onlySentMessageUpdates
Link copied to clipboard
common
fun Flow<BaseMessageUpdate>.onlySentMessageUpdates(): Flow<BaseSentMessageUpdate>

Converts flow to Flow of BaseSentMessageUpdate

passportMessages
Link copied to clipboard
common
inline fun <T : BaseSentMessageUpdate> Flow<T>.passportMessages(): Flow<PassportMessage>
toEditMediaGroupUpdate
Link copied to clipboard
common
toSentMediaGroupUpdate
Link copied to clipboard
common
toTelegramUpdate
Link copied to clipboard
common
fun String.toTelegramUpdate(): Update
fun JsonElement.toTelegramUpdate(): Update
fun Json.toTelegramUpdate(source: String): Update
fun Json.toTelegramUpdate(source: JsonElement): Update