1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-22 16:23:48 +00:00

fix build

This commit is contained in:
InsanusMokrassar 2021-08-06 12:02:26 +06:00
parent ed077ae1bc
commit 96d980cb8a
6 changed files with 31 additions and 19 deletions

View File

@ -35,23 +35,23 @@ private suspend inline fun <reified T : CallbackQuery> BehaviourContext.waitCall
count: Int = 1, count: Int = 1,
initRequest: Request<*>? = null, initRequest: Request<*>? = null,
noinline errorFactory: NullableRequestBuilder<*> = { null }, noinline errorFactory: NullableRequestBuilder<*> = { null },
filter: SimpleFilter<T>? = null, noinline filter: SimpleFilter<T>? = null,
noinline filter: CallbackQueryMapper<T>? = null noinline mapper: CallbackQueryMapper<T>? = null
) : List<T> = waitCallbackQueries<T>( ) : List<T> = waitCallbackQueries<T>(
count, count,
initRequest, initRequest,
errorFactory, errorFactory,
filter ?.let { filter ?.let {
{ {
(it as? T) ?.let(::filter) (it as? T) ?.let { filter(it) } == true
} }
} }
) { ) {
if (this is T) { if (this is T) {
if (filter == null) { if (mapper == null) {
this this
} else { } else {
filter(this) mapper(this)
} }
} else { } else {
null null

View File

@ -15,16 +15,16 @@ private suspend inline fun <reified T : ChatMemberUpdatedUpdate> BehaviourContex
count: Int = 1, count: Int = 1,
initRequest: Request<*>? = null, initRequest: Request<*>? = null,
noinline errorFactory: NullableRequestBuilder<*> = { null }, noinline errorFactory: NullableRequestBuilder<*> = { null },
filter: SimpleFilter<T>? = null, noinline filter: SimpleFilter<T>? = null,
noinline mapper: ChatMemberUpdatedMapper<ChatMemberUpdated> noinline mapper: ChatMemberUpdatedMapper<ChatMemberUpdated>
): List<ChatMemberUpdated> = expectFlow( ): List<ChatMemberUpdated> = expectFlow(
initRequest, initRequest,
count, count,
errorFactory errorFactory
) { ) {
val data = (it as? T) ?.data ?: return@expectFlow emptyList() val casted = (it as? T) ?: return@expectFlow emptyList()
if (filter == null || filter(data)) { if (filter == null || filter(casted)) {
data.mapper().let(::listOfNotNull) casted.data.mapper().let(::listOfNotNull)
} else { } else {
emptyList() emptyList()
} }
@ -34,7 +34,7 @@ private suspend inline fun <reified T : ChatMemberUpdatedUpdate> BehaviourContex
count: Int = 1, count: Int = 1,
initRequest: Request<*>? = null, initRequest: Request<*>? = null,
noinline errorFactory: NullableRequestBuilder<*> = { null }, noinline errorFactory: NullableRequestBuilder<*> = { null },
filter: SimpleFilter<T>? = null, noinline filter: SimpleFilter<T>? = null,
noinline mapper: ChatMemberUpdatedMapper<ChatMemberUpdated>? = null noinline mapper: ChatMemberUpdatedMapper<ChatMemberUpdated>? = null
) : List<ChatMemberUpdated> = waitChatMemberUpdated<T>( ) : List<ChatMemberUpdated> = waitChatMemberUpdated<T>(
count, count,

View File

@ -56,14 +56,18 @@ private suspend inline fun <reified T : MessageContent> BehaviourContext.waitCon
initRequest: Request<*>? = null, initRequest: Request<*>? = null,
includeMediaGroups: Boolean = true, includeMediaGroups: Boolean = true,
noinline errorFactory: NullableRequestBuilder<*> = { null }, noinline errorFactory: NullableRequestBuilder<*> = { null },
filter: SimpleFilter<CommonMessage<T>>? = null, noinline filter: SimpleFilter<CommonMessage<T>>? = null,
noinline mapper: CommonMessageToContentMapper<T>? = null noinline mapper: CommonMessageToContentMapper<T>? = null
) : List<T> = waitCommonMessage<T>( ) : List<T> = waitCommonMessage<T>(
count, count,
initRequest, initRequest,
includeMediaGroups, includeMediaGroups,
errorFactory, errorFactory,
filter filter ?.let {
{
it.withContent<T>() ?.let { filter(it) } == true
}
}
) { ) {
if (content is T) { if (content is T) {
@Suppress("UNCHECKED_CAST") @Suppress("UNCHECKED_CAST")

View File

@ -39,13 +39,17 @@ private suspend inline fun <reified T : ChatEvent> BehaviourContext.waitEvents(
count: Int = 1, count: Int = 1,
initRequest: Request<*>? = null, initRequest: Request<*>? = null,
noinline errorFactory: NullableRequestBuilder<*> = { null }, noinline errorFactory: NullableRequestBuilder<*> = { null },
filter: SimpleFilter<ChatEventMessage<T>>? = null, noinline filter: SimpleFilter<ChatEventMessage<T>>? = null,
noinline mapper: EventMessageToEventMapper<T>? = null noinline mapper: EventMessageToEventMapper<T>? = null
) : List<T> = waitEventMessages<T>( ) : List<T> = waitEventMessages<T>(
initRequest, initRequest,
errorFactory, errorFactory,
count, count,
filter filter ?.let {
{
(it.chatEvent as? T) ?.let { filter(it as ChatEventMessage<T>) } == true
}
}
) { ) {
if (chatEvent is T) { if (chatEvent is T) {
@Suppress("UNCHECKED_CAST") @Suppress("UNCHECKED_CAST")

View File

@ -33,19 +33,23 @@ private suspend inline fun <reified T : InlineQuery> BehaviourContext.waitInline
count: Int = 1, count: Int = 1,
initRequest: Request<*>? = null, initRequest: Request<*>? = null,
noinline errorFactory: NullableRequestBuilder<*> = { null }, noinline errorFactory: NullableRequestBuilder<*> = { null },
filter: SimpleFilter<InlineQuery>? = null, noinline filter: SimpleFilter<T>? = null,
noinline mapper: InlineQueryMapper<T>? = null noinline mapper: InlineQueryMapper<T>? = null
) : List<T> = waitInlineQueries<T>( ) : List<T> = waitInlineQueries<T>(
count, count,
initRequest, initRequest,
errorFactory, errorFactory,
filter filter ?.let {
{
(it as? T) ?.let { casted -> filter(casted) } == true
}
}
) { ) {
if (this is T) { if (this is T) {
if (filter == null) { if (mapper == null) {
this this
} else { } else {
filter(this) mapper(this)
} }
} else { } else {
null null

View File

@ -37,7 +37,7 @@ suspend inline fun <reified T : EncryptedPassportElement> BehaviourContext.waitP
count: Int = 1, count: Int = 1,
initRequest: Request<*>? = null, initRequest: Request<*>? = null,
noinline errorFactory: NullableRequestBuilder<*> = { null }, noinline errorFactory: NullableRequestBuilder<*> = { null },
filter: SimpleFilter<PassportMessage>? = null, noinline filter: SimpleFilter<PassportMessage>? = null,
noinline mapper: PassportMessageMapper? = null noinline mapper: PassportMessageMapper? = null
) : List<PassportData> = waitPassportMessages( ) : List<PassportData> = waitPassportMessages(
initRequest, initRequest,