Due to convention, interfaces should not have TikTok name inside, but they should have prefix Live instead

- rename TikTokMapper to LiveMapper
- rename TikTokLiveMapperHelper to LiveMapperHelper

Create interface:
LiveEventsHandler for TikTokLiveEventHandler
LiveMessagesHandler for TikTokLiveMessageHandler
This commit is contained in:
jacek.wolniewicz
2024-07-01 23:28:38 +02:00
parent b223651a8f
commit fed9de3fd0
18 changed files with 52 additions and 7 deletions

View File

@@ -3,6 +3,9 @@ package io.github.jwdeveloper.tiktok;
import io.github.jwdeveloper.tiktok.data.events.common.TikTokEvent;
import io.github.jwdeveloper.tiktok.data.events.gift.TikTokGiftEvent;
import io.github.jwdeveloper.tiktok.data.models.gifts.Gift;
import io.github.jwdeveloper.tiktok.data.settings.LiveClientSettings;
import io.github.jwdeveloper.tiktok.http.HttpClientBuilder;
import io.github.jwdeveloper.tiktok.http.HttpClientFactory;
import io.github.jwdeveloper.tiktok.live.GiftsManager;
import io.github.jwdeveloper.tiktok.live.LiveClient;
@@ -17,6 +20,7 @@ import java.util.function.Predicate;
public class CusomizationExample {
public static void main(String[] args) {
var customEventHandler = new CustomEventsHandler();
var client = TikTokLive.newClient("john")
.configure(liveClientSettings ->
{
@@ -30,7 +34,7 @@ public class CusomizationExample {
.customize(container ->
{
//overriding default implementation of GiftsManager, with own one
container.registerSingleton(TikTokLiveEventHandler.class, CustomEventsHandler.class);
container.registerSingleton(TikTokLiveEventHandler.class, customEventHandler);
}).build();
client.connect();
@@ -38,6 +42,7 @@ public class CusomizationExample {
client.publishEvent(TikTokGiftEvent.of("stone", 2, 12));
}
public static class CustomEventsHandler extends TikTokLiveEventHandler {
@Override

View File

@@ -12,7 +12,7 @@
<module>API</module>
<module>Client</module>
<module>Examples</module>
<module>Tools-ReadmeGenerator</module>
<module>tools-readme</module>
<module>extension-recorder</module>
<module>extension-collector</module>

View File

@@ -9,7 +9,7 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>Tools-ReadmeGenerator</artifactId>
<artifactId>tools-readme</artifactId>
<repositories>
<repository>
<id>jitpack.io</id>
@@ -23,6 +23,11 @@
</properties>
<dependencies>
<dependency>
<groupId>com.hubspot.jinjava</groupId>
<artifactId>jinjava</artifactId>
<version>2.7.2</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>

3
tools-readme/readme.md Normal file
View File

@@ -0,0 +1,3 @@
Generates documentation from template
that can be found under
- `src/main/resources/readme-template.html`

View File

@@ -22,6 +22,7 @@ public class Main
var output = System.getProperty("user.dir");
DescriptionGenerator generator = Descrabble.create()
.withTemplate(targetFile)
.withVariable("version", version)

View File

@@ -0,0 +1,27 @@
package io.github.jwdeveloper.tiktok;
import com.google.common.base.Charsets;
import com.google.common.collect.Maps;
import com.google.common.io.Resources;
import com.hubspot.jinjava.Jinjava;
import java.io.IOException;
import java.util.HashMap;
public class Main2 {
public static void main(String[] args) throws IOException {
var version = System.getenv("VERSION");
if (version == null || version.equals("")) {
version = "[Replace with current version]";
}
var template = Resources.toString(Resources.getResource("my-template.html"), Charsets.UTF_8);
var jinjava = new Jinjava();
var context = new HashMap<String, Object>();
context.put("version", version);
var renderedTemplate = jinjava.render(template, context);
}
}

View File

Before

Width:  |  Height:  |  Size: 241 KiB

After

Width:  |  Height:  |  Size: 241 KiB

View File

@@ -4,7 +4,6 @@
</image>
</container>
<container>
<title>TikTok Live Java</title>
<br>
@@ -19,6 +18,11 @@
</container>
</container>
<text>
A Java library inspired by [TikTokLive](https://github.com/isaackogan/TikTokLive) and [TikTokLiveSharp](https://github.com/frankvHoof93/TikTokLiveSharp). Use it to receive live stream events such as comments and gifts in realtime from [TikTok LIVE](https://www.tiktok.com/live) by connecting to TikTok's internal WebCast push service.
The library includes a wrapper that connects to the WebCast service using just the username (`uniqueId`). This allows you to connect to your own live chat as well as the live chat of other streamers.
No credentials are required. Events such as [Members Joining](#member), [Gifts](#gift), [Subscriptions](#subscribe), [Viewers](#roomuser), [Follows](#social), [Shares](#social), [Questions](#questionnew), [Likes](#like) and [Battles](#linkmicbattle) can be tracked.
</text>
<br>
<code language="xml">

View File

@@ -81,9 +81,10 @@ Do you prefer other programming languages?
## Events
{{events-content}}
{{for item of data }}
@{events-content}
{{for item of data}}
{{if item is 2}}
@@ -102,6 +103,5 @@ my name is {{item.name}}
{{listener-content}}
```
## Contributing
Your improvements are welcome! Feel free to open an <a href="https://github.com/jwdeveloper/TikTok-Live-Java/issues">issue</a> or <a href="https://github.com/jwdeveloper/TikTok-Live-Java/pulls">pull request</a>.