mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-24 19:18:44 +00:00
Compare commits
No commits in common. "a87c21273d653e11a7d4da9820345f75b6283bcd" and "08ef146daa771bb72d9b62db684a9d16880c6d7e" have entirely different histories.
a87c21273d
...
08ef146daa
@ -5,8 +5,6 @@
|
||||
* `Core`:
|
||||
* Fixes in `mention` creation
|
||||
* Deprecate `StorageFileInfo`
|
||||
* `BehaviourBuilder`:
|
||||
* In the expectations a lot of `on*Message` extensions have been added (like `onContentMessage`). These extensions could be useful when with the `Content` its message info is important
|
||||
|
||||
## 0.38.12
|
||||
|
||||
|
@ -23,7 +23,7 @@ import kotlinx.coroutines.flow.toList
|
||||
|
||||
typealias CommonMessageToContentMapper<T> = suspend CommonMessage<T>.() -> T?
|
||||
|
||||
private suspend fun <O> BehaviourContext.waitCommonContent(
|
||||
private suspend fun <O> BehaviourContext.waitCommonMessage(
|
||||
count: Int = 1,
|
||||
initRequest: Request<*>? = null,
|
||||
includeMediaGroups: Boolean = true,
|
||||
@ -77,7 +77,7 @@ private suspend inline fun <reified T : MessageContent> BehaviourContext.waitCon
|
||||
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
||||
noinline filter: SimpleFilter<CommonMessage<T>>? = null,
|
||||
noinline mapper: CommonMessageToContentMapper<T>? = null
|
||||
) : List<T> = waitCommonContent<T>(
|
||||
) : List<T> = waitCommonMessage<T>(
|
||||
count,
|
||||
initRequest,
|
||||
includeMediaGroups,
|
||||
@ -90,8 +90,7 @@ private suspend inline fun <reified T : MessageContent> BehaviourContext.waitCon
|
||||
contentConverter(mapper)
|
||||
).toList()
|
||||
|
||||
|
||||
suspend fun BehaviourContext.waitContent(
|
||||
suspend fun BehaviourContext.waitContentMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
|
@ -1,281 +0,0 @@
|
||||
@file:Suppress("unused")
|
||||
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||
|
||||
import dev.inmo.micro_utils.coroutines.safelyWithoutExceptions
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||
import dev.inmo.tgbotapi.extensions.utils.withContent
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.*
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.*
|
||||
import dev.inmo.tgbotapi.types.message.content.media.*
|
||||
import dev.inmo.tgbotapi.types.message.content.media.AudioMediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.message.content.media.DocumentMediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.message.content.media.MediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.message.content.media.VisualMediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.message.payments.InvoiceContent
|
||||
import dev.inmo.tgbotapi.types.update.MediaGroupUpdates.SentMediaGroupUpdate
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.toList
|
||||
|
||||
typealias CommonMessageToCommonMessageMapper<T> = suspend CommonMessage<T>.() -> CommonMessage<T>?
|
||||
|
||||
internal suspend fun <O : MessageContent> BehaviourContext.waitCommonMessage(
|
||||
count: Int = 1,
|
||||
initRequest: Request<*>? = null,
|
||||
includeMediaGroups: Boolean = true,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
filter: SimpleFilter<CommonMessage<MessageContent>>? = null,
|
||||
mapper: suspend CommonMessage<MessageContent>.() -> CommonMessage<O>?
|
||||
): Flow<CommonMessage<O>> = expectFlow(
|
||||
initRequest,
|
||||
count,
|
||||
errorFactory
|
||||
) {
|
||||
val messages = when (it) {
|
||||
is SentMediaGroupUpdate -> {
|
||||
if (includeMediaGroups) {
|
||||
it.data.map { it as CommonMessage<MessageContent> }
|
||||
} else {
|
||||
emptyList()
|
||||
}
|
||||
}
|
||||
is BaseSentMessageUpdate -> listOf(it.data)
|
||||
else -> return@expectFlow emptyList()
|
||||
}
|
||||
messages.mapNotNull { message ->
|
||||
val asCommonMessage = message as CommonMessage<MessageContent>
|
||||
if (filter == null || filter(asCommonMessage)) {
|
||||
asCommonMessage.mapper()
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal inline fun <reified T : MessageContent> contentMessageConverter(
|
||||
noinline mapper: CommonMessageToCommonMessageMapper<T>? = null
|
||||
): suspend CommonMessage<MessageContent>.() -> CommonMessage<T>? = mapper ?.let {
|
||||
{
|
||||
if (content is T) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val message = (this as CommonMessage<T>)
|
||||
safelyWithoutExceptions { mapper(message) }
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
} ?: {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
if (content is T) this as CommonMessage<T> else null
|
||||
}
|
||||
|
||||
private suspend inline fun <reified T : MessageContent> BehaviourContext.waitContentMessage(
|
||||
count: Int = 1,
|
||||
initRequest: Request<*>? = null,
|
||||
includeMediaGroups: Boolean = true,
|
||||
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
||||
noinline filter: SimpleFilter<CommonMessage<T>>? = null,
|
||||
noinline mapper: CommonMessageToCommonMessageMapper<T>? = null
|
||||
) : List<CommonMessage<T>> = waitCommonMessage<T>(
|
||||
count,
|
||||
initRequest,
|
||||
includeMediaGroups,
|
||||
errorFactory,
|
||||
filter ?.let {
|
||||
{
|
||||
it.withContent<T>() ?.let { filter(it) } == true
|
||||
}
|
||||
},
|
||||
contentMessageConverter(mapper)
|
||||
).toList()
|
||||
|
||||
suspend fun BehaviourContext.waitContentMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
includeMediaGroups: Boolean = true,
|
||||
filter: SimpleFilter<CommonMessage<MessageContent>>? = null,
|
||||
mapper: CommonMessageToCommonMessageMapper<MessageContent>? = null
|
||||
) = waitContentMessage(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitContactMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonMessage<ContactContent>>? = null,
|
||||
mapper: CommonMessageToCommonMessageMapper<ContactContent>? = null
|
||||
) = waitContentMessage(count, initRequest, false, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitDiceMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonMessage<DiceContent>>? = null,
|
||||
mapper: CommonMessageToCommonMessageMapper<DiceContent>? = null
|
||||
) = waitContentMessage(count, initRequest, false, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitGameMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonMessage<GameContent>>? = null,
|
||||
mapper: CommonMessageToCommonMessageMapper<GameContent>? = null
|
||||
) = waitContentMessage(count, initRequest, false, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitLocationMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonMessage<LocationContent>>? = null,
|
||||
mapper: CommonMessageToCommonMessageMapper<LocationContent>? = null
|
||||
) = waitContentMessage(count, initRequest, false, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitLiveLocationMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonMessage<LiveLocationContent>>? = null,
|
||||
mapper: CommonMessageToCommonMessageMapper<LiveLocationContent>? = null
|
||||
) = waitContentMessage(count, initRequest, false, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitStaticLocationMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonMessage<StaticLocationContent>>? = null,
|
||||
mapper: CommonMessageToCommonMessageMapper<StaticLocationContent>? = null
|
||||
) = waitContentMessage(count, initRequest, false, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitPollMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonMessage<PollContent>>? = null,
|
||||
mapper: CommonMessageToCommonMessageMapper<PollContent>? = null
|
||||
) = waitContentMessage(count, initRequest, false, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitTextMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonMessage<TextContent>>? = null,
|
||||
mapper: CommonMessageToCommonMessageMapper<TextContent>? = null
|
||||
) = waitContentMessage(count, initRequest, false, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitVenueMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonMessage<VenueContent>>? = null,
|
||||
mapper: CommonMessageToCommonMessageMapper<VenueContent>? = null
|
||||
) = waitContentMessage(count, initRequest, false, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitAudioMediaGroupContentMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
includeMediaGroups: Boolean = true,
|
||||
filter: SimpleFilter<CommonMessage<AudioMediaGroupContent>>? = null,
|
||||
mapper: CommonMessageToCommonMessageMapper<AudioMediaGroupContent>? = null
|
||||
) = waitContentMessage(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitDocumentMediaGroupContentMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
includeMediaGroups: Boolean = true,
|
||||
filter: SimpleFilter<CommonMessage<DocumentMediaGroupContent>>? = null,
|
||||
mapper: CommonMessageToCommonMessageMapper<DocumentMediaGroupContent>? = null
|
||||
) = waitContentMessage(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitMediaMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
includeMediaGroups: Boolean = false,
|
||||
filter: SimpleFilter<CommonMessage<MediaContent>>? = null,
|
||||
mapper: CommonMessageToCommonMessageMapper<MediaContent>? = null
|
||||
) = waitContentMessage(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitAnyMediaGroupContentMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
includeMediaGroups: Boolean = true,
|
||||
filter: SimpleFilter<CommonMessage<MediaGroupContent>>? = null,
|
||||
mapper: CommonMessageToCommonMessageMapper<MediaGroupContent>? = null
|
||||
) = waitContentMessage(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitVisualMediaGroupContentMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
includeMediaGroups: Boolean = true,
|
||||
filter: SimpleFilter<CommonMessage<VisualMediaGroupContent>>? = null,
|
||||
mapper: CommonMessageToCommonMessageMapper<VisualMediaGroupContent>? = null
|
||||
) = waitContentMessage(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitTextedMediaContentMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
includeMediaGroups: Boolean = true,
|
||||
filter: SimpleFilter<CommonMessage<TextedMediaContent>>? = null,
|
||||
mapper: CommonMessageToCommonMessageMapper<TextedMediaContent>? = null
|
||||
) = waitContentMessage(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitAnimationMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonMessage<AnimationContent>>? = null,
|
||||
mapper: CommonMessageToCommonMessageMapper<AnimationContent>? = null
|
||||
) = waitContentMessage(count, initRequest, false, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitAudioMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
includeMediaGroups: Boolean = false,
|
||||
filter: SimpleFilter<CommonMessage<AudioContent>>? = null,
|
||||
mapper: CommonMessageToCommonMessageMapper<AudioContent>? = null
|
||||
) = waitContentMessage(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitDocumentMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
includeMediaGroups: Boolean = false,
|
||||
filter: SimpleFilter<CommonMessage<DocumentContent>>? = null,
|
||||
mapper: CommonMessageToCommonMessageMapper<DocumentContent>? = null
|
||||
) = waitContentMessage(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitPhotoMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
includeMediaGroups: Boolean = false,
|
||||
filter: SimpleFilter<CommonMessage<PhotoContent>>? = null,
|
||||
mapper: CommonMessageToCommonMessageMapper<PhotoContent>? = null
|
||||
) = waitContentMessage(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitStickerMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonMessage<StickerContent>>? = null,
|
||||
mapper: CommonMessageToCommonMessageMapper<StickerContent>? = null
|
||||
) = waitContentMessage(count, initRequest, false, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitVideoMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
includeMediaGroups: Boolean = false,
|
||||
filter: SimpleFilter<CommonMessage<VideoContent>>? = null,
|
||||
mapper: CommonMessageToCommonMessageMapper<VideoContent>? = null
|
||||
) = waitContentMessage(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitVideoNoteMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonMessage<VideoNoteContent>>? = null,
|
||||
mapper: CommonMessageToCommonMessageMapper<VideoNoteContent>? = null
|
||||
) = waitContentMessage(count, initRequest, false, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitVoiceMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonMessage<VoiceContent>>? = null,
|
||||
mapper: CommonMessageToCommonMessageMapper<VoiceContent>? = null
|
||||
) = waitContentMessage(count, initRequest, false, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitInvoiceMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<CommonMessage<InvoiceContent>>? = null,
|
||||
mapper: CommonMessageToCommonMessageMapper<InvoiceContent>? = null
|
||||
) = waitContentMessage(count, initRequest, false, errorFactory, filter, mapper)
|
@ -24,7 +24,7 @@ import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||
typealias CommonMessageFilter<T> = SimpleFilter<CommonMessage<T>>
|
||||
inline fun <T : MessageContent> CommonMessageFilter(noinline block: CommonMessageFilter<T>) = block
|
||||
|
||||
internal suspend inline fun <BC : BehaviourContext, reified T : MessageContent> BC.onContentMessageWithType(
|
||||
internal suspend inline fun <BC : BehaviourContext, reified T : MessageContent> BC.onContent(
|
||||
noinline initialFilter: CommonMessageFilter<T>? = null,
|
||||
noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<T>, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<T>, Any> = ByChatMessageMarkerFactory,
|
||||
@ -57,7 +57,7 @@ suspend fun <BC : BehaviourContext> BC.onContentMessage(
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<MessageContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<MessageContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<MessageContent>>
|
||||
) = onContentMessageWithType(
|
||||
) = onContent(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
markerFactory,
|
||||
@ -81,7 +81,7 @@ suspend fun <BC : BehaviourContext> BC.onContact(
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<ContactContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<ContactContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<ContactContent>>
|
||||
) = onContentMessageWithType(
|
||||
) = onContent(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
markerFactory,
|
||||
@ -105,7 +105,7 @@ suspend fun <BC : BehaviourContext> BC.onDice(
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<DiceContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<DiceContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<DiceContent>>
|
||||
) = onContentMessageWithType(
|
||||
) = onContent(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
markerFactory,
|
||||
@ -129,7 +129,7 @@ suspend fun <BC : BehaviourContext> BC.onGame(
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<GameContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<GameContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<GameContent>>
|
||||
) = onContentMessageWithType(
|
||||
) = onContent(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
markerFactory,
|
||||
@ -153,7 +153,7 @@ suspend fun <BC : BehaviourContext> BC.onLocation(
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<LocationContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<LocationContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<LocationContent>>
|
||||
) = onContentMessageWithType(
|
||||
) = onContent(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
markerFactory,
|
||||
@ -177,7 +177,7 @@ suspend fun <BC : BehaviourContext> BC.onLiveLocation(
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<LiveLocationContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<LiveLocationContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<LiveLocationContent>>
|
||||
) = onContentMessageWithType(
|
||||
) = onContent(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
markerFactory,
|
||||
@ -201,7 +201,7 @@ suspend fun <BC : BehaviourContext> BC.onStaticLocation(
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<StaticLocationContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<StaticLocationContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<StaticLocationContent>>
|
||||
) = onContentMessageWithType(
|
||||
) = onContent(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
markerFactory,
|
||||
@ -225,7 +225,7 @@ suspend fun <BC : BehaviourContext> BC.onPoll(
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<PollContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<PollContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<PollContent>>
|
||||
) = onContentMessageWithType(
|
||||
) = onContent(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
markerFactory,
|
||||
@ -249,7 +249,7 @@ suspend fun <BC : BehaviourContext> BC.onText(
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<TextContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<TextContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<TextContent>>
|
||||
) = onContentMessageWithType(
|
||||
) = onContent(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
markerFactory,
|
||||
@ -273,7 +273,7 @@ suspend fun <BC : BehaviourContext> BC.onVenue(
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<VenueContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<VenueContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<VenueContent>>
|
||||
) = onContentMessageWithType(
|
||||
) = onContent(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
markerFactory,
|
||||
@ -297,7 +297,7 @@ suspend fun <BC : BehaviourContext> BC.onAudioMediaGroup(
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<AudioMediaGroupContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<AudioMediaGroupContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<AudioMediaGroupContent>>
|
||||
) = onContentMessageWithType(
|
||||
) = onContent(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
markerFactory,
|
||||
@ -321,7 +321,7 @@ suspend fun <BC : BehaviourContext> BC.onDocumentMediaGroupContent(
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<DocumentMediaGroupContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<DocumentMediaGroupContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<DocumentMediaGroupContent>>
|
||||
) = onContentMessageWithType(
|
||||
) = onContent(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
markerFactory,
|
||||
@ -345,7 +345,7 @@ suspend fun <BC : BehaviourContext> BC.onTextedMediaContent(
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<TextedMediaContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<TextedMediaContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<TextedMediaContent>>
|
||||
) = onContentMessageWithType(
|
||||
) = onContent(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
markerFactory,
|
||||
@ -369,7 +369,7 @@ suspend fun <BC : BehaviourContext> BC.onMediaCollection(
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<MediaCollectionContent<TelegramMediaFile>>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<MediaCollectionContent<TelegramMediaFile>>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<MediaCollectionContent<TelegramMediaFile>>>
|
||||
) = onContentMessageWithType(
|
||||
) = onContent(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
markerFactory,
|
||||
@ -393,7 +393,7 @@ suspend fun <BC : BehaviourContext> BC.onMedia(
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<MediaContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<MediaContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<MediaContent>>
|
||||
) = onContentMessageWithType(
|
||||
) = onContent(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
markerFactory,
|
||||
@ -417,7 +417,7 @@ suspend fun <BC : BehaviourContext> BC.onAnimation(
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<AnimationContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<AnimationContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<AnimationContent>>
|
||||
) = onContentMessageWithType(
|
||||
) = onContent(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
markerFactory,
|
||||
@ -441,7 +441,7 @@ suspend fun <BC : BehaviourContext> BC.onAudio(
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<AudioContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<AudioContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<AudioContent>>
|
||||
) = onContentMessageWithType(
|
||||
) = onContent(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
markerFactory,
|
||||
@ -465,7 +465,7 @@ suspend fun <BC : BehaviourContext> BC.onDocument(
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<DocumentContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<DocumentContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<DocumentContent>>
|
||||
) = onContentMessageWithType(
|
||||
) = onContent(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
markerFactory,
|
||||
@ -489,7 +489,7 @@ suspend fun <BC : BehaviourContext> BC.onPhoto(
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<PhotoContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<PhotoContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<PhotoContent>>
|
||||
) = onContentMessageWithType(
|
||||
) = onContent(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
markerFactory,
|
||||
@ -513,7 +513,7 @@ suspend fun <BC : BehaviourContext> BC.onSticker(
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<StickerContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<StickerContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<StickerContent>>
|
||||
) = onContentMessageWithType(
|
||||
) = onContent(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
markerFactory,
|
||||
@ -537,7 +537,7 @@ suspend fun <BC : BehaviourContext> BC.onVideo(
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<VideoContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<VideoContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<VideoContent>>
|
||||
) = onContentMessageWithType(
|
||||
) = onContent(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
markerFactory,
|
||||
@ -561,7 +561,7 @@ suspend fun <BC : BehaviourContext> BC.onVideoNote(
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<VideoNoteContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<VideoNoteContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<VideoNoteContent>>
|
||||
) = onContentMessageWithType(
|
||||
) = onContent(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
markerFactory,
|
||||
@ -585,7 +585,7 @@ suspend fun <BC : BehaviourContext> BC.onVoice(
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<VoiceContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<VoiceContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<VoiceContent>>
|
||||
) = onContentMessageWithType(
|
||||
) = onContent(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
markerFactory,
|
||||
@ -609,7 +609,7 @@ suspend fun <BC : BehaviourContext> BC.onInvoice(
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<InvoiceContent>, Update> = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in CommonMessage<InvoiceContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<InvoiceContent>>
|
||||
) = onContentMessageWithType(
|
||||
) = onContent(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
markerFactory,
|
||||
|
@ -58,7 +58,7 @@ class KtorRequestsExecutor(
|
||||
excludeDefaultFactories: Boolean = false,
|
||||
private val requestsLimiter: RequestLimiter = ExceptionsOnlyLimiter(),
|
||||
private val jsonFormatter: Json = nonstrictJsonFormat,
|
||||
private val pipelineStepsHolder: KtorPipelineStepsHolder = KtorPipelineStepsHolder
|
||||
private val pipelineStepsHolder: KtorPipelineStepsHolder = TODO()
|
||||
) : BaseRequestsExecutor(telegramAPIUrlsKeeper) {
|
||||
private val callsFactories: List<KtorCallFactory> = callsFactories.run {
|
||||
if (!excludeDefaultFactories) {
|
||||
|
@ -70,6 +70,4 @@ interface KtorPipelineStepsHolder {
|
||||
request: Request<T>,
|
||||
callsFactories: List<KtorCallFactory>
|
||||
): T = result.getOrThrow()
|
||||
|
||||
companion object : KtorPipelineStepsHolder
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user