Skip to content

Release 0.2.0

Pre-release
Pre-release

Choose a tag to compare

@batarelkin batarelkin released this 30 Mar 05:25
· 40 commits to master since this release

MAX Bot API Java Client — v0.2.0

Group ID: ru.etsft.max
Java: 21+
License: Apache 2.0


Breaking Changes

Unified UpdateHandler interface

WebhookHandler and MaxLongPollingConsumer.UpdateHandler have been replaced by a single shared interface in the core module:

ru.max.botapi.core.UpdateHandler

Both webhook and long-polling modes now use this interface. Define one handler bean and switch between modes by changing only the max.bot.mode property — no code changes required.

Migration:

Before (0.1.0) After (0.2.0)
WebhookHandler UpdateHandler
MaxLongPollingConsumer.UpdateHandler UpdateHandler
handler.onError(e) (default method) .onError(e -> ...) on builder

onError moved to builder

The onError default method was removed from the handler interface and moved to MaxLongPollingConsumer.Builder.onError(Consumer<Exception>). If not set, errors are logged at WARN level (same default behavior as before).

// Before
MaxLongPollingConsumer.builder()
    .handler(new MaxLongPollingConsumer.UpdateHandler() {
        public void onUpdate(Update update) { ... }
        public void onError(Exception e) { ... }
    })
    .build();

// After
MaxLongPollingConsumer.builder()
    .handler(update -> { ... })
    .onError(e -> { ... })
    .build();

New Features

Auto-created MaxSerializer for webhook mode

The webhook auto-configuration now automatically extracts the MaxSerializer from the MaxBotAPI bean. Users no longer need to declare a MaxSerializer bean manually — it just works when a token is configured.

Previously, missing the MaxSerializer bean caused the webhook controller to silently not start.

serializer() accessor on MaxBotAPI and MaxClient

MaxBotAPI api = MaxBotAPI.create("token");
MaxSerializer serializer = api.serializer();

Publishing guide

Added PUBLISHING.md with step-by-step instructions for publishing to Maven Central via the Central Portal: account setup, GPG key generation, local staging, bundle upload, and CI/CD integration.


Installation

Gradle (String Boot)

dependencies {
    implementation("ru.etsft.max:max-bot-api-spring-boot:0.2.0")
    implementation("ru.etsft.max:max-bot-api-jackson:0.2.0")
}

Maven (String Boot)

<dependency>
    <groupId>ru.etsft.max</groupId>
    <artifactId>max-bot-api-spring-boot</artifactId>
    <version>0.2.0</version>
</dependency>
<dependency>
    <groupId>ru.etsft.max</groupId>
    <artifactId>max-bot-api-jackson</artifactId>
    <version>0.2.0</version>
</dependency>

Gradle

dependencies {
    implementation("ru.etsft.max:max-bot-api-client:0.2.0")
    implementation("ru.etsft.max:max-bot-api-jackson:0.2.0")
    implementation("ru.etsft.max:max-bot-api-longpolling:0.2.0")
}

Maven

<dependency>
    <groupId>ru.etsft.max</groupId>
    <artifactId>max-bot-api-client</artifactId>
    <version>0.2.0</version>
</dependency>
<dependency>
    <groupId>ru.etsft.max</groupId>
    <artifactId>max-bot-api-jackson</artifactId>
    <version>0.2.0</version>
</dependency>
<dependency>
    <groupId>ru.etsft.max</groupId>
    <artifactId>max-bot-api-longpolling</artifactId>
    <version>0.2.0</version>
</dependency>

Spring Boot Quick Start

max:
  bot:
    mode: longpolling   # or "webhook"
    longpolling:
      token: "your-bot-token"
@Bean
UpdateHandler updateHandler() {
    return update -> System.out.println("Got: " + update.updateType());
}

Same handler works for both modes.

Basic configuration for longpolling/webhook:

max:
  bot:
    mode: longpolling # or webhook
    webhook:
      url: "https://<your base url>/api/webhook"
      path: "/api/webhook"
      secret: "some random secret here"
      token: "your-bot-token"
    longpolling:
      token: "your-bot-token"

Links