tdlight-java/README.md

132 lines
3.8 KiB
Markdown
Raw Normal View History

2020-08-20 13:46:17 +02:00
TDLight Java [![Build Status](https://travis-ci.org/tdlight-team/tdlight-java.svg?branch=dev)](https://travis-ci.org/tdlight-team/tdlight-java)
2020-08-20 12:18:04 +02:00
====================
2020-08-20 12:22:02 +02:00
A barebone java wrapper for TDLib (and TDLight)
2020-08-20 13:46:17 +02:00
This wrapper gives you direct access to TDLib API in Java.
2020-08-20 12:18:04 +02:00
## Requirements
JVM: Oracle JVM and OpenJDK
Java versions: Java 8, 9, 10, 11, 12, 13, 14, 15
2020-08-20 12:18:04 +02:00
Operating system: Windows, Linux
Supported CPU architectures: amd64 (linux, windows), aarch64 (linux)
Required libraries for linux: OpenSSL and zlib
2020-08-20 17:05:50 +02:00
## Including TDLight Java in a project
There are two packages of TDLight:
- [TDLight](#For-TDLight-Java-with-optimized-TDLight), with our optimized fork of TDLib (Reccomended for bots)
- [TDLight with official TDLib](#For-TDLight-Java with-official-TDLib) (Reccomended for GUI clients)
The two packages are compatible, but while TDLight is focused on long term resources usage and speed, TDLib is more focused on stability.
Choose one of the two different TDLight packages and then follow the guide below.
Replace `REPLACE_WITH_LATEST_VERSION` with the latest version of tdlight, you can find it on the **Releases** tab on github.
### For TDLight Java with optimized TDLight
#### Maven
2020-08-20 12:18:04 +02:00
```xml
<repositories>
<repository>
<id>tdlight-gihtub</id>
<name>GitHub TDLight Team Apache Maven Packages</name>
<url>https://maven.pkg.github.com/tdlight-team/tdlight-java</url>
</repository>
</repositories>
<dependencies>
<dependency>
2020-08-20 12:49:49 +02:00
<groupId>it.tdlight</groupId>
<artifactId>tdlight-java</artifactId>
2020-08-20 12:18:04 +02:00
<version>REPLACE_WITH_LATEST_VERSION</version>
</dependency>
</dependencies>
```
2020-08-20 17:05:50 +02:00
#### Gradle
2020-08-20 12:18:04 +02:00
```groovy
repositories {
maven { url "https://maven.pkg.github.com/tdlight-team/tdlight-java" }
}
dependencies {
2020-08-20 12:49:49 +02:00
implementation 'it.tdlight:tdlight-java:REPLACE_WITH_LATEST_VERSION'
2020-08-20 12:18:04 +02:00
}
```
2020-08-20 17:05:50 +02:00
### For TDLight Java with official TDLib
#### Maven
```xml
<repositories>
<repository>
<id>tdlight-gihtub</id>
<name>GitHub TDLight Team Apache Maven Packages</name>
<url>https://maven.pkg.github.com/tdlight-team/tdlight-java</url>
</repository>
</repositories>
2020-08-20 12:18:04 +02:00
2020-08-20 17:05:50 +02:00
<dependencies>
<dependency>
<groupId>it.tdlight</groupId>
<artifactId>tdlight-java</artifactId>
<version>REPLACE_WITH_LATEST_VERSION</version>
</dependency>
</dependencies>
```
#### Gradle
```groovy
repositories {
maven { url "https://maven.pkg.github.com/tdlight-team/tdlight-java" }
}
dependencies {
implementation 'it.tdlight:tdlight-java:REPLACE_WITH_LATEST_VERSION'
}
```
2020-08-20 12:18:04 +02:00
## Usage
Simple initialization of a native TDLib client
```java
import java.io.File;
import it.tdlight.tdlight.Client;
import it.tdlight.tdlight.Init;
import it.tdlight.tdlight.Log;
public class Example {
public static void main(String[] args) {
// Initialize TDLight native libraries
Init.start();
// Set TDLib log level to 1
Log.setVerbosityLevel(1);
// Uncomment this line to print TDLib logs to a file
// Log.setFilePath("logs" + File.separatorChar + "tdlib.log");
Client client = new Client();
// Initialize the TDLib client
client.initializeClient();
// Now you can use the client
}
}
```
2020-08-20 13:46:17 +02:00
### TDLib methods documentation
[TdApi class javadoc](https://tdlight-team.github.io/tdlib-docs)
2020-08-20 12:18:04 +02:00
## About
#### License
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
2020-08-20 13:35:14 +02:00
### Libraries licenses
2020-08-20 12:18:04 +02:00
2020-08-20 13:35:14 +02:00
JTDlib is licensed by Ernesto Castellotti <erny.castell@gmail.com> under the terms of the GNU Lesser General Public License 3
TDLib is licensed by Aliaksei Levin <levlam@telegram.org> and Arseny Smirnov <arseny30@gmail.com> under the terms of the Boost Software License
OpenSSL is licensed under the terms of Apache License v2
Zlib is licensed under the terms of Zlib license