ensureInitialized method

void ensureInitialized({
  1. String? pathTdlib,
  2. bool is_init_tdlib = true,
  3. bool is_init_telegram_bot_api = true,
  4. TelegramClientTdlibOption? telegramClientTdlibOption,
  5. TelegramClientTelegramBotApiOption? telegramClientTelegramBotApiOption,
})

return original data json

Implementation

void ensureInitialized({
  String? pathTdlib,
  bool is_init_tdlib = true,
  bool is_init_telegram_bot_api = true,
  TelegramClientTdlibOption? telegramClientTdlibOption,
  TelegramClientTelegramBotApiOption? telegramClientTelegramBotApiOption,
}) {
  telegramClientTdlibOption ??= TelegramClientTdlibOption(
    isAutoGetChat: false,
    timeOutUpdate: 1.0,
    delayInvoke: Duration(milliseconds: 1),
    delayUpdate: Duration(milliseconds: 1),
    taskMaxCount: 10000,
    taskMinCooldown: 10,
    isInvokeThrowOnError: true,
  );
  telegramClientTelegramBotApiOption ??= TelegramClientTelegramBotApiOption(
    tokenBot: "",
    clientOption: {},
  );
  if (is_init_telegram_bot_api) {
    telegramBotApi = TelegramBotApi(
      token_bot: telegramClientTelegramBotApiOption.tokenBot,
      eventInvoke: event_invoke,
      eventUpdate: event_update,
      clientOption: telegramClientTelegramBotApiOption.clientOption,
      eventEmitter: event_emitter,
      serverUniverseNative:
          telegramClientTelegramBotApiOption.serverUniverseNative,
      crypto: telegramClientTelegramBotApiOption.crypto,
      telegramUrlWebhook:
          telegramClientTelegramBotApiOption.telegramUrlWebhook,
      httpClient: telegramClientTelegramBotApiOption.httpClient,
    );
    telegramBotApi.initServer();
  }
  if (is_init_tdlib) {
    tdlib = Tdlib(
      pathTdl: pathTdlib,
      clientOption: telegramClientTdlibOption.clientOption,
      timeOutUpdate: telegramClientTdlibOption.timeOutUpdate,
      invokeTimeOut: telegramClientTdlibOption.invokeTimeOut,
      event_invoke: event_invoke,
      event_update: event_update,
      delayUpdate: telegramClientTdlibOption.delayUpdate,
      delayInvoke: telegramClientTdlibOption.delayInvoke,
      isAutoGetChat: telegramClientTdlibOption.isAutoGetChat,
      onGenerateExtraInvoke: telegramClientTdlibOption.onGenerateExtraInvoke,
      onGetInvokeData: telegramClientTdlibOption.onGetInvokeData,
      onReceiveUpdate: telegramClientTdlibOption.onReceiveUpdate,
      isInvokeThrowOnError: telegramClientTdlibOption.isInvokeThrowOnError,
      eventEmitter: event_emitter,
      taskMaxCount: telegramClientTdlibOption.taskMaxCount,
      taskMinCooldown: telegramClientTdlibOption.taskMinCooldown,
    );
  }
}