mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 00:03:48 +00:00
clear of webhook on UpdatePoller start
This commit is contained in:
parent
57bf40a4f9
commit
24fb3e2188
@ -74,6 +74,8 @@ of `]` in links titles
|
||||
* `kotlin serialization` version `0.10.0` -> `0.11.0`
|
||||
* `ktor` version `1.1.2` -> `1.1.3`
|
||||
* Added `DeleteWebhook` request
|
||||
* All default `startGettingOfUpdates` (in fact - method `start` of `UpdatesPoller`) are suspend and
|
||||
will try to delete webhook
|
||||
|
||||
## 0.11.0
|
||||
|
||||
|
@ -2,6 +2,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.utils.extensions
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.GetUpdates
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.webhook.DeleteWebhook
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.MediaGroupMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.BaseMessageUpdate
|
||||
@ -72,7 +73,8 @@ class UpdatesPoller(
|
||||
pushMediaGroupUpdate()
|
||||
}
|
||||
|
||||
fun start(): Job {
|
||||
suspend fun start(): Job {
|
||||
executor.executeUnsafe(DeleteWebhook())
|
||||
return pollerJob ?: scope.launch {
|
||||
while (isActive) {
|
||||
delay(requestsDelayMillis)
|
||||
|
@ -9,7 +9,7 @@ import java.util.concurrent.Executors
|
||||
|
||||
typealias UpdateReceiver<T> = suspend (T) -> Unit
|
||||
|
||||
fun RequestsExecutor.startGettingOfUpdates(
|
||||
suspend fun RequestsExecutor.startGettingOfUpdates(
|
||||
requestsDelayMillis: Long = 1000,
|
||||
scope: CoroutineScope = CoroutineScope(Executors.newFixedThreadPool(4).asCoroutineDispatcher()),
|
||||
allowedUpdates: List<String>? = null,
|
||||
@ -18,7 +18,7 @@ fun RequestsExecutor.startGettingOfUpdates(
|
||||
return UpdatesPoller(this, requestsDelayMillis, scope, allowedUpdates, block).start()
|
||||
}
|
||||
|
||||
fun RequestsExecutor.startGettingOfUpdates(
|
||||
suspend fun RequestsExecutor.startGettingOfUpdates(
|
||||
messageCallback: UpdateReceiver<MessageUpdate>? = null,
|
||||
messageMediaGroupCallback: UpdateReceiver<MessageMediaGroupUpdate>? = null,
|
||||
editedMessageCallback: UpdateReceiver<EditMessageUpdate>? = null,
|
||||
@ -58,7 +58,7 @@ fun RequestsExecutor.startGettingOfUpdates(
|
||||
)
|
||||
}
|
||||
|
||||
fun RequestsExecutor.startGettingOfUpdates(
|
||||
suspend fun RequestsExecutor.startGettingOfUpdates(
|
||||
messageCallback: UpdateReceiver<MessageUpdate>? = null,
|
||||
mediaGroupCallback: UpdateReceiver<MediaGroupUpdate>? = null,
|
||||
editedMessageCallback: UpdateReceiver<EditMessageUpdate>? = null,
|
||||
|
Loading…
Reference in New Issue
Block a user