All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.malkusch.telgrambot.api.TelegramApiFactory Maven / Gradle / Ivy

The newest version!
package de.malkusch.telgrambot.api;

import de.malkusch.telgrambot.TelegramApi;

import static java.util.Objects.requireNonNull;

public final class TelegramApiFactory {

    public static TelegramApi telegramApi(String chatId, String token, Timeouts timeouts) {
        requireNonNull(timeouts);

        requireNonNull(chatId);
        if (chatId.isBlank()) {
            throw new IllegalArgumentException("chatId must not be empty");
        }

        requireNonNull(token);
        if (token.isBlank()) {
            throw new IllegalArgumentException("token must not be empty");
        }

        TelegramApi api = new TelegramHttpApi(chatId, token, timeouts);
        api = new TelegramRateLimitedApi(api, timeouts);
        return api;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy