mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-21 15:53:47 +00:00
add additional functions in TelegramBotMiddlewareBuilder
This commit is contained in:
parent
b5b7482c2f
commit
27416daeb8
@ -6,4 +6,4 @@ kotlin.incremental=true
|
||||
kotlin.incremental.js=true
|
||||
|
||||
library_group=dev.inmo
|
||||
library_version=18.2.2
|
||||
library_version=18.2.2-local
|
||||
|
@ -13,6 +13,48 @@ class TelegramBotMiddlewareBuilder {
|
||||
var onRequestResultAbsent: (suspend (request: Request<*>, callsFactories: List<KtorCallFactory>) -> Any?)? = null
|
||||
var onRequestReturnResult: (suspend (result: Result<*>, request: Request<*>, callsFactories: List<KtorCallFactory>) -> Result<Any?>?)? = null
|
||||
|
||||
/**
|
||||
* Useful way to set [onRequestException]
|
||||
*/
|
||||
fun doOnRequestException(block: suspend (request: Request<*>, t: Throwable?) -> Any?) {
|
||||
onRequestException = block
|
||||
}
|
||||
/**
|
||||
* Useful way to set [onBeforeSearchCallFactory]
|
||||
*/
|
||||
fun doOnBeforeSearchCallFactory(block: suspend (request: Request<*>, callsFactories: List<KtorCallFactory>) -> Unit) {
|
||||
onBeforeSearchCallFactory = block
|
||||
}
|
||||
/**
|
||||
* Useful way to set [onBeforeCallFactoryMakeCall]
|
||||
*/
|
||||
fun doOnBeforeCallFactoryMakeCall(block: suspend (request: Request<*>, potentialFactory: KtorCallFactory) -> Unit) {
|
||||
onBeforeCallFactoryMakeCall = block
|
||||
}
|
||||
/**
|
||||
* Useful way to set [onAfterCallFactoryMakeCall]
|
||||
*/
|
||||
fun doOnAfterCallFactoryMakeCall(block: suspend (result: Any?, request: Request<*>, potentialFactory: KtorCallFactory) -> Any?) {
|
||||
onAfterCallFactoryMakeCall = block
|
||||
}
|
||||
/**
|
||||
* Useful way to set [onRequestResultPresented]
|
||||
*/
|
||||
fun doOnRequestResultPresented(block: suspend (result: Any?, request: Request<*>, resultCallFactory: KtorCallFactory, callsFactories: List<KtorCallFactory>) -> Any?) {
|
||||
onRequestResultPresented = block
|
||||
}
|
||||
/**
|
||||
* Useful way to set [onRequestResultAbsent]
|
||||
*/
|
||||
fun doOnRequestResultAbsent(block: suspend (request: Request<*>, callsFactories: List<KtorCallFactory>) -> Any?) {
|
||||
onRequestResultAbsent = block
|
||||
}
|
||||
/**
|
||||
* Useful way to set [onRequestReturnResult]
|
||||
*/
|
||||
fun doOnRequestReturnResult(block: suspend (result: Result<*>, request: Request<*>, callsFactories: List<KtorCallFactory>) -> Result<Any?>?) {
|
||||
onRequestReturnResult = block
|
||||
}
|
||||
|
||||
fun build(): TelegramBotMiddleware {
|
||||
return TelegramBotMiddleware(
|
||||
|
Loading…
Reference in New Issue
Block a user