SimpleMultiServerRequestsExecutor

class SimpleMultiServerRequestsExecutor(bots: List<TelegramBot>, botSelector: suspend List<TelegramBot>.(currentBotIndex: Int, t: Throwable?) -> TelegramBot, onClose: () -> Unit) : RequestsExecutor

This type of RequestsExecutor (aka TelegramBot) has been created to aggregate several bots under the hood and make requests, for example, with changing of api url

Parameters

bots

Bots which will be used to executes

botSelector

It is strategy by which the bot is selected for the execution. This lambda will receive -1 when request execution just started and this call is first in context of one execute. By default, will select next TelegramBot when called (or first when current index is last or -1)

onClose

This method will be called inside of close method. By default, will close all bots

Constructors

Link copied to clipboard
fun SimpleMultiServerRequestsExecutor(bots: List<TelegramBot>, botSelector: suspend List<TelegramBot>.(currentBotIndex: Int, t: Throwable?) -> TelegramBot = { i, _ -> getOrElse(i + 1) { first() } }, onClose: () -> Unit = { bots.forEach(TelegramBot::close) })

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
open override fun close()
Link copied to clipboard
open suspend override fun <T : Any> execute(request: Request<T>): T

Unsafe execution of incoming request. Can throw almost any exception. So, it is better to use something like dev.inmo.tgbotapi.extensions.utils.shortcuts.executeAsync or dev.inmo.tgbotapi.extensions.utils.shortcuts.executeUnsafe