1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-12-23 00:57:13 +00:00

remove deprecations

This commit is contained in:
InsanusMokrassar 2021-11-08 17:33:02 +06:00
parent 10c62bf2c7
commit 44e9dc9253
8 changed files with 4 additions and 82 deletions

View File

@ -27,7 +27,7 @@ expect var defaultCoroutineScopeProvider: () -> CoroutineScope
*/
@PreviewFeature
suspend fun TelegramBot.buildBehaviour(
flowUpdatesFilter: FlowsUpdatesFilter,
flowUpdatesFilter: FlowsUpdatesFilter = FlowsUpdatesFilter(),
scope: CoroutineScope = defaultCoroutineScopeProvider(),
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
block: BehaviourContextReceiver<Unit>
@ -70,11 +70,3 @@ suspend fun TelegramBot.buildBehaviourWithLongPolling(
scope = scope
)
}
@PreviewFeature
@Deprecated("Renamed to buildBehaviourWithLongPolling")
suspend fun TelegramBot.buildBehaviour(
scope: CoroutineScope = defaultCoroutineScopeProvider(),
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
block: BehaviourContextReceiver<Unit>
) = buildBehaviourWithLongPolling(scope, defaultExceptionsHandler, block)

View File

@ -55,13 +55,6 @@ interface BehaviourContext : FlowsUpdatesFilter, TelegramBot, CoroutineScope {
upstreamUpdatesFlow: Flow<Update>? = null,
updatesFilter: BehaviourContextAndTypeReceiver<Boolean, Update>? = null
): BehaviourContext
@Deprecated("This method is not recommended to use and will be removed in near release")
fun copy(
bot: TelegramBot,
scope: CoroutineScope = this.scope,
flowsUpdatesFilter: FlowsUpdatesFilter = this.flowsUpdatesFilter
): BehaviourContext = copy(upstreamUpdatesFlow = flowsUpdatesFilter.allUpdatesFlow)
}
class DefaultBehaviourContext(
@ -113,30 +106,6 @@ inline fun <T> BehaviourContext(
crossinline block: BehaviourContext.() -> T
) = DefaultBehaviourContext(bot, scope, upstreamUpdatesFlow = flowsUpdatesFilter.allUpdatesFlow).run(block)
/**
* Creates new one [BehaviourContext], adding subsequent [FlowsUpdatesFilter] in case [newFlowsUpdatesFilterSetUp] is provided and
* [CoroutineScope] as new [BehaviourContext.scope]. You must do all subscription/running of longPolling manually.
*
* @param newFlowsUpdatesFilterSetUp As a parameter receives [FlowsUpdatesFilter] from old [this] [BehaviourContext.flowsUpdatesFilter]
*/
@RiskFeature("It is recommended to use doInSubContextWithUpdatesFilter instead. " +
"This method is low level and should not be used in case you are not pretty sure you need it.")
@Deprecated("This method is useless and will not be used in future")
suspend fun <T, BC : BehaviourContext> BC.doInSubContextWithFlowsUpdatesFilterSetup(
newFlowsUpdatesFilterSetUp: CustomBehaviourContextAndTypeReceiver<BC, Unit, FlowsUpdatesFilter>?,
stopOnCompletion: Boolean = true,
behaviourContextReceiver: CustomBehaviourContextReceiver<BC, T>
): T = (copy(
scope = LinkedSupervisorScope(),
) as BC).run {
withContext(coroutineContext) {
newFlowsUpdatesFilterSetUp ?.let {
it.apply { invoke(this@run, this@doInSubContextWithFlowsUpdatesFilterSetup.flowsUpdatesFilter) }
}
behaviourContextReceiver().also { if (stopOnCompletion) stop() }
}
}
/**
* Creates new one [BehaviourContext], adding subsequent [FlowsUpdatesFilter] in case [updatesFilter] is provided and
* [CoroutineScope] as new [BehaviourContext.scope]

View File

@ -25,7 +25,7 @@ import kotlin.coroutines.coroutineContext
*/
suspend fun telegramBotWithBehaviour(
token: String,
flowsUpdatesFilter: FlowsUpdatesFilter,
flowsUpdatesFilter: FlowsUpdatesFilter = FlowsUpdatesFilter(),
scope: CoroutineScope? = null,
apiUrl: String = telegramBotAPIDefaultUrl,
builder: KtorRequestsExecutorBuilder.() -> Unit = {},
@ -77,13 +77,3 @@ suspend fun telegramBotWithBehaviourAndLongPolling(
)
}
}
@Deprecated("Renamed to telegramBotWithBehaviourAndLongPolling")
suspend fun telegramBotWithBehaviour(
token: String,
scope: CoroutineScope? = null,
apiUrl: String = telegramBotAPIDefaultUrl,
builder: KtorRequestsExecutorBuilder.() -> Unit = {},
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
block: BehaviourContextReceiver<Unit>
) = telegramBotWithBehaviourAndLongPolling(token, scope, apiUrl, builder, defaultExceptionsHandler, block)

View File

@ -119,14 +119,6 @@ suspend fun BehaviourContext.waitEditedStaticLocation(
filter: SimpleFilter<CommonMessage<StaticLocationContent>>? = null,
mapper: CommonMessageToContentMapper<StaticLocationContent>? = null
) = waitEditedContent(count, initRequest, false, errorFactory, filter, mapper)
@Deprecated("Potentially, this trigger will never be used. Use `waitPollUpdates` instead")
suspend fun BehaviourContext.waitEditedPoll(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null },
count: Int = 1,
filter: SimpleFilter<CommonMessage<PollContent>>? = null,
mapper: CommonMessageToContentMapper<PollContent>? = null
) = waitEditedContent(count, initRequest, false, errorFactory, filter, mapper)
suspend fun BehaviourContext.waitEditedText(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null },

View File

@ -166,19 +166,6 @@ suspend fun <BC : BehaviourContext> BC.onEditedLocation(
scenarioReceiver
)
@Deprecated("Potentially, this trigger will never be used. Use `onPollUpdated` instead")
suspend fun <BC : BehaviourContext> BC.onEditedPoll(
initialFilter: CommonMessageFilter<PollContent>? = CommonMessageFilterExcludeMediaGroups,
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<PollContent>, Update> = MessageFilterByChat,
markerFactory: MarkerFactory<in CommonMessage<PollContent>, Any> = ByChatMessageMarkerFactory,
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<PollContent>>
)= onEditedContent(
initialFilter,
subcontextUpdatesFilter,
markerFactory,
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,

View File

@ -26,10 +26,7 @@ data class UnknownInlineKeyboardButton internal constructor(
*/
@Serializable
data class PayInlineKeyboardButton(
override val text: String,
@Deprecated("Don't use this button due to removing of this in near release")
@Transient
val pay: Boolean = true
override val text: String
) : InlineKeyboardButton {
@ExperimentalSerializationApi
@EncodeDefault

View File

@ -20,7 +20,4 @@ data class PrivateContentMessageImpl<T: MessageContent>(
override val replyTo: Message?,
override val replyMarkup: InlineKeyboardMarkup?,
override val senderBot: CommonBot?,
) : PrivateContentMessage<T> {
@Deprecated("This value will always be null. You may get SuccessfulPayment as one of ChatEvents")
val paymentInfo: SuccessfulPaymentEvent? = null
}
) : PrivateContentMessage<T>

View File

@ -4,8 +4,6 @@ import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.CommonEvent
import dev.inmo.tgbotapi.types.message.payments.abstracts.PaymentInfo
import dev.inmo.tgbotapi.types.payments.SuccessfulPayment
@Deprecated("Renamed", ReplaceWith("SuccessfulPaymentEvent", "dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent"))
typealias SuccessfulPaymentInfo = SuccessfulPaymentEvent
data class SuccessfulPaymentEvent(
val payment: SuccessfulPayment
) : PaymentInfo, CommonEvent