mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 08:13:47 +00:00
new startGettingOfUpdates extension
This commit is contained in:
parent
4877b8958e
commit
6c39dc4d06
@ -40,6 +40,9 @@
|
||||
|
||||
### 0.26.2
|
||||
|
||||
* `TelegramBotAPI-extensions-api`:
|
||||
* `startGettingOfUpdates` extension which not require filter (but return a new one) was added
|
||||
|
||||
### 0.26.1
|
||||
|
||||
* `TelegramBotAPI`:
|
||||
|
@ -10,6 +10,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.update.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.MediaGroupUpdates.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.updateshandlers.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.PreviewFeature
|
||||
import io.ktor.client.features.HttpRequestTimeoutException
|
||||
import kotlinx.coroutines.*
|
||||
|
||||
@ -63,6 +64,21 @@ fun RequestsExecutor.startGettingOfUpdates(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will create a new one [FlowsUpdatesFilter]. This method is unsafe due to the fact that it will start
|
||||
* getting updates IMMEDIATELY. That means that your bot will be able to skip some of them until you will call
|
||||
* [kotlinx.coroutines.flow.Flow.collect] on one of [FlowsUpdatesFilter] flows
|
||||
*/
|
||||
@PreviewFeature
|
||||
fun RequestsExecutor.startGettingOfUpdates(
|
||||
timeoutSeconds: Seconds = 30,
|
||||
scope: CoroutineScope = CoroutineScope(Dispatchers.Default),
|
||||
exceptionsHandler: (suspend (Exception) -> Unit)? = null,
|
||||
flowsUpdatesFilterUpdatesKeeperCount: Int = 64
|
||||
): FlowsUpdatesFilter = FlowsUpdatesFilter(flowsUpdatesFilterUpdatesKeeperCount).apply {
|
||||
startGettingOfUpdates(timeoutSeconds, scope, exceptionsHandler, allowedUpdates, asUpdateReceiver)
|
||||
}
|
||||
|
||||
fun RequestsExecutor.startGettingOfUpdates(
|
||||
updatesFilter: UpdatesFilter,
|
||||
timeoutSeconds: Seconds = 30,
|
||||
|
Loading…
Reference in New Issue
Block a user