$ show pengrad/java-telegram-bot-api
This repository is a Java/Kotlin client library for the Telegram Bot API, providing type-safe wrappers for all bot API methods and models. The architecture is a classic library with a fluent builder pattern: users create request objects (e.g., `SendMessage`, `GetUpdates`), execute them via the `TelegramBot` class, and receive typed responses. The library handles both synchronous and asynchronous execution, supports long-polling and webhook modes, and includes Telegram Passport encryption/decryption utilities. The codebase is well-structured, with clear separation into model, request, response, and utility packages. It features custom Gson adapters for polymorphic API types (e.g., reaction types, chat boost sources) that demonstrate a clean discriminated union deserialization pattern. The library is actively maintained, tracking Telegram Bot API updates closely, and includes Kotlin extension functions for idiomatic usage. It is not a data research project; it is purely an integration library.
The LLM identified 2 files worth highlighting for reuse:
Implements the Telegram Passport decryption protocol using AES-256-CBC with RSA-OAEP key transport and SHA-256 hash derivation. The package includes custom Base64, AES, and RSA implementations that are self-contained and could be extracted into any Java project needing to decrypt Telegram Passport data. It demonstrates careful handling of cryptographic primitives (secure random, PKCS5 padding, OAEP padding) without external dependencies beyond the standard Java crypto library.
A reusable OkHttp interceptor that automatically retries HTTP requests on 429 (Too Many Requests) responses. It respects the `Retry-After` header and implements exponential backoff with jitter. Though in the test source tree, it is a production-quality utility that can be extracted and applied to any OkHttp-based client to handle Telegram API rate limits gracefully.