mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 16:23:48 +00:00
complete story support
This commit is contained in:
parent
a65971be00
commit
6873c23309
@ -62,6 +62,10 @@ suspend fun BehaviourContext.waitText(
|
|||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
) = waitContent(initRequest, errorFactory).mapContent<TextContent>()
|
) = waitContent(initRequest, errorFactory).mapContent<TextContent>()
|
||||||
|
suspend fun BehaviourContext.waitStory(
|
||||||
|
initRequest: Request<*>? = null,
|
||||||
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
|
) = waitContent(initRequest, errorFactory).mapContent<StoryContent>()
|
||||||
suspend fun BehaviourContext.waitVenue(
|
suspend fun BehaviourContext.waitVenue(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
|
@ -74,6 +74,10 @@ suspend fun BehaviourContext.waitTextMessage(
|
|||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
) = waitContentMessage(initRequest, errorFactory).mapWithContent<TextContent>()
|
) = waitContentMessage(initRequest, errorFactory).mapWithContent<TextContent>()
|
||||||
|
suspend fun BehaviourContext.waitStoryMessage(
|
||||||
|
initRequest: Request<*>? = null,
|
||||||
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
|
) = waitContentMessage(initRequest, errorFactory).mapWithContent<StoryContent>()
|
||||||
suspend fun BehaviourContext.waitVenueMessage(
|
suspend fun BehaviourContext.waitVenueMessage(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
|
@ -248,6 +248,30 @@ suspend fun <BC : BehaviourContext> BC.onText(
|
|||||||
scenarioReceiver
|
scenarioReceiver
|
||||||
)
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
|
||||||
|
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
|
||||||
|
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
|
||||||
|
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
|
||||||
|
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
|
||||||
|
* to combinate several filters
|
||||||
|
* @param [markerFactory] Will be used to identify different "stream". [scenarioReceiver] will be called synchronously
|
||||||
|
* in one "stream". Output of [markerFactory] will be used as a key for "stream"
|
||||||
|
* @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that
|
||||||
|
* data
|
||||||
|
*/
|
||||||
|
suspend fun <BC : BehaviourContext> BC.onStory(
|
||||||
|
initialFilter: CommonMessageFilter<StoryContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, StoryMessage, Update>? = MessageFilterByChat,
|
||||||
|
markerFactory: MarkerFactory<in StoryMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, StoryMessage>
|
||||||
|
) = onContentMessageWithType(
|
||||||
|
initialFilter,
|
||||||
|
subcontextUpdatesFilter,
|
||||||
|
markerFactory,
|
||||||
|
scenarioReceiver
|
||||||
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
|
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
|
||||||
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
|
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
|
||||||
|
@ -11,6 +11,7 @@ typealias DiceMessage = CommonMessage<DiceContent>
|
|||||||
typealias ContactMessage = CommonMessage<ContactContent>
|
typealias ContactMessage = CommonMessage<ContactContent>
|
||||||
typealias PollMessage = CommonMessage<PollContent>
|
typealias PollMessage = CommonMessage<PollContent>
|
||||||
typealias TextMessage = CommonMessage<TextContent>
|
typealias TextMessage = CommonMessage<TextContent>
|
||||||
|
typealias StoryMessage = CommonMessage<StoryContent>
|
||||||
|
|
||||||
typealias LocationMessage = CommonMessage<LocationContent>
|
typealias LocationMessage = CommonMessage<LocationContent>
|
||||||
typealias LiveLocationMessage = CommonMessage<LiveLocationContent>
|
typealias LiveLocationMessage = CommonMessage<LiveLocationContent>
|
||||||
|
@ -292,6 +292,7 @@ import dev.inmo.tgbotapi.types.message.content.ResendableContent
|
|||||||
import dev.inmo.tgbotapi.types.message.content.SpoilerableMediaContent
|
import dev.inmo.tgbotapi.types.message.content.SpoilerableMediaContent
|
||||||
import dev.inmo.tgbotapi.types.message.content.StaticLocationContent
|
import dev.inmo.tgbotapi.types.message.content.StaticLocationContent
|
||||||
import dev.inmo.tgbotapi.types.message.content.StickerContent
|
import dev.inmo.tgbotapi.types.message.content.StickerContent
|
||||||
|
import dev.inmo.tgbotapi.types.message.content.StoryContent
|
||||||
import dev.inmo.tgbotapi.types.message.content.TextContent
|
import dev.inmo.tgbotapi.types.message.content.TextContent
|
||||||
import dev.inmo.tgbotapi.types.message.content.TextedContent
|
import dev.inmo.tgbotapi.types.message.content.TextedContent
|
||||||
import dev.inmo.tgbotapi.types.message.content.TextedMediaContent
|
import dev.inmo.tgbotapi.types.message.content.TextedMediaContent
|
||||||
@ -3480,6 +3481,15 @@ public inline fun ResendableContent.stickerContentOrThrow(): StickerContent = th
|
|||||||
public inline fun <T> ResendableContent.ifStickerContent(block: (StickerContent) -> T): T? =
|
public inline fun <T> ResendableContent.ifStickerContent(block: (StickerContent) -> T): T? =
|
||||||
stickerContentOrNull() ?.let(block)
|
stickerContentOrNull() ?.let(block)
|
||||||
|
|
||||||
|
public inline fun ResendableContent.storyContentOrNull(): StoryContent? = this as?
|
||||||
|
dev.inmo.tgbotapi.types.message.content.StoryContent
|
||||||
|
|
||||||
|
public inline fun ResendableContent.storyContentOrThrow(): StoryContent = this as
|
||||||
|
dev.inmo.tgbotapi.types.message.content.StoryContent
|
||||||
|
|
||||||
|
public inline fun <T> ResendableContent.ifStoryContent(block: (StoryContent) -> T): T? =
|
||||||
|
storyContentOrNull() ?.let(block)
|
||||||
|
|
||||||
public inline fun ResendableContent.textContentOrNull(): TextContent? = this as?
|
public inline fun ResendableContent.textContentOrNull(): TextContent? = this as?
|
||||||
dev.inmo.tgbotapi.types.message.content.TextContent
|
dev.inmo.tgbotapi.types.message.content.TextContent
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ fun Flow<ContentMessage<*>>.onlyPhotoContentMessages() = withContentType<PhotoCo
|
|||||||
fun Flow<ContentMessage<*>>.onlyPollContentMessages() = withContentType<PollContent>()
|
fun Flow<ContentMessage<*>>.onlyPollContentMessages() = withContentType<PollContent>()
|
||||||
fun Flow<ContentMessage<*>>.onlyStickerContentMessages() = withContentType<StickerContent>()
|
fun Flow<ContentMessage<*>>.onlyStickerContentMessages() = withContentType<StickerContent>()
|
||||||
fun Flow<ContentMessage<*>>.onlyTextContentMessages() = withContentType<TextContent>()
|
fun Flow<ContentMessage<*>>.onlyTextContentMessages() = withContentType<TextContent>()
|
||||||
|
fun Flow<ContentMessage<*>>.onlyStoryContentMessages() = withContentType<StoryContent>()
|
||||||
fun Flow<ContentMessage<*>>.onlyVenueContentMessages() = withContentType<VenueContent>()
|
fun Flow<ContentMessage<*>>.onlyVenueContentMessages() = withContentType<VenueContent>()
|
||||||
fun Flow<ContentMessage<*>>.onlyVideoContentMessages() = withContentType<VideoContent>()
|
fun Flow<ContentMessage<*>>.onlyVideoContentMessages() = withContentType<VideoContent>()
|
||||||
fun Flow<ContentMessage<*>>.onlyVideoNoteContentMessages() = withContentType<VideoNoteContent>()
|
fun Flow<ContentMessage<*>>.onlyVideoNoteContentMessages() = withContentType<VideoNoteContent>()
|
||||||
|
@ -120,6 +120,11 @@ fun FlowsUpdatesFilter.textMessages(
|
|||||||
scopeToIncludeChannels: CoroutineScope? = null
|
scopeToIncludeChannels: CoroutineScope? = null
|
||||||
) = filterContentMessages<TextContent>(scopeToIncludeChannels)
|
) = filterContentMessages<TextContent>(scopeToIncludeChannels)
|
||||||
|
|
||||||
|
fun Flow<BaseSentMessageUpdate>.storyMessages() = filterContentMessages<StoryContent>()
|
||||||
|
fun FlowsUpdatesFilter.storyMessages(
|
||||||
|
scopeToIncludeChannels: CoroutineScope? = null
|
||||||
|
) = filterContentMessages<StoryContent>(scopeToIncludeChannels)
|
||||||
|
|
||||||
fun Flow<BaseSentMessageUpdate>.venueMessages() = filterContentMessages<VenueContent>()
|
fun Flow<BaseSentMessageUpdate>.venueMessages() = filterContentMessages<VenueContent>()
|
||||||
fun FlowsUpdatesFilter.venueMessages(
|
fun FlowsUpdatesFilter.venueMessages(
|
||||||
scopeToIncludeChannels: CoroutineScope? = null
|
scopeToIncludeChannels: CoroutineScope? = null
|
||||||
|
Loading…
Reference in New Issue
Block a user