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,
    is_cli: false,
    timeOutUpdate: 1.0,
    delayInvoke: Duration(milliseconds: 1),
    delayUpdate: Duration(milliseconds: 1),
    task_max_count: 10000,
    task_min_cooldown: 10,
    isInvokeThrowOnError: true,
  );
  telegramClientTelegramBotApiOption ??= TelegramClientTelegramBotApiOption(
    tokenBot: "",
    clientOption: {},
  );
  if (is_init_telegram_bot_api) {
    telegramBotApi = TelegramBotApi(
      tokenBot: telegramClientTelegramBotApiOption.tokenBot,
      event_invoke: event_invoke,
      event_update: event_update,
      clientOption: telegramClientTelegramBotApiOption.clientOption,
      eventEmitter: event_emitter,
      serverUniverseNative:
          telegramClientTelegramBotApiOption.serverUniverseNative,
      telegramCryptoKey: telegramClientTelegramBotApiOption.telegramCryptoKey,
      telegramUrlWebhook:
          telegramClientTelegramBotApiOption.telegramUrlWebhook,
      httpClient: telegramClientTelegramBotApiOption.httpClient,
    );
    telegramBotApi.initServer();
  }
  if (is_init_tdlib) {
    tdlib = Tdlib(
      pathTdl: pathTdlib,
      is_cli: telegramClientTdlibOption.is_cli,
      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,
      on_generate_extra_invoke:
          telegramClientTdlibOption.on_generate_extra_invoke,
      on_get_invoke_data: telegramClientTdlibOption.on_get_invoke_data,
      on_receive_update: telegramClientTdlibOption.on_receive_update,
      isInvokeThrowOnError: telegramClientTdlibOption.isInvokeThrowOnError,
      eventEmitter: event_emitter,
      task_max_count: telegramClientTdlibOption.task_max_count,
      task_min_cooldown: telegramClientTdlibOption.task_min_cooldown,
    );
  }
}