tdlight-java/README.md

191 lines
6.3 KiB
Markdown
Raw Normal View History

2021-10-01 19:40:35 +02:00
<div style="text-align: center" align="center">
<a href="https://github.com/tdlight-team/tdlight-java"><img src="./.media/tdlight-logo.png" alt="TDLight logo" style="width: 5rem; height: 5rem"></a>
<h1>TDLight Java</h1>
<p>Complete Bot and Userbot Telegram library written in Java, based on <a href="https://github.com/tdlib/td">TDLib</a></p>
2023-01-02 01:22:58 +01:00
<a href="https://github.com/tdlight-team/tdlight-java/actions/workflows/maven-publish.yml">
<img alt="Maven package" src="https://github.com/tdlight-team/tdlight-java/actions/workflows/maven-publish.yml/badge.svg?branch=master"></a>
2021-10-01 16:59:34 +02:00
<a href="https://github.com/tdlight-team/tdlight-java/releases">
2023-01-02 01:22:58 +01:00
<img alt="Release" src="https://img.shields.io/github/v/release/tdlight-team/tdlight-java.svg?include_prereleases&style=flat-square">
2021-10-01 16:59:34 +02:00
</a>
<a href="https://www.ej-technologies.com/products/jprofiler/overview.html">
2021-10-01 19:40:35 +02:00
<img alt="JProfiler" src="https://local.cavallium.it/mirrors/jprofiler-logo/jprofiler-logo-badge.svg">
2021-10-01 16:59:34 +02:00
</a>
</div>
<br>
2021-10-01 19:40:35 +02:00
## 💻 Supported platforms
2021-10-01 16:59:34 +02:00
**Java versions**: from Java 17 to Java 21+ (Java 8 to 16 is supported if you use the following dependency classifier: `jdk8`)
2021-10-01 16:59:34 +02:00
**Operating systems**: Linux, Windows, MacOS
**CPU architectures**:
2021-10-22 12:54:28 +02:00
- amd64 (Linux, Windows, MacOS)
- armhf (Linux)
- arm64 (Linux)
- ppc64el (Linux)
- riscv64 (linux)
2020-08-20 12:18:04 +02:00
## 📚 Required libraries
- **Linux: OpenSSL1/OpenSSL3, zlib, (libc++ if you use clang)**
- **MacOS: OpenSSL**
- **Windows: [Microsoft Visual C++ Redistributable](https://aka.ms/vs/17/release/vc_redist.x64.exe)**
2020-08-20 12:18:04 +02:00
2021-10-01 19:40:35 +02:00
### Install OpenSSL on macOS
2021-10-22 12:54:28 +02:00
2021-11-06 11:59:31 +01:00
You must install `openssl@3` using the <a href="https://brew.sh">brew package manager </a>, then link openssl
2021-10-22 12:54:28 +02:00
to `/usr/local/opt/openssl`
2021-10-01 16:59:34 +02:00
2021-10-01 19:40:35 +02:00
If you don't know how to do this, type the following commands in your terminal:
2021-10-01 16:59:34 +02:00
```bash
2021-11-06 11:59:31 +01:00
brew install openssl@3
ln -sf /usr/local/Cellar/openssl@3/3.0.0 /usr/local/opt/openssl
2021-10-01 16:59:34 +02:00
```
2021-09-30 19:14:54 +02:00
2021-10-01 19:40:35 +02:00
## 📚 How to use the library
2021-10-22 12:54:28 +02:00
2021-10-01 19:40:35 +02:00
### Setting up the library using Maven
2021-10-22 12:54:28 +02:00
2021-10-01 19:40:35 +02:00
If you are using Maven, edit your `pom.xml` file as below:
2021-10-22 12:54:28 +02:00
2020-08-20 12:18:04 +02:00
```xml
2021-10-22 12:54:28 +02:00
2021-09-27 19:27:13 +02:00
<project>
2021-10-22 12:54:28 +02:00
<repositories>
<!-- Add the following repository -->
<repository>
<id>mchv</id>
<name>MCHV Apache Maven Packages</name>
<url>https://mvn.mchv.eu/repository/mchv/</url>
</repository>
</repositories>
<dependencyManagement>
<dependencies>
<!-- Add the following dependency -->
<dependency>
<groupId>it.tdlight</groupId>
<artifactId>tdlight-java-bom</artifactId>
<version>VERSION</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
2021-10-22 12:54:28 +02:00
<dependencies>
<!-- Add the following dependencies -->
<dependency>
<groupId>it.tdlight</groupId>
2023-05-15 00:10:23 +02:00
<artifactId>tdlight-java</artifactId>
<!-- Java 8 is supported if you use the following dependency classifier: <classifier>jdk8</classifier> -->
<!-- don't specify the version here -->
2021-10-22 12:54:28 +02:00
</dependency>
<!-- Example linux amd64 (GNU GCC) ssl1 natives -->
2021-10-22 12:54:28 +02:00
<dependency>
<groupId>it.tdlight</groupId>
2023-05-15 00:10:23 +02:00
<artifactId>tdlight-natives</artifactId>
<classifier>linux_amd64_gnu_ssl1</classifier>
<!-- don't specify the version here -->
2021-10-22 12:54:28 +02:00
</dependency>
2023-05-15 00:10:23 +02:00
<!-- Example windows amd64 natives -->
<dependency>
<groupId>it.tdlight</groupId>
<artifactId>tdlight-natives</artifactId>
<classifier>windows_amd64</classifier>
<!-- don't specify the version here -->
</dependency>
<!-- ... -->
<!-- Include other native classifiers, for example linux_amd64_ssl3, macos_amd64, ... -->
2021-10-22 12:54:28 +02:00
</dependencies>
2021-09-27 19:27:13 +02:00
</project>
2020-08-23 15:59:19 +02:00
```
2021-09-27 19:27:13 +02:00
2021-10-22 12:54:28 +02:00
Replace `VERSION` with the latest release version, you can find
it [here](https://github.com/tdlight-team/tdlight-java/releases).
2021-10-01 19:40:35 +02:00
## Setting up the library using Gradle
2021-10-22 12:54:28 +02:00
2021-10-01 19:40:35 +02:00
If you are using Gradle, add the following lines into your `build.gradle` file
2021-10-22 12:54:28 +02:00
2020-08-20 12:18:04 +02:00
```groovy
repositories {
2021-10-22 12:54:28 +02:00
maven { url "https://mvn.mchv.eu/repository/mchv/" }
2020-08-20 12:18:04 +02:00
}
dependencies {
// import the BOM
implementation platform('it.tdlight:tdlight-java-bom:VERSION')
// do not specify the versions on the dependencies below!
2023-05-15 00:38:52 +02:00
implementation group: 'it.tdlight', name: 'tdlight-java' // Java 8 is supported if you use the following dependency classifier: `jdk8`
implementation group: 'it.tdlight', name: 'tdlight-natives', classifier: 'linux_amd64_gnu_ssl1'
// Include other native classifiers, for example linux_amd64_clang_ssl3, macos_amd64, ... -->
2020-08-20 12:18:04 +02:00
}
```
2021-09-27 19:27:13 +02:00
2021-10-22 12:54:28 +02:00
Replace `VERSION` with the latest release version, you can find
it [here](https://github.com/tdlight-team/tdlight-java/releases).
2021-10-01 19:40:35 +02:00
## âš’ Native dependencies
2021-10-22 12:54:28 +02:00
2023-05-15 00:10:23 +02:00
To use TDLight Java you need to include the native libraries, by specifying one of the following classifier for each tdlight-natives dependency:
2021-10-22 12:54:28 +02:00
- `linux_amd64_clang_ssl3`
- `linux_amd64_gnu_ssl1`
- `linux_amd64_gnu_ssl3`
- `linux_arm64_clang_ssl3`
- `linux_arm64_gnu_ssl1`
- `linux_arm64_gnu_ssl3`
- `linux_armhf_gnu_ssl1`
- `linux_armhf_gnu_ssl3`
- `linux_ppc64el_gnu_ssl3`
- `linux_riscv64_gnu_ssl3`
2023-05-15 00:10:23 +02:00
- `windows_amd64`
- `macos_amd64`
2023-05-15 00:38:52 +02:00
Advanced: If you want to use a different precompiled native, please set the java property `it.tdlight.native.workdir`. (Please note that you must build [this](https://github.com/tdlight-team/tdlight-java-natives), you can't put random precompiled tdlib binaries found on the internet)
2021-10-01 19:40:35 +02:00
## Usage
2021-10-22 12:54:28 +02:00
An example on how to use TDLight Java can be found
here: [Example.java](https://github.com/tdlight-team/tdlight-java/blob/master/example/src/main/java/it/tdlight/example/Example.java)
2021-10-06 20:43:57 +02:00
### Advanced usage
2021-10-22 12:54:28 +02:00
If you want to disable the automatic runtime shutdown hook, you should set the property `it.tdlight.enableShutdownHooks`
to `false`
2021-10-06 20:43:57 +02:00
2021-10-01 19:40:35 +02:00
### TDLight methods documentation
2021-10-22 12:54:28 +02:00
2021-09-27 19:27:13 +02:00
[TdApi JavaDoc](https://tdlight-team.github.io/tdlight-docs)
2020-08-20 13:46:17 +02:00
2021-10-01 19:40:35 +02:00
### TDLight extended features
2021-10-22 12:54:28 +02:00
TDLight has some extended features compared to TDLib, that you can see on
the [TDLight official repository](https://github.com/tdlight-team/tdlight#tdlight-extra-features).
2020-08-28 21:38:49 +02:00
2021-10-01 19:40:35 +02:00
## About
2021-10-22 12:54:28 +02:00
2021-10-01 19:40:35 +02:00
### **License**
2021-10-22 12:54:28 +02:00
2020-08-20 13:35:14 +02:00
TDLight is licensed by Andrea Cavalli <andrea@cavallium.it> under the terms of the GNU Lesser General Public License 3
2020-08-20 12:18:04 +02:00
2021-10-01 19:40:35 +02:00
### **Libraries licenses**
2020-08-20 12:18:04 +02:00
2021-10-22 12:54:28 +02:00
JTDLib is licensed by Ernesto Castellotti <erny.castell@gmail.com> under the terms of the GNU Lesser General Public
License 3
2020-08-20 13:35:14 +02:00
2021-10-22 12:54:28 +02:00
TDLib is licensed by Aliaksei Levin <levlam@telegram.org> and Arseny Smirnov <arseny30@gmail.com> under the terms of the
Boost Software License
2020-08-20 13:35:14 +02:00
OpenSSL is licensed under the terms of Apache License v2
2020-08-20 17:10:36 +02:00
Zlib is licensed under the terms of Zlib license