mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-25 19:48:43 +00:00
new startGettingUpdates method
This commit is contained in:
parent
ba2c4cbb30
commit
944d15f326
@ -22,6 +22,8 @@
|
||||
* `TelegramBotAPI-extensions-api`:
|
||||
* All functions from `com.github.insanusmokrassar.TelegramBotAPI.utils.extensions.UpdatesPolling` now available
|
||||
in package `com.github.insanusmokrassar.TelegramBotAPI.extensions.api.updates.UpdatesPolling`
|
||||
* Now new method of getting updates available: `startGettingUpdates` with `UpdatesFilter` as incoming first
|
||||
parameter
|
||||
|
||||
## 0.23.0 TelegramBotAPI 4.6
|
||||
|
||||
|
@ -6,9 +6,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.ALL_UPDATES_LIST
|
||||
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.KtorUpdatesPoller
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.updateshandlers.UpdatesFilter
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.updateshandlers.UpdateReceiver
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.updateshandlers.*
|
||||
import kotlinx.coroutines.*
|
||||
|
||||
|
||||
@ -28,6 +26,17 @@ fun RequestsExecutor.startGettingOfUpdates(
|
||||
}
|
||||
}
|
||||
|
||||
fun RequestsExecutor.startGettingOfUpdates(
|
||||
updatesFilter: UpdatesFilter,
|
||||
timeoutMillis: Long = 30 * 1000,
|
||||
scope: CoroutineScope = CoroutineScope(Dispatchers.Default)
|
||||
): UpdatesPoller = startGettingOfUpdates(
|
||||
timeoutMillis,
|
||||
scope,
|
||||
updatesFilter.allowedUpdates,
|
||||
updatesFilter.asUpdateReceiver
|
||||
)
|
||||
|
||||
fun RequestsExecutor.startGettingOfUpdates(
|
||||
messageCallback: UpdateReceiver<MessageUpdate>? = null,
|
||||
messageMediaGroupCallback: UpdateReceiver<MessageMediaGroupUpdate>? = null,
|
||||
@ -47,7 +56,8 @@ fun RequestsExecutor.startGettingOfUpdates(
|
||||
timeoutMillis: Long = 30 * 1000,
|
||||
scope: CoroutineScope = GlobalScope
|
||||
): UpdatesPoller {
|
||||
val filter = UpdatesFilter(
|
||||
return startGettingOfUpdates(
|
||||
SimpleUpdatesFilter(
|
||||
messageCallback,
|
||||
messageMediaGroupCallback,
|
||||
editedMessageCallback,
|
||||
@ -63,12 +73,9 @@ fun RequestsExecutor.startGettingOfUpdates(
|
||||
preCheckoutQueryCallback,
|
||||
pollCallback,
|
||||
pollAnswerCallback
|
||||
)
|
||||
return startGettingOfUpdates(
|
||||
),
|
||||
timeoutMillis,
|
||||
scope,
|
||||
filter.allowedUpdates,
|
||||
filter.asUpdateReceiver
|
||||
scope
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -145,7 +145,7 @@ fun createSimpleUpdateFilter(
|
||||
pollCallback: UpdateReceiver<PollUpdate>? = null,
|
||||
pollAnswerCallback: UpdateReceiver<PollAnswerUpdate>? = null,
|
||||
unknownCallback: UpdateReceiver<UnknownUpdateType>? = null
|
||||
): UpdatesFilter = UpdatesFilter(
|
||||
): UpdatesFilter = SimpleUpdatesFilter(
|
||||
messageCallback = messageCallback,
|
||||
messageMediaGroupCallback = mediaGroupCallback,
|
||||
editedMessageCallback = editedMessageCallback,
|
||||
|
Loading…
Reference in New Issue
Block a user