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