Library provides plenty of configuration options, full list of which you can see in the BotConfiguration class description.

There are also two approaches to configuring the bot:

Configurator lambda

// ...
val bot = TelegramBot("BOT_TOKEN") {
  inputListener = RedisInputListenerImpl()
  classManager = KoinClassManagerImpl()
  logging {
      botLogLevel = LogLvl.DEBUG
  }
}
// ...

ConfigLoader interface

There is also the ability to configure through a special ConfigLoader interface,
which you can use to load settings from external sources (properties, command line args, etc.).

The implementation of this interface can be passed through a secondary constructor and the instance will be configured accordingly.

val bot = TelegramBot(ConfigLoaderImpl)

Currently there's several modules provided that implements this interface like ktgram-config-env, ktgram-config-toml.

BotConfiguration Overview

BotConfiguration

The BotConfiguration class is the central hub for configuring a bot. It includes properties for identifying the bot, setting up the API host, determining whether the bot operates in a test environment, handling inputs, managing classes, and controlling input auto-removal. Additionally, it provides internal properties for rate limiting, HTTP client configuration, logging, update listening, and command parsing.

Properties

Configuration Blocks

BotConfiguration also offers functions to configure its internal components:

Associated Configuration Classes

RateLimiterConfiguration

Configures global rate limiting.

HttpConfiguration

Contains configuration for the bot's HTTP client.

LoggingConfiguration

Manages logging levels for bot actions and HTTP requests.

UpdatesListenerConfiguration

Configures parameters related to pulling updates.

CommandParsingConfiguration

Specifies parameters for command parsing.

Example Configuration

Here's an example of how to configure a bot using these classes:

val bot = TelegramBot("TOKEN") {
    identifier = "MyBot",
    apiHost = "https://api.telegram.org",
    isTestEnv = true,
    inputListener = InputListenerMapImpl(),
    classManager = ClassManagerImpl(),

    httpClient {
        requestTimeoutMillis = 5000L
        connectTimeoutMillis = 3000L
        socketTimeoutMillis = 2000L
    }
    logging {
        botLogLevel = LogLvl.DEBUG
        httpLogLevel = HttpLogLevel.BODY
    }
    updatesListener {
        dispatcher = Dispatchers.IO
        processingDispatcher = Dispatchers.Unconfined
        pullingDelay = 1000L
    }
    commandParsing {
        commandDelimiter = '*'
        parametersDelimiter = '&'
        restrictSpacesInCommands = true
    }
}

This configuration sets up a bot with specific identifiers, enables test environment mode, configures rate limiting, HTTP client settings, logging levels, update listener parameters, and command parsing rules.

By leveraging these configuration options, developers can fine-tune their bots to meet specific requirements and optimize performance across various operational scenarios.