Files
TeleJ/README.md
2025-11-04 01:52:55 +03:00

143 lines
6.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

### English Version
# TeleJ
An elegant Java library for creating Telegram bots, featuring a framework module to reduce boilerplate and speed up development.
## ⚠️ Project Status ⚠️
**This project is currently under active development.** APIs may change, and features are still being added. It is not yet recommended for production use.
## About The Project
TeleJ is a library designed to simplify and accelerate the process of creating Telegram bots in Java. It provides a convenient API and a modular structure that helps you focus on your bot's logic rather than on repetitive code.
## Key Features
* **Simple Setup:** Get started with your bot quickly.
* **Modular Architecture:** Includes a `core` module, an `event-handlers` framework module, and other components that can be included as needed.
* **Modern Approach:** Utilizes modern Java features to create clean and readable code.
* **Extensible:** Easily extendable to add custom functionality.
### Usage Example
Below is a simple example of how to create and run a bot using TeleJ.
```java
public class MyAwesomeBot {
private static final TelegramBot telegramBot = new OkHttpTelegramBot("token");
public static void main(String[] args) {
telegramBot.start(new UpdateConsumer() {
@Override
public void onUpdate(Update update) {
if (update.hasMessage()) {
Message message = update.message();
if (message.hasText()) {
if (message.text().equalsIgnoreCase("ping!")) {
telegramBot.execute(new SendMessage.Builder(
message.chatId(), "pong!").replyToMessage(message.messageId())
.build());
}
}
}
}
});!
}
}
```
## Project Structure
The project consists of several modules:
* `core`: The core of the library with all the basic functions for interacting with the Telegram Bot API.
* `event-handlers`: A framework module designed to reduce boilerplate and speed up development by simplifying the handling of events and updates from Telegram.
* `annotation-processor`: An annotation processor to simplify code writing.
* `longpolling-okhttp`: An implementation for receiving updates via Long Polling using OkHttp.
## License
This project is distributed under the MIT License.
***
### Русская версия
# TeleJ
Изящная библиотека на Java для создания ботов в Telegram, с модулем фреймворка для ускорения разработки и уменьшения количества шаблонного кода.
## ⚠️ Статус проекта ⚠️
**Этот проект находится в стадии активной разработки.** API может изменяться, а новые функции все еще добавляются. Пока не рекомендуется использовать его в продакшене.
## О проекте
TeleJ — это библиотека, разработанная для упрощения и ускорения процесса создания ботов для Telegram на языке Java. Она предоставляет удобный API и модульную структуру, которая помогает сосредоточиться на логике вашего бота, а не на повторяющемся коде.
## Основные возможности
* **Простая настройка:** Быстрое начало работы с вашим ботом.
* **Модульная архитектура:** Включает основной модуль (`core`), модуль фреймворка (`event-handlers`) и другие компоненты, которые можно подключать по мере необходимости.
* **Современный подход:** Использует современные возможности Java для создания чистого и читаемого кода.
* **Расширяемость:** Легко расширяется для добавления пользовательского функционала.
### Пример использования
Ниже приведен простой пример того, как создать и запустить бота с использованием TeleJ.
```java
public class MyAwesomeBot {
private static final TelegramBot telegramBot = new OkHttpTelegramBot("token");
public static void main(String[] args) {
telegramBot.start(new UpdateConsumer() {
@Override
public void onUpdate(Update update) {
if (update.hasMessage()) {
Message message = update.message();
if (message.hasText()) {
if (message.text().equalsIgnoreCase("ping!")) {
telegramBot.execute(new SendMessage.Builder(
message.chatId(), "pong!").replyToMessage(message.messageId())
.build());
}
}
}
}
});!
}
}
```
## Структура проекта
Проект состоит из нескольких модулей:
* `core`: Ядро библиотеки со всеми основными функциями для взаимодействия с Telegram Bot API.
* `event-handlers`: Модуль фреймворка, предназначенный для уменьшения бойлерплейта (шаблонного кода) и ускорения разработки за счет упрощения обработки событий и обновлений от Telegram.
* `annotation-processor`: Обработчик аннотаций для упрощения написания кода.
* `longpolling-okhttp`: Реализация получения обновлений через Long Polling с использованием OkHttp.
## Лицензия
Этот проект распространяется под лицензией MIT License.