mirror of
https://github.com/jwdeveloper/TikTokLiveJava.git
synced 2026-02-28 01:09:40 -05:00
.
This commit is contained in:
@@ -22,35 +22,44 @@
|
||||
*/
|
||||
package io.github.jwdeveloper.tiktok;
|
||||
|
||||
import io.github.jwdeveloper.tiktok.data.events.TikTokSubNotifyEvent;
|
||||
import io.github.jwdeveloper.tiktok.data.events.TikTokSubscribeEvent;
|
||||
import io.github.jwdeveloper.tiktok.data.events.gift.TikTokGiftEvent;
|
||||
import io.github.jwdeveloper.tiktok.exceptions.TikTokLiveOfflineHostException;
|
||||
import io.github.jwdeveloper.tiktok.utils.ConsoleColors;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.Duration;
|
||||
import java.util.HashMap;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class SimpleExample
|
||||
{
|
||||
public static String TIKTOK_HOSTNAME = "adasdsadadadasdasdsadasdasad";
|
||||
public class SimpleExample {
|
||||
public static String TIKTOK_HOSTNAME = "bangbetmenygy";
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
|
||||
showLogo();
|
||||
// set tiktok username
|
||||
|
||||
|
||||
/*
|
||||
//Optional checking if host name is correct
|
||||
if(TikTokLive.isHostNameValid(TIKTOK_HOSTNAME))
|
||||
{
|
||||
System.out.println("user name exists!");
|
||||
}
|
||||
*/
|
||||
|
||||
//Optional checking if live is online
|
||||
// Optional checking if live is online
|
||||
if(TikTokLive.isLiveOnline(TIKTOK_HOSTNAME))
|
||||
{
|
||||
System.out.println("Live is online!");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
TikTokLive.newClient(SimpleExample.TIKTOK_HOSTNAME)
|
||||
.configure(clientSettings ->
|
||||
{
|
||||
@@ -73,18 +82,43 @@ public class SimpleExample
|
||||
|
||||
//clientSettings.setRoomId("XXXXXXXXXXXXXXXXX");
|
||||
})
|
||||
.onConnected((liveClient, event) ->
|
||||
{
|
||||
for (var gift : liveClient.getGiftManager().getGifts()) {
|
||||
gift.getPicture().downloadImageAsync().thenAccept(image ->
|
||||
{
|
||||
|
||||
});
|
||||
}
|
||||
})
|
||||
.onWebsocketMessage((liveClient, event) ->
|
||||
{
|
||||
|
||||
|
||||
var tiktokLiveEvent = event.getEvent();
|
||||
if(tiktokLiveEvent instanceof TikTokSubNotifyEvent e)
|
||||
{
|
||||
System.out.println("it was subscrible event");
|
||||
}
|
||||
|
||||
})
|
||||
.onWebsocketResponse((liveClient, event) ->
|
||||
{
|
||||
event.getResponse();
|
||||
})
|
||||
.onGift((liveClient, event) ->
|
||||
{
|
||||
switch (event.getGift()) {
|
||||
case ROSE -> print(ConsoleColors.RED, "Rose!");
|
||||
case GG -> print(ConsoleColors.YELLOW, " GOOD GAME!");
|
||||
case TIKTOK -> print(ConsoleColors.CYAN,"Thanks for TikTok");
|
||||
default -> print(ConsoleColors.GREEN, "[Thanks for gift] ", ConsoleColors.YELLOW, event.getGift().getName(), "x", event.getCombo());
|
||||
case TIKTOK -> print(ConsoleColors.CYAN, "Thanks for TikTok");
|
||||
default ->
|
||||
print(ConsoleColors.GREEN, "[Thanks for gift] ", ConsoleColors.YELLOW, event.getGift().getName(), "x", event.getCombo());
|
||||
}
|
||||
})
|
||||
.onGiftCombo((liveClient, event) ->
|
||||
{
|
||||
print(ConsoleColors.RED,"GIFT COMBO",event.getGift().getName(),event.getCombo());
|
||||
print(ConsoleColors.RED, "GIFT COMBO", event.getGift().getName(), event.getCombo());
|
||||
})
|
||||
.onConnected((client, event) ->
|
||||
{
|
||||
@@ -92,7 +126,7 @@ public class SimpleExample
|
||||
})
|
||||
.onDisconnected((liveClient, event) ->
|
||||
{
|
||||
print(ConsoleColors.RED,"[Disconnected]");
|
||||
print(ConsoleColors.RED, "[Disconnected]");
|
||||
})
|
||||
.onRoomInfo((liveClient, event) ->
|
||||
{
|
||||
@@ -130,9 +164,8 @@ public class SimpleExample
|
||||
System.out.println(sb);
|
||||
}
|
||||
|
||||
private static void showLogo()
|
||||
{
|
||||
System.out.println(ConsoleColors.GREEN+"""
|
||||
private static void showLogo() {
|
||||
System.out.println(ConsoleColors.GREEN + """
|
||||
|
||||
_____ _ _ _____ _ _ _ \s
|
||||
|_ _(_) | _|_ _|__ | | _| | (_)_ _____\s
|
||||
|
||||
Reference in New Issue
Block a user