docs / com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.updates / kotlinx.coroutines.flow.Flow

Extensions for kotlinx.coroutines.flow.Flow

(common)

asChatEventsFlow

Will map incoming BaseSentMessageUpdates to ChatEventMessage from BaseSentMessageUpdate.data

fun <T : BaseSentMessageUpdate> Flow<T>.asChatEventsFlow(): Flow<ChatEventMessage>
(common)

asContentMessagesFlow

Will map incoming BaseSentMessageUpdates to ContentMessage from BaseSentMessageUpdate.data

fun <T : BaseSentMessageUpdate> Flow<T>.asContentMessagesFlow(): Flow<ContentMessage<*>>
(common)

asDataCallbackQueryFlow

fun Flow<CallbackQueryUpdate>.asDataCallbackQueryFlow(): Flow<DataCallbackQuery>
(common)

asGameShortNameCallbackQueryFlow

fun Flow<CallbackQueryUpdate>.asGameShortNameCallbackQueryFlow(): Flow<GameShortNameCallbackQuery>
(common)

asUnknownCallbackQueryFlow

fun Flow<CallbackQueryUpdate>.asUnknownCallbackQueryFlow(): Flow<UnknownCallbackQueryType>
(common)

asUnknownMessagesFlow

Will map incoming BaseSentMessageUpdates to UnknownMessageType from BaseSentMessageUpdate.data

fun <T : BaseSentMessageUpdate> Flow<T>.asUnknownMessagesFlow(): Flow<UnknownMessageType>
(common)

filterBaseMessageUpdates

Flow.filter incoming BaseMessageUpdates by their ChatId

fun <T : BaseMessageUpdate> Flow<T>.filterBaseMessageUpdates(chatId: ChatId): Flow<T>

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

fun <T : BaseMessageUpdate> Flow<T>.filterBaseMessageUpdates(chat: Chat): Flow<T>
(common)

filterCommandsInsideTextMessages

Convert incoming com.github.insanusmokrassar.TelegramBotAPI.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

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

filterCommandsWithArgs

Convert incoming com.github.insanusmokrassar.TelegramBotAPI.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.

fun <T : BaseSentMessageUpdate> Flow<T>.filterCommandsWithArgs(commandRegex: Regex): Flow<List<TextSource>>
(common)

filterExactCommands

Convert incoming com.github.insanusmokrassar.TelegramBotAPI.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

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

filterSentMediaGroupUpdates

Flow.filter incoming SentMediaGroupUpdates by their ChatId

fun <T : SentMediaGroupUpdate> Flow<T>.filterSentMediaGroupUpdates(chatId: ChatId): Flow<T>

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

fun <T : SentMediaGroupUpdate> Flow<T>.filterSentMediaGroupUpdates(chat: Chat): Flow<T>